Texture Not Showing without GlColor3x

Started by
4 comments, last by solacedagony 15 years, 9 months ago
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 );
  glTexCoord2d
  glVertex2d
...x3 for quad...
glEnd( );
That's my usual texture binding, coloring, drawing.
Orranaim:SolacedAgonyICQ:14260031arsonicconvergen@hotmail.com
Advertisement
do you enable texturing? (glEnable(GL_TEXTURE_2D))
Quote:Original post by NDIR
do you enable texturing? (glEnable(GL_TEXTURE_2D))


Yes, I just forgot to add it to my code there.
Orranaim:SolacedAgonyICQ:14260031arsonicconvergen@hotmail.com
Are you doing any sort of blending?
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:
glTexEnv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

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]
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:
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

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 ) {		case SCENE_MAINMENU:			RenderMainMenu( );			break;				case SCENE_NEWGAME:			RenderNewGame( );			break;		case SCENE_WORLDMAP:			RenderWorldMap( );			break;	}		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.
Orranaim:SolacedAgonyICQ:14260031arsonicconvergen@hotmail.com

This topic is closed to new replies.

Advertisement