   World in a text file
  Hi, I''m just playing with lesson 10, and I''m trying to combine it with lesson 23, where I can load multiple textures and I was wondernig if I could do commands, like the glBindTexture() command inside the Text file... I want to be able to load the walls to have different textures then the floors etc. etc.Shouldn''t be that hard, but I can''t just implement the code right inbetween the text doc... 
  instead of doing commands in the text file, why don't you just load a list of textures? check how many there are on the list and you use a for loop to put the loaded textures into an array that fits every single texture !   [edited by - JazzD on January 22, 2004 3:29:02 PM];  This is my World.txt, with a number (0,1,2) defining texture:NUMPOLLIES 36// Floor 11-3.0  0.0 -3.0 0.0 6.0-3.0  0.0  3.0 0.0 0.0 3.0  0.0  3.0 6.0 0.01-3.0  0.0 -3.0 0.0 6.0 3.0  0.0 -3.0 6.0 6.0 3.0  0.0  3.0 6.0 0.0// Ceiling 12-3.0  1.0 -3.0 0.0 6.0-3.0  1.0  3.0 0.0 0.0 3.0  1.0  3.0 6.0 0.02-3.0  1.0 -3.0 0.0 6.0 3.0  1.0 -3.0 6.0 6.0 3.0  1.0  3.0 6.0 0.0// A10-2.0  1.0  -2.0 0.0 1.0-2.0  0.0  -2.0 0.0 0.0-0.5  0.0  -2.0 1.5 0.00-2.0  1.0  -2.0 0.0 1.0-0.5  1.0  -2.0 1.5 1.0-0.5  0.0  -2.0 1.5 0.0// A20 2.0  1.0  -2.0 2.0 1.0 2.0  0.0  -2.0 2.0 0.0 0.5  0.0  -2.0 0.5 0.00 2.0  1.0  -2.0 2.0 1.0 0.5  1.0  -2.0 0.5 1.0 0.5  0.0  -2.0 0.5 0.0// B1A N D SO ONtypedef struct tagTRIANGLE{VERTEX vertex[3];int tex; //added tex identifier} TRIANGLE;void SetupWorld(){float x, y, z, u, v;int numtriangles;FILE *filein;char oneline[255];filein = fopen("data/world.txt", "rt&quot;// File To Load World Data Fromreadstr(filein,oneline);sscanf(oneline, "NUMPOLLIES %d\n", &numtriangles);sector1.triangle = new TRIANGLE[numtriangles];sector1.numtriangles = numtriangles;for (int loop = 0; loop < numtriangles; loop++){readstr(filein,oneline);sscanf(oneline,"%d", &sector1.triangle[loop].tex); //loading texture attributefor (int vert = 0; vert < 3; vert++){ readstr(filein,oneline); sscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v);sector1.triangle[loop].vertex[vert].x = x;sector1.triangle[loop].vertex[vert].y = y;sector1.triangle[loop].vertex[vert].z = z;sector1.triangle[loop].vertex[vert].u = u;sector1.triangle[loop].vertex[vert].v = v;}}fclose(filein);return;} ;  My basic world text files look like this: // Vertices? Colors? Normals? Textures?1 0 0 1// If there are textures, how many?3// Begin reading texture filenames (the : is to specify where it starts:grond.bmpmuur.bmpdak.bmp// How many triangles14// Triangles: Texture Number0// Vertex  Texture Coordinate-10 -10 00 0 10 -10 01 0 10  10 01 1// And so on...0 10  10 0   1 1-10  10 0   0 1-10 -10 0   0 01 -2   2  00 0  2   2  01 0  2   2  31 11  2   2  31 1 -2   2  30 1 -2   2  00 01 -2  -2  00 0  2  -2  01 0  2  -2  31 1// And a lot more trianglesThis is pretty handy for simply testing if a modelling/animation program works, easy to implement and easy to make. ;  Hrmmm... maybe I miss worded my question, like what JazzD said, I should put the traingles into an array.But, I should begin to completly understand the code.I use the same code as the Anonymous poster (NeHe''s basecode from lesson 10).From my understanding it does this:1)Defines Floats which will be used to define the location of the triangles.2)Opens and reads the text document which holds the list of textures.3) sscanf(oneline, "NUMPOLLIES %d\n", &numtriangles); <--- counts the number of triangles?4) sector1.triangle = new TRIANGLE[numtriangles];sector1.numtriangles = numtriangles; <--- makes the array which holds all of the coords for the triangles.5) for (int loop = 0; loop < numtriangles; loop++){for (int vert = 0; vert < 3; vert++){readstr(filein,oneline);sscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v);sector1.triangle[loop].vertex[vert].x = x;sector1.triangle[loop].vertex[vert].y = y;sector1.triangle[loop].vertex[vert].z = z;sector1.triangle[loop].vertex[vert].u = u;sector1.triangle[loop].vertex[vert].v = v;}}^ This goes through the text document assigning each triangle section to the array:: and displays it?6) Closes the fileI guess my question is where do I do the glBindTexture() -ing?Should I cut the loop in half so after it displays X amount of triangles I change the texture?Need guidance ;  Place the texture number before every triangle in your text file and, when you draw a triangle get the texture number (stored in an array, just like the vertices and texture coordinates) and bind the specified texture with glBindTexture (or you could first check if the specified texture isn''t binded already, this for speed reasons). ;  Ive been playing with lesson 10I am using multiple textures int LoadGLTextures() // Load Bitmaps And Convert To Textures{   int Status=FALSE; // Status Indicator   AUX_RGBImageRec *TextureImage[1];// Create Storage Space For The TextureglGenTextures(array[0].txtcount, &texture[0]);// Create Texturesfor (int loop=1; loop < 99; loop++){switch (array[0].txtused[loop]){case 0 :{break;}case 1 :// 1= used{memset(TextureImage,0,sizeof(void *)*1);   // Set The Pointer To NULL (clears memory)if (TextureImage[0]=LoadBMP(array[loop].txtfilename)){Status=TRUE;   // Set The Status To TRUE// Create Nearest Filtered Texture//glBindTexture(GL_TEXTURE_2D, texture[loop]);//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);//glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);// Create Linear Filtered Texture//   glBindTexture(GL_TEXTURE_2D, texture[loop]);//    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);// glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);// Create MipMapped TextureglBindTexture(GL_TEXTURE_2D, texture[loop]);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_NEAREST);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);}}}}   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}array is somewhere to store the textures i useIn the DrawGLScene i added graphics = sector1.triangle[loop_m].vertex[0].gfx; // select texture from world dataglBindTexture(GL_TEXTURE_2D, texture[graphics]);   // this must be outside glBegin glEndIn SetupWorld() i added for (int vert = 0; vert < 3; vert++)// This loop builds a vector list{//readstr(filein,oneline);// read a linesscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v);// get vectors and storesector1.triangle[loop].vertex[vert].x = x;sector1.triangle[loop].vertex[vert].y = y;sector1.triangle[loop].vertex[vert].z = z;sector1.triangle[loop].vertex[vert].u = u;sector1.triangle[loop].vertex[vert].v = v;sector1.triangle[loop].vertex[vert].gfx = gfx;// This is the TextureNot the easiest way but quick and simply when just playing around, i did this within a week of starting with opengl and its only 10 years since i did any C programming. I got that to work now playing with light which is proving to be abit of a pain (normals problem i think)add these to give you simply movement in the Y axis GLfloat y=0.0f;// y offset moves up and down(this ones in the DrawScene()GLfloat ytrans = y-walkbias-0.25f;// added y to give it up downif (keys[''A'']){y-= 0.04f;}if (keys[''Z'']){y+= 0.04f;}just stick them in the right placesHope this helpsJust going to climb into my flame proof suit tobe ready..;  Well, I haven't been able to do any programming lately cuz my school account was disabled :/ but I got it back like 20 minutes ago and started working on my project. I was able to do everything you said unfinished, no errors or nothing, it's just that when I try and run the program, it just stops responding... maybe I told it to do too much?EDIT: Oh, and while I'm at it, the variable, graphic, is the variable for the number for the texture I want to load from the array, right?   [edited by - Kheteris on January 29, 2004 1:46:41 PM];  Bumb I''m 99% positive that I am not missing anything, no errors, no warnings etc etc, I added the m_gfx variable everwhere I saw m_x, m_y etc etc...Why would it just stop responding? Am I telling it to do to much? ;  Post some code.  You probably have an infinite loop somewhere.Enigma 