Skip to main content
GameDev.net gamedev.net
🔒 Locked

Strange Texture Color Problems

Started by Grunhund3 Feb 2, 2003 at 5:05 PM 0 replies 250+ views
Original Post
Grunhund3
Grunhund3
I am using opengl under sdl and am experiencing strange color problems when I texture map my polygons. Basically everything looks correct the texture map is scaled properly etc, except for the color values for the pixels are a few units higher or lower then the original image. (determined from photoshop) I've checked the values in the raw pixel data also and they are the appropriate values, it is only when it is displayed it is slightly off. The texture map is 16x16 and this is in orthogonal mode. Here is the basic code:
    
glGenTextures(1, &Textures[framenum]);
glBindTexture(GL_TEXTURE_2D, Textures[framenum]);   glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); 
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, temppixels);

glColor3f(1.0f, 1.0f, 1.0f);
xleft = 100;
xright = 116;
ytop = 100;
ybottom = 116;
	
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f); glVertex2i(xleft, ytop); //top left

glTexCoord2f(0.0f,1.0f); glVertex2i(xleft, ybottom); //bottom left

glTexCoord2f(1.0f,1.0f); glVertex2i(xright, ybottom); //bottom right

glTexCoord2f(1.0f,0.0f); glVertex2i(xright, ytop); //top right

glEnd();
    
Any help is much appreciated. Thanks! Grunhund [edited by - Grunhund3 on February 2, 2003 6:09:23 PM] [edited by - Grunhund3 on February 2, 2003 6:10:28 PM]
Grunhund3
Grunhund3
I''ll answer the question in case the search button starts working at some future date.

Apparently for the glTexImage2D() internal format parameter, GL_RBGA does not default to 8 bits. Changing this to GL_RBGA8 fixed the problem.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.