Sign in to follow this  
ahz

OpenGL mipmap high-res photos makes solid white textures

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 Technology
OpenGL renderer string: Mesa DRI UniChrome (KM400) 20050526 x86/MMX+/3DNow!+/SSE
OpenGL version string: 1.2 Mesa 6.4.2

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
"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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this