Archived

This topic is now archived and is closed to further replies.

Muncher

texture mapping woes

Recommended Posts

Muncher    101
ARGGGGHHHH, i need expertise of the gamedev forums here! I am loading my and binding textures like this: AUX_RGBImageRec *fab; fab = auxDIBImageLoad("crap.bmp"); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,0); glTexImage2D(GL_TEXTURE_2D,0,3,fab->sizeX,fab->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,fab->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP ); which works fine, but when i have more that one texture (ie/ i load a texture and bind it as texture #1) then only last texture loaded actually works (ie/ texture #0 displays the OTHER texture)...... what gives?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
glBindTexture(GL_TEXTURE_2D,0);

''0'' is reserved, if I''m not mistaken.
Here''s how you need to setup each individual texture:



AUX_RGBImageRec *fab;
fab = auxDIBImageLoad("crap.bmp";

// Hey, what if the image wasn''t found, eh?

int textureId;
glGenTextures(1, &textureId); // Generate a new texture-id and store it in ''textureId''

glBindTexture(GL_TEXTURE_2D, textureId); // Activate it

glTexImage2D(GL_TEXTURE_2D,0,3,fab->sizeX,fab->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,fab->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP );



Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureId);
/* draw polygons here */


If it still won''t work (are you supplying any texture-coordinates with your vertices?),
try glEnable(GL_TEXTURE_2D) before you load your image.
I can''t remember wether or not it is needed.

Share this post


Link to post
Share on other sites
Muncher    101
I already am using glBindTexture(GL_TEXTURE_2D,texID) for my drawing code, the tex coords are fine... but the last texture loaded is the only one displayed, REGUARDLESS of the texture id i bind before it draw :\

Share this post


Link to post
Share on other sites
JTippetts    12950
Most likely.

Muncher: You need to generate a unique texture ID for every texture you try to bind. glGenTextures() will fill an array with unique texture IDs that are ready for use. You can setup an array with as many unsigned ints as you have textures and pass it to this function. Then, assign one texture to each ID in the array.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Share this post


Link to post
Share on other sites