//Erik Daniel //Graphics engine //parts taken from Nehe tutorials no.6, no.16, no. (Nehe.gamedev.net) #include #include #include #include #include //variables double pposx, pposy, pposz; //typedefs typedef struct light { double ambient[4]; double diffuse[4]; typedef struct vertex { int r, g, b, u, v; double posx, posy, posz; } typedef int entity[3]; typedef struct level { int numentities; entity entities[numentities]; staticmodel levelmodel; } typedef struct frame { int xangle, yangle, zangle; } typedef struct motion { int numframes, fps; frame frames[numframes]; } typedef struct triangle { vertex vertices[3]; } typedef struct staticmodel { int numtriangles; triangles[numtriangles]; } typedef struct bone { int numtriangles, nummotions; triangle triangles[numtriangles]; motion motion[nummotions]; int current_motion; int current_frame; } typedef struct model { string texfilename; int numbones; bone bones[numbones]; } //functions void draw_model(model modl, motion mtion, frame frm, int xpos, int ypos, int zpos, int xrot, int yrot, int zrot) { gltranslate(xpos, ypos, zpos); glrotate3f(xrot, yrot, zrot); glBindTexture(GL_TEXTURE_2D, loadtexture(texfilename.modl)); for(bn=0;bnsizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering } if (TextureImage[0]) // If Texture Exists { if (TextureImage[0]->data) // If Texture Image Exists { free(TextureImage[0]->data); // Free The Texture Image Memory } free(TextureImage[0]); // Free The Image Structure } return Status; // Return The Status } void bindentitylight(entity ent, light lit) { GLfloat LightAmbient[]= { ambient[0].lit f, ambient[1].lit f, ambient[2].lit f, ambient[3].lit f }; GLfloat LightDiffuse[] = { diffuse[0].lit f, diffuse[1].lit f, diffuse[2].lit f, diffuse[3].lit f }; GLfloat LightPosition[]= { xpos.ent.lvl f, ypos.ent.lvl f, zpos.ent.lvl f, 1.0f }; #undef LightAmbient[]; #undef LightDiffuse[]; #undef LightPosition[]; } void bindentityfog(int entitynum, double radius, double r, double g, double b, double s, double density); { GLuint filter; // Which Filter To Use GLuint fogMode[]= { GL_EXP, GL_EXP2, GL_LINEAR }; // Storage For Three Types Of Fog GLuint fogfilter= 0; // Which Fog To Use GLfloat fogColor[4]= {r f, g f, b f, s f}; // Fog Color glClearColor(0.5f,0.5f,0.5f,1.0f); // We'll Clear To The Color Of The Fog ( Modified ) glFogi(GL_FOG_MODE, fogMode[fogfilter]); // Fog Mode glFogfv(GL_FOG_COLOR, fogColor); // Set Fog Color glFogf(GL_FOG_DENSITY, density f); // How Dense Will The Fog Be glHint(GL_FOG_HINT, GL_DONT_CARE); // Fog Hint Value glFogf(GL_FOG_START, 1.0f); // Fog Start Depth glFogf(GL_FOG_END, 5.0f); // Fog End Depth if(pposxxpos.entities[entitynum].level-radius && pposz>zpos.entities[entitynum].level-radius) { glEnable(GL_FOG); // Enables GL_FOG } #undef filter; #undef fogmode[]; #undef fogfilter; #undef fogcolor; } void camerapos(xpos,ypos,zpos,xdir,ydir,zdir) { glulookat(xpos,ypos,zpos,xdir,ydir,zdir,0,0,0); } void draw_level(level lvl) { for(drwps=0;drwps-->
Make your own free website on Tripod.com