My textures are black... (;_;)

Started by
7 comments, last by Floating 20 years, 12 months ago
Hi, I load textures and initialize them correctly. Then I draw a lot of different non-textured things. Then when I want to draw a simple textured quad, it just appears black! My textures loading routine works fine (I took it from another of my applications where textures are working), but it seems I forgot some important setting. Could someone please tell me the important settings required to be able to display textures? (like glDisable(GL_LIGHTING), etc.) I initialize the textures like this: glBindTexture (GL_TEXTURE_2D, id); glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 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); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE); glTexImage2D (GL_TEXTURE_2D, 0, texFormat, imageWidth, imageHeight, 0, texFormat, GL_UNSIGNED_BYTE, imageData); Then I try using that texture with: glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,1); glDisable(GL_LIGHTING); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex3i(0,0,0); glTexCoord2f(1.0f,0.0f); glVertex3i(100,0,0); glTexCoord2f(1.0f,1.0f); glVertex3i(100,100,0); glTexCoord2f(0.0f,1.0f); glVertex3i(0,100,0); glEnd(); Thanks for your help
Advertisement
glColor3f(1.0f, 1.0f, 1.0f); ?
glBindTexture(GL_TEXTURE_2D,1);

change to:

glBindTexture(GL_TEXTURE_2D,id);

| - Project-X - my mega project.. getting warmer - | - adDeath - an ad blocker I made - | - email me - |
Thanks RipTorn, but id was 1 in fact.

Luke, that was it! Thanks a lot
Hi, me again!

I have a very quick question related to the previous one:

glColor3f(a,a,a) with a between 0 and 1 displays my texture from black (a=0) to normal colors (a=1).

How can I reach a similar effect but from white to normal colors?
Or how can I blend my texture with the background?
a) I don''t think you can, without changing the texture itself...
b) could you be a bit more specific about how you want it to blend against the background?
Thanks James,

What I want to do is display "icons" on a white surface. Some of them can be enabled (normal colors), others disabled (paler colors). The last case seems to be blending, no?

Can''t I apply some kind of filter?
If you are puting that icon over same background then it might be easier/faster just to make two textures and apply them as needed.
Thank you,

I found an easier way: I simply blend a white square over the texture!

This topic is closed to new replies.

Advertisement