Strange Texture Color Problems

Started by
0 comments, last by Grunhund3 21 years, 2 months ago
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]
Advertisement
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.

This topic is closed to new replies.

Advertisement