mipmap high-res photos makes solid white textures

Started by
7 comments, last by V-man 16 years, 10 months ago
I am trying to mipmap arbitrary photos (for a slideshow). When they are high resolution, then OpenGL just draws a solid white area instead of the bitmap. One photo works at 509x767 but fails at 510x768. However, I'd really like to use textures equal to the size of the window. I am an newbie to 3D graphics. My system is Linux 2.6, Mesa 3D 6.4.2. The screen is 1280x800 and the window is 900x700.
Advertisement
we are going to need to see some code here, are you using glBuild2DMipmaps()? or glTexImage2D()? Do you have GL2.0 card? Need more info.
I'm glad to give more info, but I'm too new to know what's relevant. :)

Loading texture from JPEG:
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );        gl_rc = gluBuild2DMipmaps( GL_TEXTURE_2D,                                cinfo.num_components,                                cinfo.image_width,                                cinfo.image_height,                                GL_RGB,                                GL_UNSIGNED_BYTE,                                raw );


Display texture:
                glEnable(GL_TEXTURE_2D);                glBindTexture(GL_TEXTURE_2D, tex);                glPushMatrix();                glScalef(1, -1, 1);                glBegin(GL_QUADS);                glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f);                glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f);                glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);                glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);                glEnd();                glPopMatrix();                glDisable (GL_TEXTURE_2D);


Video card from lspci is below.
01:00.0 VGA compatible controller: VIA Technologies, Inc. VT8378 [S3 UniChrome] Integrated Video (rev 01)


Here's output from glxinfo:
OpenGL vendor string: VIA TechnologyOpenGL renderer string: Mesa DRI UniChrome (KM400) 20050526 x86/MMX+/3DNow!+/SSEOpenGL version string: 1.2 Mesa 6.4.2
Resizing to 512x512 allows me to see all my photos (instead of the white spaces), but as I mentioned, I do prefer to have full resolution.


      gl_rc = gluScaleImage(GL_RGB,                                cinfo.image_width,                                cinfo.image_height,                        GL_UNSIGNED_BYTE,                        raw,                        512,                        512,                        GL_UNSIGNED_BYTE,                        raw2);


Unfortunately, I don't know (1) what the limit is, (2) when an error occurs, or (3) what exactly is the problem.

When using the original sizes (without the above gluScaleImage), I see this on the console
Mesa: User error: GL_INVALID_VALUE in glTexImage2D(level=0, width=1024, height=1024, depth=1)Mesa: User error: GL_INVALID_VALUE in glTexImage2D(level=10, width=1, height=1, depth=1)
glubuildmipmaps calls
gluScaleImage first to scale the images to power of 2 (before it creates the mipmaps so youre not seeing the fullimage at all)

i dont think your cared supports nonpower of 2 sized images thus the only way is to create a 512x1024 sized image and just use the bootomleft 509x767 or it
Quote:i dont think your cared supports nonpower of 2 sized images thus the only way is to create a 512x1024 sized image and just use the bootomleft 509x767 or it


If that were true, why can I use 509x767?
Quote:Original post by ahz
Quote:i dont think your cared supports nonpower of 2 sized images thus the only way is to create a 512x1024 sized image and just use the bootomleft 509x767 or it


If that were true, why can I use 509x767?
gluBuild2DMipmaps resizes the passed in image data to the nearest power-of-two dimensions before creating the texture and mipmap levels. If a dimension is exactly between two powers of two (ie: 768) it scales up. So with a 509x767 image you get a 512x512 texture and with a 510x768 image you get a 512x1024 texture. My guess is that the max texture resolution on your card is 512x512 (you can check this using glGet* with GL_MAX_TEXTURE_SIZE).
Kalidor, that's the answer I was looking for. You were right: glGetIntegerv( GL_MAX_TEXTURE_SIZE, &tex_size) does return 512. (I guess I should increase VRAM.) Now I know exactly what to do. Thanks. :)

BTW, I found that's just an estimate, and here is a more accurate (but more complex) method:

http://www.opengl.org/resources/faq/technical/texture.htm
21.130 What's the maximum size texture map my device will render hardware accelerated?
"http://www.opengl.org/resources/faq/technical/texture.htm
21.130 What's the maximum size texture map my device will render hardware accelerated?"

I think you can ignore that.
Cards like ATI and NV will report 4096 and that is a very exact number.
BTW, that is the texture width and height, for 1D and 2D textures.

Your S3 card is too old and suggest getting something from ATI or NV, preferably NV since they have better Linux drivers.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement