OpenGL: texture loading changes the current color

I noticed that when I load a texture, it can change the current color of the drawing, depending on the color of the texture. For example, after execution

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, info.biWidth, info.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,bitmap); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 

all consecutive polygons drawn on the screen will have a color depending on the loaded texture image.

Is this a standard? I did not find this behavior documented.

+7
opengl textures
source share
1 answer

Yes, how it works, remember that GL is a state machine, so you left the texture binding (and possibly turned on), so when you used it, you used the first pixel (provided that you did not provide any texture coordinates) to color the primitive.

To solve this problem, turn off texturing when you don't want texturing, you can do this with

 glDisable(GL_TEXTURE_2D); 
+9
source share

All Articles