Probles with loading multiple TGAs

Started by
10 comments, last by _Z 22 years, 11 months ago
The probles is: I have a function which loads a TGA according to path given, the TGA is loaded to quad structure, which contains a GLuint var[1]...so there are multiple files, multiple quad structures. The problem is that all quads become one texture...why? The source is actually modified NeHe''s lesson10...I put it up at www.kivilinn.tartu.ee/z...Plz help me!
0x600
Advertisement
If you are using nehe''s code, my guess is that you probably have a fixed array to hold, and define texture data.
You should have a texture[n] array, not texture[0] in LoadGLTextures..
Load all the textures to this array, but not to the same fixed place.

Bruno
The problem isn''t in holding space (I suppose)...every quad holds its own texture in GLunit tex[1] (the structure is simple and looks like this:
typedef struct
{
tipp tipp[4]; //these are 4 vertices (each one x, y, z, u, v)
GLuint tex[1]; //this is the place to hold the texture
}quad;
).
The problem is like this:
Assume that we have two quads. Both of them have different textures, but both look like the second (assume its texture is red, and both are red) WHY???
The code is located at www.kivilinn.tartu.ee/z

(it is less than 100kb
0x600
The problem isn''t in holding space (I suppose)...every quad holds its own texture in GLunit tex[1] (the structure is simple and looks like this:
typedef struct
{
tipp tipp[4]; //these are 4 vertices (each one x, y, z, u, v)
GLuint tex[1]; //this is the place to hold the texture
}quad;
).
The problem is like this:
Assume that we have two quads. Both of them have different textures, but both look like the second (assume its texture is red, and both are red) WHY???
The code is located at www.kivilinn.tartu.ee/z

(it is less than 100kb
0x600
Hi

I gave a quick look at your code, and i have to say it''s a big mess

I found two bugs, first you cannot inside a glBegin() glEnd(), Bind textures.
In the SetupWorld function when you start building the display list, you have a glBegin(GL_QUADS) glEnd(), and immediatly after that, you are disabling texture usage, and also binding a texture.
Remove them from there, and place them somewhere else outside the glbegin/glend, and it should work.

hope this fixes your problem,

Bruno
I didn't check your code but I am putting up my version of the Nehe example that I modified for my Map Engine. Note, I didn't put the complete function but the part that I put should help you find your problem.

make sure that somewhere in your Init() function you have:

glEnable( GL_TEXTURE_2D );


      AUX_RGBImageRec *TextureImage[ NUM_TEXTURE ];  memset( TextureImage, 0, sizeof( void * ) * 1 );  for ( int index = 0; index < NUM_TEXTURE; index++ )  {     TextureImage[ index ] = LoadBMP( tileFileNames[ index ] );       if ( TextureImage[ index ] == NULL )     {        PostQuitMessage( 0 );        return( 0 );     }  }  // &texture[ 0 ]  glGenTextures( NUM_TEXTURE, &texture[ 0 ] ); // We are generating four textures  for ( int index = 0; index < NUM_TEXTURE; index++ )  {     glBindTexture( GL_TEXTURE_2D, texture[ index ] );	 glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR );	// Linear Filtering	 glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR );	// Linear Filtering	 glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage[ index ]->sizeX, 	 			   TextureImage[ index ]->sizeY, 0, GL_RGB, 	 			   GL_UNSIGNED_BYTE, TextureImage[ index ]->data );  }    


Now, this loads 4 textures into a GLint texture[4] array and it works fine when I blit the map to the screen so it should work for you also...

Hope it does....

NB: some of the comments my not say the correct thing as I didn't change them when I built the map engine...

"And that's the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP's Invasive Production Activation Technology!

Edited by - cyberdrek on April 25, 2001 11:07:30 AM
[Cyberdrek | ]
About mess you''re absolutely right. It really is messy.
I tried your suggestions, well that didn''t do. All four quads are still one color (texture). How can I place different textures on different objects?
0x600
CYBERDREK:
Actually I do the same, load different textures into places they belong (into different quad structs). You do it with one array. But how can I make so that different objects wear different textures, how does the texturing system actually work?

0x600
Cyberdrek:
Thanks, I got he idea (at least I hope so)
0x600
Cyberdrek:
I remade my code as you suggested...nothing...all quads wear the last loaded texture. Why, I don''t know..
0x600

This topic is closed to new replies.

Advertisement