   Another newbie OpenGL question :)
  Hey, I've been playing around with some 3ds model loading code i found on the net, but I'm having trouble getting the model to display properly. Im testing with a sphere btw. In ortho i can see it fine but its 2d for obvious reasons, but when I try and use glFrustum I only see a few pixels of the outline. By translating it on the z axis, further into the screen, so further away in a perspective view, the overall size of the outline i can see doesnt appear to change but other parts of it become visible, and some of the parts that were visible before are no longer visible. Can anyone help?(edited to clarify my meaning)I've included a link to a screen shot of whats happening, it should be a solid cube :)   excuse the mess, have been hacking away at it all day trying to figure it out--- code hosted as a zip archive to make life easier: http://www.si.lorcode.com/images/3dsCode.zipmain:#include <SDL/SDL.h>#include <SDL/SDL_opengl.h>#include <iostream>#include <gl\gl.h>// Header File For The OpenGL32 Library#include <gl\glu.h>// Header File For The GLu32 Library#include "Model_3DS.h"#ifdef main#undef main#endifvoid init();void CGLinit();void resizeWindow(int width, int height);int SCREEN_WIDTH = 800;int SCREEN_HEIGHT = 600;int videoFlags;SDL_Event event;int main(int argc, char *argv[]){float txA = 0.0, tyA = 0.0, tzA = 0.0;float tx = 381.214, ty = 295.709, tz = -4.7;init();std::cout << "Init Done" << std::endl;CGLinit();std::cout << "GL Init Done" << std::endl;resizeWindow(SCREEN_WIDTH, SCREEN_HEIGHT);std::cout << "Resize Done" << std::endl;Model_3DS m; std::cout << "Model Defined" << std::endl;m.Load("sphere.3ds");std::cout << "File Loaded" << std::endl;m.shownormals = true;m.lit = false;std::cout << "Lighting False" << std::endl;m.visible = true;glColor3f(0.0,0.0,1.0);//glTranslatef(381.214, 295.709, -5.0);m.pos.x = tx;m.pos.y = ty;m.pos.z = tz;//try changing this to see if we can find the model anywherem.Draw();std::cout << "Model Drawn" << std::endl;SDL_GL_SwapBuffers();while(1){while(SDL_PollEvent(&event)){switch(event.type){case SDL_QUIT:exit(0);break;case SDL_KEYDOWN:switch(event.key.keysym.sym){case SDLK_UP:tyA = 0.1;break;case SDLK_DOWN:tyA = -0.1;break;case SDLK_LEFT:txA = -0.1;break;case SDLK_RIGHT:txA = 0.1;break;case SDLK_z:tzA = 0.1;break;case SDLK_x:tzA = -0.1;break;}break;case SDL_KEYUP:switch(event.key.keysym.sym){case SDLK_UP:tyA = 0.0;break;case SDLK_DOWN:tyA = 0.0;break;case SDLK_LEFT:txA = 0.0;break;case SDLK_RIGHT:txA = 0.0;break;case SDLK_z:tzA = 0.0;break;case SDLK_x:tzA = 0.0;break;}break;}}if((txA != 0.0) || (tyA != 0.0) || (tzA != 0.0)){tx += txA;ty += tyA;tz += tzA;std::cout << "X = " << tx << "\tY = " << ty << "\tZ = " << tz << std::endl;m.pos.x = tx;m.pos.y = ty;m.pos.z = tz;glClear(GL_COLOR_BUFFER_BIT);m.Draw();SDL_GL_SwapBuffers();}}return 0;}void init(){const int SCREEN_BPP = 32;const SDL_VideoInfo *videoInfo;//Initialize SDLif( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { exit(1); } //This bit ripped form nehe tut due to laziness/* Fetch the video info */    videoInfo = SDL_GetVideoInfo( );    if ( !videoInfo ){    fprintf( stderr, "Video query failed: %s\n",SDL_GetError( ) );    exit(1);}/* the flags to pass to SDL_SetVideoMode */    videoFlags  = SDL_OPENGL;/* Enable OpenGL in SDL */    videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */    videoFlags |= SDL_HWPALETTE;  /* Store the palette in hardware */    //videoFlags |= SDL_RESIZABLE;  /* Enable window resizing */ temp disabled, resizing is a bit fucked    /* This checks to see if surfaces can be stored in memory */    if ( videoInfo->hw_available )videoFlags |= SDL_HWSURFACE;    elsevideoFlags |= SDL_SWSURFACE;    /* This checks if hardware blits can be done */    if ( videoInfo->blit_hw )videoFlags |= SDL_HWACCEL;    /* Sets up OpenGL double buffering */    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );//end of rip lol//Create Window if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags) == NULL ) { exit(1);  } //Set caption SDL_WM_SetCaption( "3ds Render", NULL ); }void CGLinit(){glEnable(GL_TEXTURE_2D);// Enable Texture Mapping ( NEW )glShadeModel(GL_SMOOTH);// Enable Smooth ShadingglClearColor(0.0f, 0.0f, 0.0f, 0.5f);// Black BackgroundglClearDepth(1.0f);// Depth Buffer SetupglEnable(GL_DEPTH_TEST);// Enables Depth TestingglDepthFunc(GL_LEQUAL);// The Type Of Depth Testing To DoglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// Really Nice Perspective Calculations//If there was any errors if( glGetError() != GL_NO_ERROR ) { exit(1);  }}void resizeWindow(int width, int height){GLfloat ratio = (GLfloat)SCREEN_WIDTH / (GLfloat)SCREEN_HEIGHT;// Reset the viewportglViewport(0, 0, width, height);// Reset the projection and modelview matrixglMatrixMode(GL_PROJECTION);glLoadIdentity();glFrustum(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0.001, 1000.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}model loading code (not written by me):////////////////////////////////////////////////////////////////////////// 3D Studio Model Class// by: Matthew Fairfax//// Model_3DS.cpp: implementation of the Model_3DS class.// This is a simple class for loading and viewing// 3D Studio model files (.3ds). It supports models// with multiple objects. It also supports multiple// textures per object. It does not support the animation// for 3D Studio models b/c there are simply too many// ways for an artist to animate a 3D Studio model and// I didn't want to impose huge limitations on the artists.// However, I have imposed a limitation on how the models are// textured:// 1) Every faces must be assigned a material// 2) If you want the face to be textured assign the//    texture to the Diffuse Color map// 3) The texture must be supported by the GLTexture class//    which only supports bitmap and targa right now// 4) The texture must be located in the same directory as//    the model//// Support for non-textured faces is done by reading the color// from the material's diffuse color.//// Some models have problems loading even if you follow all of// the restrictions I have stated and I don't know why. If you// can import the 3D Studio file into Milkshape 3D // (http://www.swissquake.ch/chumbalum-soft) and then export it// to a new 3D Studio file. This seems to fix many of the problems// but there is a limit on the number of faces and vertices Milkshape 3D// can read.//// Usage:// Model_3DS m;//// m.Load("model.3ds"); // Load the model// m.Draw();// Renders the model to the screen//// // If you want to show the model's normals// m.shownormals = true;//// // If the model is not going to be lit then set the lit// // variable to false. It defaults to true.// m.lit = false;//// // You can disable the rendering of the model// m.visible = false;// // // You can move and rotate the model like this:// m.rot.x = 90.0f;// m.rot.y = 30.0f;// m.rot.z = 0.0f;//// m.pos.x = 10.0f;// m.pos.y = 0.0f;// m.pos.z = 0.0f;//// // If you want to move or rotate individual objects// m.Objects[0].rot.x = 90.0f;// m.Objects[0].rot.y = 30.0f;// m.Objects[0].rot.z = 0.0f;//// m.Objects[0].pos.x = 10.0f;// m.Objects[0].pos.y = 0.0f;// m.Objects[0].pos.z = 0.0f;////////////////////////////////////////////////////////////////////////// This is used to generate a warning from the compiler#define _QUOTE(x) # x#define QUOTE(x) _QUOTE(x)#define __FILE__LINE__ __FILE__ "(" QUOTE(__LINE__) ") : "#define warn( x )  message( __FILE__LINE__ #x "\n" ) // You need to uncomment this if you are using MFC#pragma warn( You need to uncomment this if you are using MFC )//#include "stdafx.h"#include "Model_3DS.h"#include <math.h>// Header file for the math library#include <gl\gl.h>// Header file for the OpenGL32 library// The chunk's id numbers#define MAIN3DS0x4D4D #define MAIN_VERS0x0002 #define EDIT3DS0x3D3D  #define MESH_VERS0x3D3E  #define OBJECT0x4000   #define TRIG_MESH0x4100    #define VERT_LIST0x4110    #define FACE_DESC0x4120#define FACE_MAT0x4130    #define TEX_VERTS0x4140#define SMOOTH_GROUP0x4150    #define LOCAL_COORDS0x4160  #define MATERIAL0xAFFF   #define MAT_NAME0xA000   #define MAT_AMBIENT0xA010   #define MAT_DIFFUSE0xA020   #define MAT_SPECULAR0xA030   #define SHINY_PERC0xA040   #define SHINY_STR_PERC0xA041   #define TRANS_PERC0xA050   #define TRANS_FOFF_PERC0xA052   #define REF_BLUR_PERC0xA053   #define RENDER_TYPE0xA100   #define SELF_ILLUM0xA084   #define MAT_SELF_ILPCT0xA08A   #define WIRE_THICKNESS0xA087   #define MAT_TEXMAP0xA200    #define MAT_MAPNAME0xA300  #define ONE_UNIT0x0100 #define KEYF3DS0xB000  #define FRAMES0xB008  #define MESH_INFO0xB002   #define HIER_POS0xB030   #define HIER_FATHER0xB010   #define PIVOT_PT0xB013   #define TRACK000xB020   #define TRACK010xB021   #define TRACK020xB022#defineCOLOR_RGB0x0010#define COLOR_TRU0x0011#define COLOR_TRUG0x0012#define COLOR_RGBG0x0013#define PERC_INT0x0030#define PERC_FLOAT0x0031//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////Model_3DS::Model_3DS(){// Initialization// Don't show the normals by defaultshownormals = false;// The model is lit by defaultlit = true;// The model is visible by defaultvisible = true;// Set up the default positionpos.x = 0.0f;pos.y = 0.0f;pos.z = 0.0f;// Set up the default rotationrot.x = 0.0f;rot.y = 0.0f;rot.z = 0.0f;// Set up the pathpath = new char[80];sprintf(path, "");// Zero out our counters for MFCnumObjects = 0;numMaterials = 0;// Set the scale to onescale = 1.0f;}Model_3DS::~Model_3DS(){}void Model_3DS::Load(char *name){// holds the main chunk headerChunkHeader main;// strip "'sif (strstr(name, "\""))name = strtok(name, "\"");// Find the pathif (strstr(name, "/") || strstr(name, "\\")){// Holds the name of the model minus the pathchar *temp; std::cout << "1" << std::endl;// Find the name without the pathif (strstr(name, "/"))temp = strrchr(name, '/');elsetemp = strrchr(name, '\\');// Allocate space for the pathpath = new char[strlen(name)-strlen(temp)+1];std::cout << "2" << std::endl;// Get a pointer to the end of the path and namechar *src = name + strlen(name) - 1;// Back up until a \ or the startwhile (src != path && !((*(src-1)) == '\\' || (*(src-1)) == '/'))src--;std::cout << "3" << std::endl;// Copy the path into pathmemcpy (path, name, src-name);path[src-name] = 0;}// Load the filebin3ds = fopen(name,"rb");std::cout << "4: " << bin3ds << std::endl;// Make sure we are at the beginningfseek(bin3ds, 0, SEEK_SET);// Load the Main Chunk's headerfread(&main.id,sizeof(main.id),1,bin3ds);    fread(&main.len,sizeof(main.len),1,bin3ds);std::cout << "5" << std::endl;// Start ProcessingMainChunkProcessor(main.len, ftell(bin3ds));std::cout << "6" << std::endl;// Don't need the file anymore so close itfclose(bin3ds);// Calculate the vertex normalsCalculateNormals();std::cout << "7" << std::endl;// For future referencemodelname = name;// Find the total number of faces and verticestotalFaces = 0;totalVerts = 0;for (int i = 0; i < numObjects; i ++){totalFaces += Objects.numFaces/3;totalVerts += Objects.numVerts;}std::cout << "8\tFaces = " << totalFaces << "\t Verts = " << totalVerts << std::endl;// If the object doesn't have any texcoords generate somefor (int k = 0; k < numObjects; k++){if (Objects[k].numTexCoords == 0){// Set the number of texture coordsObjects[k].numTexCoords = Objects[k].numVerts;// Allocate an array to hold the texture coordinatesObjects[k].TexCoords = new GLfloat[Objects[k].numTexCoords * 2];// Make some texture coordsfor (int m = 0; m < Objects[k].numTexCoords; m++){Objects[k].TexCoords[2*m] = Objects[k].Vertexes[3*m];Objects[k].TexCoords[2*m+1] = Objects[k].Vertexes[3*m+1];}}}std::cout << "9" << std::endl;// Let's build simple colored textures for the materials w/o a texturefor (int j = 0; j < numMaterials; j++){if (Materials[j].textured == false){unsigned char r = Materials[j].color.r;unsigned char g = Materials[j].color.g;unsigned char b = Materials[j].color.b;Materials[j].tex.BuildColorTexture(r, g, b);Materials[j].textured = true;}}std::cout << "10" << std::endl;}void Model_3DS::Draw(){if (visible){glPushMatrix();// Move the modelglTranslatef(pos.x, pos.y, pos.z);// Rotate the modelglRotatef(rot.x, 1.0f, 0.0f, 0.0f);glRotatef(rot.y, 0.0f, 1.0f, 0.0f);glRotatef(rot.z, 0.0f, 0.0f, 1.0f);glScalef(scale, scale, scale);// Loop through the objectsfor (int i = 0; i < numObjects; i++){// Enable texture coordiantes, normals, and vertices arraysif (Objects.textured)glEnableClientState(GL_TEXTURE_COORD_ARRAY);if (lit)glEnableClientState(GL_NORMAL_ARRAY);glEnableClientState(GL_VERTEX_ARRAY);// Point them to the objects arraysif (Objects.textured)glTexCoordPointer(2, GL_FLOAT, 0, Objects.TexCoords);if (lit)glNormalPointer(GL_FLOAT, 0, Objects.Normals);glVertexPointer(3, GL_FLOAT, 0, Objects.Vertexes);// Loop through the faces as sorted by material and draw themfor (int j = 0; j < Objects.numMatFaces; j ++){// Use the material's textureMaterials[Objects.MatFaces[j].MatIndex].tex.Use();glPushMatrix();// Move the modelglTranslatef(Objects.pos.x, Objects.pos.y, Objects.pos.z);// Rotate the model//glRotatef(Objects.rot.x, 1.0f, 0.0f, 0.0f);//glRotatef(Objects.rot.y, 0.0f, 1.0f, 0.0f);//glRotatef(Objects.rot.z, 0.0f, 0.0f, 1.0f);glRotatef(Objects.rot.z, 0.0f, 0.0f, 1.0f);glRotatef(Objects.rot.y, 0.0f, 1.0f, 0.0f);glRotatef(Objects.rot.x, 1.0f, 0.0f, 0.0f);// Draw the faces using an index to the vertex arrayglDrawElements(GL_TRIANGLES, Objects.MatFaces[j].numSubFaces, GL_UNSIGNED_SHORT, Objects.MatFaces[j].subFaces);glPopMatrix();}// Show the normals?if (shownormals){// Loop through the vertices and normals and draw the normalfor (int k = 0; k < Objects.numVerts * 3; k += 3){// Disable texturingglDisable(GL_TEXTURE_2D);// Disbale lighting if the model is litif (lit)glDisable(GL_LIGHTING);// Draw the normals blueglColor3f(0.0f, 0.0f, 1.0f);// Draw a line between the vertex and the end of the normalglBegin(GL_LINES);glVertex3f(Objects.Vertexes[k], Objects.Vertexes[k+1], Objects.Vertexes[k+2]);glVertex3f(Objects.Vertexes[k]+Objects.Normals[k], Objects.Vertexes[k+1]+Objects.Normals[k+1], Objects.Vertexes[k+2]+Objects.Normals[k+2]);glEnd();// Reset the color to whiteglColor3f(1.0f, 1.0f, 1.0f);// If the model is lit then renable lightingif (lit)glEnable(GL_LIGHTING);}}}glPopMatrix();}}void Model_3DS::CalculateNormals(){// Let's build some normalsfor (int i = 0; i < numObjects; i++){for (int g = 0; g < Objects.numVerts; g++){// Reduce each vert's normal to unitfloat length;Vector unit;unit.x = Objects.Normals[g*3];unit.y = Objects.Normals[g*3+1];unit.z = Objects.Normals[g*3+2];length = (float)sqrt((unit.x*unit.x) + (unit.y*unit.y) + (unit.z*unit.z));if (length == 0.0f)length = 1.0f;unit.x /= length;unit.y /= length;unit.z /= length;Objects.Normals[g*3]   = unit.x;Objects.Normals[g*3+1] = unit.y;Objects.Normals[g*3+2] = unit.z;}}}void Model_3DS::MainChunkProcessor(long length, long findex){ChunkHeader h;std::cout << "Entering MainChunckProcessor" << std::endl;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);std::cout << "Entering MCP while loop" << std::endl;while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds); fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){// This is the mesh information like vertices, faces, and materialscase EDIT3DS: std::cout << "MCP EDIT3DS" << std::endl;EditChunkProcessor(h.len, ftell(bin3ds));break;// I left this in case anyone gets very ambitiouscase KEYF3DS: std::cout << "MCP KEYF3DS" << std::endl; //KeyFrameChunkProcessor(h.len, ftell(bin3ds)); break;default: std::cout << "MCP default\t" << ftell(bin3ds) << "/" << (findex + length -6) << std::endl;break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET); std::cout << "Exiting MainChunckProcessor" << std::endl;}void Model_3DS::EditChunkProcessor(long length, long findex){ChunkHeader h;std::cout << "Entering EditChunckProcessor" << std::endl;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// First count the number of Objects and Materialswhile (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case OBJECT:numObjects++;break;case MATERIAL:numMaterials++;break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}std::cout << "ECP checkpoint 1" << std::endl;// Now load the materialsif (numMaterials > 0){Materials = new Material[numMaterials];// Material is set to untextured until we find otherwisefor (int d = 0; d < numMaterials; d++)Materials[d].textured = false;fseek(bin3ds, findex, SEEK_SET);int i = 0;while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case MATERIAL:MaterialChunkProcessor(h.len, ftell(bin3ds), i);i++;break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}}std::cout << "ECP checkpoint 2" << std::endl;// Load the Objects (individual meshes in the whole model)if (numObjects > 0){Objects = new Object[numObjects];// Set the textured variable to false until we find a texturefor (int k = 0; k < numObjects; k++)Objects[k].textured = false;// Zero the objects position and rotationfor (int m = 0; m < numObjects; m++){Objects[m].pos.x = 0.0f;Objects[m].pos.y = 0.0f;Objects[m].pos.z = 0.0f;Objects[m].rot.x = 0.0f;Objects[m].rot.y = 0.0f;Objects[m].rot.z = 0.0f;}std::cout << "ECP checkpoint 3" << std::endl;// Zero out the number of texture coordsfor (int n = 0; n < numObjects; n++)Objects[n].numTexCoords = 0;fseek(bin3ds, findex, SEEK_SET);int j = 0;std::cout << "ECP checkpoint 4" << std::endl;while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case OBJECT:ObjectChunkProcessor(h.len, ftell(bin3ds), j);j++;break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);std::cout << "Exiting ECP" << std::endl;}void Model_3DS::MaterialChunkProcessor(long length, long findex, int matindex){ChunkHeader h;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case MAT_NAME:// Loads the material's namesMaterialNameChunkProcessor(h.len, ftell(bin3ds), matindex);break;case MAT_AMBIENT://ColorChunkProcessor(h.len, ftell(bin3ds));break;case MAT_DIFFUSE:DiffuseColorChunkProcessor(h.len, ftell(bin3ds), matindex);break;case MAT_SPECULAR://ColorChunkProcessor(h.len, ftell(bin3ds));case MAT_TEXMAP:// Finds the names of the textures of the material and loads themTextureMapChunkProcessor(h.len, ftell(bin3ds), matindex);break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::MaterialNameChunkProcessor(long length, long findex, int matindex){// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Read the material's namefor (int i = 0; i < 80; i++){Materials[matindex].name = fgetc(bin3ds);if (Materials[matindex].name == 0){Materials[matindex].name = 0;break;}}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::DiffuseColorChunkProcessor(long length, long findex, int matindex){ChunkHeader h;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);// Determine the format of the color and load itswitch (h.id){case COLOR_RGB:// A rgb float color chunkFloatColorChunkProcessor(h.len, ftell(bin3ds), matindex);break;case COLOR_TRU:// A rgb int color chunkIntColorChunkProcessor(h.len, ftell(bin3ds), matindex);break;case COLOR_RGBG:// A rgb gamma corrected float color chunkFloatColorChunkProcessor(h.len, ftell(bin3ds), matindex);break;case COLOR_TRUG:// A rgb gamma corrected int color chunkIntColorChunkProcessor(h.len, ftell(bin3ds), matindex);break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::FloatColorChunkProcessor(long length, long findex, int matindex){float r;float g;float b;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);fread(&r,sizeof(r),1,bin3ds);fread(&g,sizeof(g),1,bin3ds);fread(&b,sizeof(b),1,bin3ds);Materials[matindex].color.r = (unsigned char)(r*255.0f);Materials[matindex].color.g = (unsigned char)(r*255.0f);Materials[matindex].color.b = (unsigned char)(r*255.0f);Materials[matindex].color.a = 255;// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::IntColorChunkProcessor(long length, long findex, int matindex){unsigned char r;unsigned char g;unsigned char b;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);fread(&r,sizeof(r),1,bin3ds);fread(&g,sizeof(g),1,bin3ds);fread(&b,sizeof(b),1,bin3ds);Materials[matindex].color.r = r;Materials[matindex].color.g = g;Materials[matindex].color.b = b;Materials[matindex].color.a = 255;// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::TextureMapChunkProcessor(long length, long findex, int matindex){ChunkHeader h;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case MAT_MAPNAME:// Read the name of texture in the Diffuse Color mapMapNameChunkProcessor(h.len, ftell(bin3ds), matindex);break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::MapNameChunkProcessor(long length, long findex, int matindex){char name[80];// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Read the name of the texturefor (int i = 0; i < 80; i++){name = fgetc(bin3ds);if (name == 0){name = 0;break;}}// Load the name and indicate that the material has a texturechar fullname[80];sprintf(fullname, "%s%s", path, name);Materials[matindex].tex.Load(fullname);Materials[matindex].textured = true;// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::ObjectChunkProcessor(long length, long findex, int objindex){ChunkHeader h;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Load the object's namefor (int i = 0; i < 80; i++){Objects[objindex].name = fgetc(bin3ds);if (Objects[objindex].name == 0){Objects[objindex].name = 0;break;}}while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case TRIG_MESH:// Process the triangles of the objectTriangularMeshChunkProcessor(h.len, ftell(bin3ds), objindex);break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::TriangularMeshChunkProcessor(long length, long findex, int objindex){ChunkHeader h;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case VERT_LIST:// Load the vertices of the onjectVertexListChunkProcessor(h.len, ftell(bin3ds), objindex);break;case LOCAL_COORDS://LocalCoordinatesChunkProcessor(h.len, ftell(bin3ds));break;case TEX_VERTS:// Load the texture coordinates for the verticesTexCoordsChunkProcessor(h.len, ftell(bin3ds), objindex);Objects[objindex].textured = true;break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// After we have loaded the vertices we can load the facesfseek(bin3ds, findex, SEEK_SET);while (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case FACE_DESC:// Load the faces of the objectFacesDescriptionChunkProcessor(h.len, ftell(bin3ds), objindex);break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::VertexListChunkProcessor(long length, long findex, int objindex){unsigned short numVerts;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Read the number of vertices of the objectfread(&numVerts,sizeof(numVerts),1,bin3ds);// Allocate arrays for the vertices and normalsObjects[objindex].Vertexes = new GLfloat[numVerts * 3];Objects[objindex].Normals = new GLfloat[numVerts * 3];// Assign the number of vertices for future useObjects[objindex].numVerts = numVerts;// Zero out the normals arrayfor (int j = 0; j < numVerts * 3; j++)Objects[objindex].Normals[j] = 0.0f;// Read the vertices, switching the y and z coordinates and changing the sign of the z coordinatefor (int i = 0; i < numVerts * 3; i+=3){fread(&Objects[objindex].Vertexes,sizeof(GLfloat),1,bin3ds);fread(&Objects[objindex].Vertexes[i+2],sizeof(GLfloat),1,bin3ds);fread(&Objects[objindex].Vertexes[i+1],sizeof(GLfloat),1,bin3ds);// Change the sign of the z coordinateObjects[objindex].Vertexes[i+2] = -Objects[objindex].Vertexes[i+2];}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::TexCoordsChunkProcessor(long length, long findex, int objindex){// The number of texture coordinatesunsigned short numCoords;// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Read the number of coordinatesfread(&numCoords,sizeof(numCoords),1,bin3ds);// Allocate an array to hold the texture coordinatesObjects[objindex].TexCoords = new GLfloat[numCoords * 2];// Set the number of texture coordsObjects[objindex].numTexCoords = numCoords;// Read teh texture coordiantes into the arrayfor (int i = 0; i < numCoords * 2; i+=2){fread(&Objects[objindex].TexCoords,sizeof(GLfloat),1,bin3ds);fread(&Objects[objindex].TexCoords[i+1],sizeof(GLfloat),1,bin3ds);}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::FacesDescriptionChunkProcessor(long length, long findex, int objindex){ChunkHeader h;unsigned short numFaces;// The number of faces in the objectunsigned short vertA;// The first vertex of the faceunsigned short vertB;// The second vertex of the faceunsigned short vertC;// The third vertex of the faceunsigned short flags;// The winding order flagslong subs;// Holds our place in the fileint numMatFaces = 0;// The number of different materials// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Read the number of facesfread(&numFaces,sizeof(numFaces),1,bin3ds);// Allocate an array to hold the facesObjects[objindex].Faces = new GLushort[numFaces * 3];// Store the number of facesObjects[objindex].numFaces = numFaces * 3;// Read the faces into the arrayfor (int i = 0; i < numFaces * 3; i+=3){// Read the vertices of the facefread(&vertA,sizeof(vertA),1,bin3ds);fread(&vertB,sizeof(vertB),1,bin3ds);fread(&vertC,sizeof(vertC),1,bin3ds);fread(&flags,sizeof(flags),1,bin3ds);// Place them in the arrayObjects[objindex].Faces   = vertA;Objects[objindex].Faces[i+1] = vertB;Objects[objindex].Faces[i+2] = vertC;// Calculate the face's normalVector n;Vertex v1;Vertex v2;Vertex v3;v1.x = Objects[objindex].Vertexes[vertA*3];v1.y = Objects[objindex].Vertexes[vertA*3+1];v1.z = Objects[objindex].Vertexes[vertA*3+2];v2.x = Objects[objindex].Vertexes[vertB*3];v2.y = Objects[objindex].Vertexes[vertB*3+1];v2.z = Objects[objindex].Vertexes[vertB*3+2];v3.x = Objects[objindex].Vertexes[vertC*3];v3.y = Objects[objindex].Vertexes[vertC*3+1];v3.z = Objects[objindex].Vertexes[vertC*3+2];// calculate the normalfloat u[3], v[3];// V2 - V3;u[0] = v2.x - v3.x;u[1] = v2.y - v3.y;u[2] = v2.z - v3.z;// V2 - V1;v[0] = v2.x - v1.x;v[1] = v2.y - v1.y;v[2] = v2.z - v1.z;n.x = (u[1]*v[2] - u[2]*v[1]);n.y = (u[2]*v[0] - u[0]*v[2]);n.z = (u[0]*v[1] - u[1]*v[0]);// Add this normal to its verts' normalsObjects[objindex].Normals[vertA*3]   += n.x;Objects[objindex].Normals[vertA*3+1] += n.y;Objects[objindex].Normals[vertA*3+2] += n.z;Objects[objindex].Normals[vertB*3]   += n.x;Objects[objindex].Normals[vertB*3+1] += n.y;Objects[objindex].Normals[vertB*3+2] += n.z;Objects[objindex].Normals[vertC*3]   += n.x;Objects[objindex].Normals[vertC*3+1] += n.y;Objects[objindex].Normals[vertC*3+2] += n.z;}// Store our current file positionsubs = ftell(bin3ds);// Check to see how many materials the faces are split intowhile (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case FACE_MAT://FacesMaterialsListChunkProcessor(h.len, ftell(bin3ds), objindex);numMatFaces++;break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}// Split the faces up according to their materialsif (numMatFaces > 0){// Allocate an array to hold the lists of faces divided by materialObjects[objindex].MatFaces = new MaterialFaces[numMatFaces];// Store the number of material facesObjects[objindex].numMatFaces = numMatFaces;fseek(bin3ds, subs, SEEK_SET);int j = 0;// Split the faces upwhile (ftell(bin3ds) < (findex + length - 6)){fread(&h.id,sizeof(h.id),1,bin3ds);fread(&h.len,sizeof(h.len),1,bin3ds);switch (h.id){case FACE_MAT:// Process the faces and split them upFacesMaterialsListChunkProcessor(h.len, ftell(bin3ds), objindex, j);j++;break;default:break;}fseek(bin3ds, (h.len - 6), SEEK_CUR);}}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}void Model_3DS::FacesMaterialsListChunkProcessor(long length, long findex, int objindex, int subfacesindex){char name[80];// The material's nameunsigned short numEntries;// The number of faces associated with this materialunsigned short Face;// Holds the faces as they are readint material;// An index to the Materials array for this material// move the file pointer to the beginning of the main// chunk's data findex + the size of the headerfseek(bin3ds, findex, SEEK_SET);// Read the material's namefor (int i = 0; i < 80; i++){name = fgetc(bin3ds);if (name == 0){name = 0;break;}}// Faind the material's index in the Materials arrayfor (material = 0; material < numMaterials; material++){if (strcmp(name, Materials[material].name) == 0)break;}// Store this value for later so that we can find the materialObjects[objindex].MatFaces[subfacesindex].MatIndex = material;// Read the number of faces associated with this materialfread(&numEntries,sizeof(numEntries),1,bin3ds);// Allocate an array to hold the list of faces associated with this materialObjects[objindex].MatFaces[subfacesindex].subFaces = new GLushort[numEntries * 3];// Store this number for later useObjects[objindex].MatFaces[subfacesindex].numSubFaces = numEntries * 3;// Read the faces into the arrayfor(int i = 0; i < numEntries * 3; i+=3){// read the facefread(&Face,sizeof(Face),1,bin3ds);// Add the face's vertices to the listObjects[objindex].MatFaces[subfacesindex].subFaces = Objects[objindex].Faces[Face * 3];Objects[objindex].MatFaces[subfacesindex].subFaces[i+1] = Objects[objindex].Faces[Face * 3 + 1];Objects[objindex].MatFaces[subfacesindex].subFaces[i+2] = Objects[objindex].Faces[Face * 3 + 2];}// move the file pointer back to where we got it so// that the ProcessChunk() which we interrupted will read// from the right placefseek(bin3ds, findex, SEEK_SET);}And I thought I'd better include it's header:////////////////////////////////////////////////////////////////////////// 3D Studio Model Class// by: Matthew Fairfax//// Model_3DS.h: interface for the Model_3DS class.// This is a simple class for loading and viewing// 3D Studio model files (.3ds). It supports models// with multiple objects. It also supports multiple// textures per object. It does not support the animation// for 3D Studio models b/c there are simply too many// ways for an artist to animate a 3D Studio model and// I didn't want to impose huge limitations on the artists.// However, I have imposed a limitation on how the models are// textured:// 1) Every faces must be assigned a material// 2) If you want the face to be textured assign the//    texture to the Diffuse Color map// 3) The texture must be supported by the GLTexture class//    which only supports bitmap and targa right now// 4) The texture must be located in the same directory as//    the model//// Support for non-textured faces is done by reading the color// from the material's diffuse color.//// Some models have problems loading even if you follow all of// the restrictions I have stated and I don't know why. If you// can import the 3D Studio file into Milkshape 3D // (http://www.swissquake.ch/chumbalum-soft) and then export it// to a new 3D Studio file. This seems to fix many of the problems// but there is a limit on the number of faces and vertices Milkshape 3D// can read.//// Usage:// Model_3DS m;//// m.Load("model.3ds"); // Load the model// m.Draw();// Renders the model to the screen//// // If you want to show the model's normals// m.shownormals = true;//// // If the model is not going to be lit then set the lit// // variable to false. It defaults to true.// m.lit = false;//// // You can disable the rendering of the model// m.visible = false;// // // You can move and rotate the model like this:// m.rot.x = 90.0f;// m.rot.y = 30.0f;// m.rot.z = 0.0f;//// m.pos.x = 10.0f;// m.pos.y = 0.0f;// m.pos.z = 0.0f;//// // If you want to move or rotate individual objects// m.Objects[0].rot.x = 90.0f;// m.Objects[0].rot.y = 30.0f;// m.Objects[0].rot.z = 0.0f;//// m.Objects[0].pos.x = 10.0f;// m.Objects[0].pos.y = 0.0f;// m.Objects[0].pos.z = 0.0f;////////////////////////////////////////////////////////////////////////#ifndef MODEL_3DS_H#define MODEL_3DS_H// I decided to use my GLTexture class b/c adding all of its functions// Would have greatly bloated the model class's code// Just replace this with your favorite texture class#include "GLTexture.h"#include <stdio.h>#include <iostream>class Model_3DS  {public:// A VERY simple vector struct// I could have included a complex class but I wanted the model class to stand alonestruct Vector {float x;float y;float z;};// Vertex struct to make code easier to read in placesstruct Vertex {float x;float y;float z;};// Color struct holds the diffuse color of the materialstruct Color4i {unsigned char r;unsigned char g;unsigned char b;unsigned char a;};// Holds the material info// TODO: add color support for non textured polysstruct Material {char name[80];// The material's nameGLTexture tex;// The texture (this is the only outside reference in this class)bool textured;// whether or not it is texturedColor4i color;};// Every chunk in the 3ds file starts with this structstruct ChunkHeader {unsigned short id;// The chunk's idunsigned long  len;// The lenght of the chunk};// I sort the mesh by material so that I won't have to switch textures a great dealstruct MaterialFaces {unsigned short *subFaces;// Index to our vertex array of all the faces that use this materialint numSubFaces;// The number of facesint MatIndex;// An index to our materials};// The 3ds file can be made up of several objectsstruct Object {char name[80];// The object namefloat *Vertexes;// The array of verticesfloat *Normals;// The array of the normals for the verticesfloat *TexCoords;// The array of texture coordinates for the verticesunsigned short *Faces;// The array of face indicesint numFaces;// The number of facesint numMatFaces;// The number of differnet material facesint numVerts;// The number of verticesint numTexCoords;// The number of verticesbool textured;// True: the object has texturesMaterialFaces *MatFaces;// The faces are divided by materialsVector pos;// The position to move the object toVector rot;// The angles to rotate the object};char *modelname;// The name of the modelchar *path;// The path of the modelint numObjects;// Total number of objects in the modelint numMaterials;// Total number of materials in the modelint totalVerts;// Total number of vertices in the modelint totalFaces;// Total number of faces in the modelbool shownormals;// True: show the normalsMaterial *Materials;// The array of materialsObject *Objects;// The array of objects in the modelVector pos;// The position to move the model toVector rot;// The angles to rotate the modelfloat scale;// The size you want the model scaled tobool lit;// True: the model is litbool visible;// True: the model gets renderedvoid Load(char *name);// Loads a modelvoid Draw();// Draws the modelFILE *bin3ds;// The binary 3ds fileModel_3DS();// Constructorvirtual ~Model_3DS();// Destructorprivate:void IntColorChunkProcessor(long length, long findex, int matindex);void FloatColorChunkProcessor(long length, long findex, int matindex);// Processes the Main Chunk that all the other chunks exist isvoid MainChunkProcessor(long length, long findex);// Processes the model's infovoid EditChunkProcessor(long length, long findex);// Processes the model's materialsvoid MaterialChunkProcessor(long length, long findex, int matindex);// Processes the names of the materialsvoid MaterialNameChunkProcessor(long length, long findex, int matindex);// Processes the material's diffuse colorvoid DiffuseColorChunkProcessor(long length, long findex, int matindex);// Processes the material's texture mapsvoid TextureMapChunkProcessor(long length, long findex, int matindex);// Processes the names of the textures and load the texturesvoid MapNameChunkProcessor(long length, long findex, int matindex);// Processes the model's geometryvoid ObjectChunkProcessor(long length, long findex, int objindex);// Processes the triangles of the modelvoid TriangularMeshChunkProcessor(long length, long findex, int objindex);// Processes the vertices of the model and loads themvoid VertexListChunkProcessor(long length, long findex, int objindex);// Processes the texture cordiantes of the vertices and loads themvoid TexCoordsChunkProcessor(long length, long findex, int objindex);// Processes the faces of the model and loads the facesvoid FacesDescriptionChunkProcessor(long length, long findex, int objindex);// Processes the materials of the faces and splits them up by materialvoid FacesMaterialsListChunkProcessor(long length, long findex, int objindex, int subfacesindex);// Calculates the normals of the vertices by averaging// the normals of the faces that use that vertexvoid CalculateNormals();};#endifTexture code (not written by me, I modified it to use SDL, rather than glaux)////////////////////////////////////////////////////////////////////////// OpenGL Texture Class// by: Matthew Fairfax//modified by: S.L.Jackson//// GLTexture.cpp: implementation of the GLTexture class.// This class loads a texture file and prepares it// to be used in OpenGL. The min filter is set to mipmap b/c// they look better and the performance cost on// modern video cards in negligible. I leave all of// the texture management to the application.//// Usage:// GLTexture tex;// GLTexture tex1;// GLTexture tex3;//// tex.Load("texture.bmp"); // Loads a bitmap// tex.Use();// Binds the bitmap for use// // // You can also build a texture with a single color and use it// tex3.BuildColorTexture(255, 0, 0);// Builds a solid red texture// tex3.Use(); // Binds the targa for use////////////////////////////////////////////////////////////////////////#include "GLTexture.h"#include <stdio.h>#include <string.h>#include <stdlib.h>//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////GLTexture::GLTexture(){}GLTexture::~GLTexture(){}int GLTexture::Load(char *name){SDL_Surface *TexImage = IMG_Load(name);if(!TexImage){printf ( "IMG_Load: %s\n", IMG_GetError () );return 1;}// Generate the OpenGL texture idglGenTextures(1, &texture[0]);// Bind this texture to its idglBindTexture(GL_TEXTURE_2D, texture[0]);// Use mipmapping filterglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);// Generate the mipmapsgluBuild2DMipmaps(GL_TEXTURE_2D, 3, TexImage->w, TexImage->h, GL_RGB, GL_UNSIGNED_BYTE, TexImage->pixels);SDL_FreeSurface(TexImage);return 0;}void GLTexture::Use(){glEnable(GL_TEXTURE_2D);// Enable texture mappingglBindTexture(GL_TEXTURE_2D, texture[0]);// Bind the texture as the current one}void GLTexture::BuildColorTexture(unsigned char r, unsigned char g, unsigned char b){unsigned char data[12];// a 2x2 texture at 24 bits// Store the datafor(int i = 0; i < 12; i += 3){data = r;data[i+1] = g;data[i+2] = b;}// Generate the OpenGL texture idglGenTextures(1, &texture[0]);// Bind this texture to its idglBindTexture(GL_TEXTURE_2D, texture[0]);glPixelStorei(GL_UNPACK_ALIGNMENT, 1);// Use mipmapping filterglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);// Generate the texturegluBuild2DMipmaps(GL_TEXTURE_2D, 3, 2, 2, GL_RGB, GL_UNSIGNED_BYTE, data);}And it's header:////////////////////////////////////////////////////////////////////////// OpenGL Texture Class// by: Matthew Fairfax//// GLTexture.h: interface for the GLTexture class.// This class loads a texture file and prepares it// to be used in OpenGL. It can open a bitmap or a// targa file. The min filter is set to mipmap b/c// they look better and the performance cost on// modern video cards in negligible. I leave all of// the texture management to the application. I have// included the ability to load the texture from a// Visual Studio resource. The bitmap's id must be// be surrounded by quotation marks (i.e. "Texture.bmp").// The targa files must be in a resource type of "TGA"// (including the quotes). The targa's id must be// surrounded by quotation marks (i.e. "Texture.tga").//// Usage:// GLTexture tex;// GLTexture tex1;// GLTexture tex3;//// tex.Load("texture.bmp"); // Loads a bitmap// tex.Use();// Binds the bitmap for use// // tex1.LoadFromResource("texture.tga"); // Loads a targa// tex1.Use(); // Binds the targa for use//// // You can also build a texture with a single color and use it// tex3.BuildColorTexture(255, 0, 0);// Builds a solid red texture// tex3.Use(); // Binds the targa for use////////////////////////////////////////////////////////////////////////#ifndef GLTEXTURE_H#define GLTEXTURE_H#include <windows.h>// Header File For Windows#include <gl\gl.h>// Header File For The OpenGL32 Library#include <gl\glu.h>// Header File For The GLu32 Library#include <SDL/SDL.h>#include <SDL/SDL_opengl.h>#include <SDL/SDL_image.h>class GLTexture  {public:char *texturename;// The textures nameunsigned int texture[1];// OpenGL's number for the textureint width;// Texture's widthint height;// Texture's heightvoid Use();// Binds the texture for usevoid BuildColorTexture(unsigned char r, unsigned char g, unsigned char b);// Sometimes we want a texture of uniform colorint Load(char *name);// Load the textureGLTexture();// Constructorvirtual ~GLTexture();// Destructor};#endif[Edited by - sizeak on August 4, 2009 11:32:23 AM]
  Code ????   ;Quote:Original post by sizeakExcuse the long post, I'm now looking for how to get code tags to work on here :)Use [ source lang = "language name here" ] followed by a closing [ /source ] tag (minus the extraneous spaces around the brackets) to get a scrollbox for code.   ;Quote:Original post by Captain_ThunderQuote:Original post by sizeakExcuse the long post, I'm now looking for how to get code tags to work on here :)Use [ source lang = "language name here" ] followed by a closing [ /source ] tag (minus the extraneous spaces around the brackets) to get a scrollbox for code.Thanks for the help :)  So anyone got any ideas?[Edited by - sizeak on August 1, 2009 6:41:41 PM];  Gah please help, I'm quite baffled :(   ;  You can only see part of it and translating you see other parts? Without seeing it, just from this description it's pretty clear that you are simply zoomed-in on it. Your model probably have extremely big coordinates for your frustum.You should simply try scaling before rendering.glScalef;  I said translating on the Z axis, so moving further away in a perspective matrix, I can see parts of the outline of it. When I translate it further away on the z axis, I see different parts of the outline, but the overall size remains unchanged. Its a sphere I'm testing with btw. I tried using glScalef which didnt help at all. It just changed the size of the bits of outline of the sphere that were visible at any given time. I can post screen shots to clarify my meaning if it helps.   ;  Bump   ;  Bump...   ;  First, to let you know, I am much better at DirectX, but I think the possible solution is the same.glFrustum(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1.0, 100.0)This sets up the camera frustum, with 1 being a near plane and 100 being a far plane.  So, everything outside this area will not be drawn.  From your description, this is why parts are not showing, depending on where you translate it.set the near to 0.0f and the far to 1000.0f just to see if that is the issue.Hope this turns out to be helpful.   