NO COLOR!!!
I''m writing an OpenGL program that uses resource file loading. I''ve done this successfully many times in the past, but for some reason this particular program will not draw the textures with color. I''ve included the following in the Initializer function:
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDepthFunc(GL_LEQUAL);
glShadeModel (GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth (1.0f);
glEnable(GL_TEXTURE_2D);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_ONE, GL_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_SRC_ALPHA);
LoadGLTextures();
BuildFont();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
return true;
The texture is being drawn in this manner:
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(3.0f, 4.0f, -10.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-3.0f, 4.0f, -10.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-3.0f, -2.0f, -10.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(3.0f, -2.0f, -10.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
I''ve no idea why there is no color. Anybody have any ideas or perhaps experienced this problem before?
February 03, 2004 03:45 PM
"texture[1]"
You want the second texture? Should it be texture[0] for the first texture?
You want the second texture? Should it be texture[0] for the first texture?
Well I suspect if you check glGetError() you''ll find it returning a nice GL_INVALID_ENUM stemming from:
assuming that wasn''t a typo when you posted.
What do you mean by ''not draw the textures with color''? Is it just a white quad (usually indicative of non-power-of-two sized texture or loading texture before obtaining an OGL context). Does it not show up at all (outside of frustrum or wrong winding)?
Enigma
glColorMaterial(GL_ONE, GL_SRC_ALPHA);
assuming that wasn''t a typo when you posted.
What do you mean by ''not draw the textures with color''? Is it just a white quad (usually indicative of non-power-of-two sized texture or loading texture before obtaining an OGL context). Does it not show up at all (outside of frustrum or wrong winding)?
Enigma
I do want the second texture. There''s a texture being drawn, and it is the correct texture, but for some reason it appears to be being drawn in grayscale. And what typo? If there''s something wrong with my glColorMaterial, please tell me.
glColorMaterial(GL_ONE, GL_SRC_ALPHA);
Try commenting(removing) that line and see if it works then.
What result are you aiming for with that line?
Try commenting(removing) that line and see if it works then.
What result are you aiming for with that line?
Enigma hit it on the nose. Check out the documentation for glColorMaterial. GL_ONE and GL_SRC_ALPHA are not values one would use there.
"Sneftel is correct, if rather vulgar." --Flarelocke
"Sneftel is correct, if rather vulgar." --Flarelocke
Commenting it out isn''t the answer. You have to call it with the proper values, and at the proper time.
"Sneftel is correct, if rather vulgar." --Flarelocke
"Sneftel is correct, if rather vulgar." --Flarelocke
I''ve tried calling it with GL_FRONT_AND_BACK and GL_AMBIENT_AND_DIFFUSE, and it still doesn''t work. I''ve got no idea what''s going on.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement