Original Post
Ok, so I'm new to the OpenGL world and I've ran into a problem to which I can't find a solution online. I'm drawing a quad with alpha (non-textured) and then I'm drawing an other quad, opaque and textured. I have the alpha value stored in a float variable and it's used in drawing the first quad, the strange thing is that, as the alpha of the first quad goes up and down (It's regulated by the mouse wheel, BTW) so does the texture's alpha transparency, the alpha is being applied to both! Here's what I think is the relevant code:
I did find a fix which is to place a glColor4f(1.0f, 1.0f, 1.0f, 1.0f); call between the two glBegin()/glEnd() blocks. It feels like the glColor4f() stores the color value even after glEnd(), is that supposed to be that way? Is there any other solution?
... glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(xmov, ymov, 0.0f); glRotatef(xrot, 1.0f, 0.0f, 0.0f); glRotatef(yrot, 0.0f, 1.0f, 0.0f); glRotatef(zrot, 0.0f, 0.0f, 1.0f); glBegin(GL_QUADS); glColor4f(1.0f, 1.0f, 1.0f, alpha); glVertex2i(0, 0); glColor4f(1.0f, 1.0f, 1.0f, alpha); glVertex2i(100, 0); glColor4f(1.0f, 1.0f, 1.0f, alpha); glVertex2i(100, 100); glColor4f(1.0f, 1.0f, 1.0f, alpha); glVertex2i(0, 100); glEnd(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, MyTexture.Handle); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex2i(0, 0); glTexCoord2i(1, 0); glVertex2i(MyTexture.Width, 0); glTexCoord2i(1, 1); glVertex2i(MyTexture.Width, MyTexture.Height); glTexCoord2i(0, 1); glVertex2i(0, MyTexture.Height); glEnd(); glDisable(GL_TEXTURE_2D); SDL_GL_SwapBuffers();}I did find a fix which is to place a glColor4f(1.0f, 1.0f, 1.0f, 1.0f); call between the two glBegin()/glEnd() blocks. It feels like the glColor4f() stores the color value even after glEnd(), is that supposed to be that way? Is there any other solution?