texture shows up on voodoo3 but not geforce4 (code)

I thought maybe this had something to do with transparencies but disabling blending and using glColor3f didn’t change a thing except remove the slight transparency. The executable went straight from the win98 voodoo3 to the winxp geforce4, what gives?

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &menus); //MENUS
glBindTexture(GL_TEXTURE_2D, menus);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256,
256, 0, GL_RGB, GL_UNSIGNED_BYTE, interfaceBMP);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, menus);
glBegin(GL_QUADS);

glColor4f(.5,.5,.5,.8);
glTexCoord2f(u1,v1); glVertex3f(x1,y1,-4);
glTexCoord2f(u2,v1); glVertex3f(x2,y1,-4);
glColor4f(1,1,1,.8);
glTexCoord2f(u2,v2); glVertex3f(x2,y2,-4);
glTexCoord2f(u1,v2); glVertex3f(x1,y2,-4);

glEnd();
glDisable(GL_TEXTURE_2D);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256,
256, 0, GL_RGB, GL_UNSIGNED_BYTE, interfaceBMP);


Doesn’t this function call lack the third parameter, “number of components of every pixel in the texture”?

The rest of the call is messed too. It should read:

glTexImage2D(GL_TEXTURE_2D, 0, 3, 256,
256, 0, GL_RGB, GL_UNSIGNED_BYTE, interfaceBMP);

[This message has been edited by Azdo (edited 02-18-2004).]

I just checked the reference manual, GL_RGB is an acceptable input in both those cases. I was assuming it was defined as 3 anyway.

Originally posted by oblique:
I just checked the reference manual, GL_RGB is an acceptable input in both those cases. I was assuming it was defined as 3 anyway.
And you’re right. Your TexImage2D call was perfectly fine.

I see you’re drawing at z=-4. Maybe there’s some clipping issue here. Try different z values.
(Voodoos do have some mad depth buffer behaviour, they sometimes simply wrap around or saturate instead of clipping).

How are your matrices set up?

If that’s all you do to specify the texture object this is not working on a correct OpenGL implementation because the default minification filter is GL_NEAREST_MIPMAP_LINEAR, you didn’t specify mipmaps, so your texture is incomplete and the texture unit is shut off.
Sounds like the Voodoo used no mipmaps.

[This message has been edited by Relic (edited 02-19-2004).]

Thanks for looking at this guys. Nothing seems to work so I just chopped out everything unnecessary so I can post the code in its entirety. This renders a quad with a blue/white gradient without any texturing on a winXP box with GeForce 4 ti 128.

#pragma comment( linker, “/subsystem:"windows" /entry:"mainCRTStartup"” )

#include <gl\glut.h>
#include <stdio.h>

#undef SCREEN_WIDTH
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600

static GLubyte interfaceBMP[256][256][3];
static GLuint menus;

void renderScene(void)
{
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, menus);
glBegin(GL_QUADS);

glColor3f(0,0,1);
glTexCoord2f(0,0); glVertex3f(-3, 3,-6);
glTexCoord2f(1,0); glVertex3f( 3, 3,-6);
glColor3f(1,1,1);
glTexCoord2f(1,1); glVertex3f( 3,-3,-6);
glTexCoord2f(0,1); glVertex3f(-3,-3,-6);

glEnd();
glDisable(GL_TEXTURE_2D);

glutSwapBuffers();
glutPostRedisplay();
}

void importInterfaceBMP( char filename )
{
FILE *fin;
fin = fopen(filename,“rb”);

int x, y;

for(x = 0; x < 54; x++) fgetc( fin );

for(y = 0; y < 256; y++) {
for(x = 0; x < 256; x++) {
interfaceBMP[y][2] = fgetc( fin );
interfaceBMP[y][1] = fgetc( fin );
interfaceBMP[y][0] = fgetc( fin );
}
}
fclose( fin );
}

void initTextures(void) {
importInterfaceBMP(“textures/interface.bmp”);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glGenTextures(1, &menus);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256,
256, 0, GL_RGB, GL_UNSIGNED_BYTE, interfaceBMP);
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glutInitWindowPosition(100,100);
glutInitWindowSize(SCREEN_WIDTH,SCREEN_HEIGHT);
glutCreateWindow(“mein window”);

glutDisplayFunc(renderScene);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glFrustum(-4,4,-3,3,4,400);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glEnable(GL_DEPTH_TEST);

initTextures();

glutMainLoop();

return(0);
}

I just realized I misread your post Relic. I had some spare time here at work but aparantly I was a little distracted. I’ll read up on mipmaps when I get home and get some proper code in there.

Just add
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
(or GL_NEAREST) in the original code after the first glBindTexture call per texture object(!) and all should work.
This state is stored with the texture object and will be correctly set everytime you call glBindTexture with that textture object id later.
If this is a menu wich is not changing size, mipmaps would be a waste.

I’m seeing textures now, thanks!