Advertisement Jump to content
Sign in to follow this  

Texture Not Showing without GlColor3x

This topic is 3834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having an issue with textures showing up. I have to include a glColor3f( 1.0f, 1.0f, 1.0f ); before the use of a textured quad or it'll show as a blank, black box. Is this due to not having any lighting or am I not doing something else correctly?
glBindTexture( GL_TEXTURE_2D, tex );
glColor3f( 1.0f, 1.0f, 1.0f );
glBegin( GL_QUADS );
...x3 for quad...
glEnd( );
That's my usual texture binding, coloring, drawing.

Share this post

Link to post
Share on other sites
If you're not using lighting (that's what "not having any lighting" means, I assume), then the following shouldn't make a difference, but try it anyway:

Otherwise, see what the color is before calling glColor and drawing the quad, right after binding the texture:
GLfloat current_color[4];
glGetFloatv(GL_CURRENT_COLOR, current_color);
// examine current_color

If current_color is black, then everything's working as it should, and you've somehow un-set the default color (1, 1, 1, 1). In this case, search through your code to see where this happens. If it reports white before setting it, not setting it doesn't work, and setting it does, then something's quite strange. In this case, whittle the problem down to the smallest test case you can and post everything relevant.

[Edit: The obvious solution is to include that glColor3f(1.0f, 1.0f, 1.0f), if you've set the color elsewhere it's probably for a reason and you'll need to reset it here. There's really no problem if you have set different colors, you just need to remember to set the color for everything; since OpenGL works as a state machine, a color set somewhere is going to stick around until you set it to something else.]

[Edited by - jouley on July 21, 2008 1:24:55 PM]

Share this post

Link to post
Share on other sites
I am doing some blending, but I am enabling blending/disabling depth testing in sections and vice versa only around the sections that the blending is occurring.

The glTexEnvi function totally screws up my blended textures, giving them a white background (including TrueType fonts). The color is indeed black. The thing that gets me is that I set the color white multiple times and after I leave those functions, it goes black again... And I can't find anywhere in my main loops where I am using a glcolorxx function call

Will a call to:

reset the color or just the information in the screen buffers?

My init function looks like this:
	glClearColor (0.0f, 0.0f, 0.0f, 1.0f);						// Black Background
glClearDepth (1.0f); // Depth Buffer Setup
glDepthFunc (GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
glEnable (GL_DEPTH_TEST); // Enable Depth Testing
glShadeModel (GL_SMOOTH); // Select Smooth Shading
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most Accurate

And my main loop:
void Draw( )
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Clear Screen And Depth Buffer
glLoadIdentity (); // Reset The Modelview Matrix
glColor3f( 1.0f, 1.0f, 1.0f );
glTranslatef( 0.0f, 0.0f, -5.0f );

// Choose rendering based on scene state
switch( g_scene ) {
RenderMainMenu( );

RenderNewGame( );

RenderWorldMap( );

glFlush (); // Flush The GL Rendering Pipeline

I really appreciate the comments thus far. I'm not seeing anything though, unfortunately. My temporary fix is putting glColor3f( 1.0f, 1.0f, 1.0f ); in the beginning of the main loop. I'll keep looking though.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!