I’ve been trying to track down a problem in my app and I’ve created a test app with the same problem. If I create and bind an RGB - UNSIGNED_BYTE texture of any size other than 2x2 the texture looks great, however if the texture is 2x2 red lines appear (originally noticed on my mipmaps). I changed my original mipmap to a solid blue 2x2 with the same results. Where is the red coming from?
Test app code:
{
glViewport(0, 0, Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (((float)Width) / ((float)Height)), 1, 100000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBlendFunc(GL_ONE, GL_ZERO);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
unsigned char texture[48] = {0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255,
0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255,
0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255,
0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255};
//r g b r g b r g b r g b
glBindTexture(GL_TEXTURE_2D, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 2, 2,
0, GL_RGB, GL_UNSIGNED_BYTE, texture);
}
Paint method:
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glColor3f(0, 0, 0);
glBegin(GL_TRIANGLES);
glTexCoord2f(4, 4);
glVertex3f(10, 10, -20);
glTexCoord2f(0, 4);
glVertex3f(-10, 10, -20);
glTexCoord2f(0, 0);
glVertex3f(-10, -10, -20);
glEnd();
SwapBuffers(DeviceContext);
}
Changing the width and height on the glTexImage2D to 1x1 or 4x4 will work, but 2x2 won’t. I’m my original app the highest texture size I tested was 512x512.
I’m running a GF2Pro with 40.72 drivers…
Thanks…
John.
[This message has been edited by john_at_kbs_is (edited 02-09-2003).]