Results 1 to 9 of 9

Thread: texture shows up on voodoo3 but not geforce4 (code)

  1. #1
    Guest

    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?

    Code :
     
    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);

  2. #2
    Member Contributor
    Join Date
    Apr 2002
    Location
    Spain
    Posts
    63

    Re: texture shows up on voodoo3 but not geforce4 (code)

    Code :
     
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 
    	256, 0, GL_RGB, GL_UNSIGNED_BYTE, interfaceBMP);
    <HR></BLOCKQUOTE>

    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:

    Code :
    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).]

  3. #3
    Guest

    Re: texture shows up on voodoo3 but not geforce4 (code)

    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.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: texture shows up on voodoo3 but not geforce4 (code)

    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?

  5. #5
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: texture shows up on voodoo3 but not geforce4 (code)

    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).]

  6. #6
    Guest

    Re: texture shows up on voodoo3 but not geforce4 (code)

    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.

    Code :
    #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][x][2] = fgetc( fin );
    			interfaceBMP[y][x][1] = fgetc( fin );
    			interfaceBMP[y][x][0] = fgetc( fin );
    		}
    	}
    	fclose( fin );
    }
     
    void initTextures(void) {
    	importInterfaceBMP("textures/interface.bmp");
    	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
     
    	glGenTextures(1, &amp;menus);
    	glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 
    		256, 0, GL_RGB, GL_UNSIGNED_BYTE, interfaceBMP);
    }
     
    int main(int argc, char **argv)
    {
    	glutInit(&amp;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);
    }

  7. #7
    Guest

    Re: texture shows up on voodoo3 but not geforce4 (code)

    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.

  8. #8
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: texture shows up on voodoo3 but not geforce4 (code)

    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.

  9. #9
    Guest

    Re: texture shows up on voodoo3 but not geforce4 (code)

    I'm seeing textures now, thanks!

Similar Threads

  1. Nothing shows while trying to render a texture
    By DonPedross in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-11-2018, 08:44 PM
  2. Blending a Texture shows white.
    By t@nt@n in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-08-2013, 08:46 PM
  3. Texture not animating only shows black model
    By Johnathon332 in forum OpenGL: GLSL
    Replies: 1
    Last Post: 04-28-2013, 09:26 AM
  4. My texture shows up offset & with a seam???????
    By Savalia in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-07-2010, 03:43 PM
  5. Texture in GL3.2 only shows up black - help please
    By Gibbon_99 in forum OpenGL: GLSL
    Replies: 14
    Last Post: 10-12-2009, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean