PDA

View Full Version : Texture partially missing



Ryo
12-18-2001, 01:06 AM
When I use gluBuild2DMipmaps to generate textures, sometimes created texture object has some missing parts.
It happens at random and missing image is not the same.
Can you suggest any reason?
My PC is
Pen2 350Mhz, 128MB memory with ATI Rage Pro 4MB.

Here is part of my code:

GLuint m_glId

::glGenTextures( 1, &m_glId );
::glBindTexture( GL_TEXTURE_2D, m_glId );
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

int res = gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, width, height,GL_RGBA, GL_UNSIGNED_BYTE, m_pTmpImg );

if( res != 0 )
{
AfxMessageBox( "Texture Generation Failed", MB_OK, MB_ICONSTOP );
return FALSE;
}

jide
12-18-2001, 02:39 AM
i've never had this problem, but i'd like to help you.

i've notice that you used:

int res = gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, width, height,GL_RGBA, GL_UNSIGNED_BYTE, m_pTmpImg );

maybe GL_RGBA make your texture beeing transparent on some places.

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

i don't remember what is doing GL_CLAMP, but try a GL_REPLACE

good luck

Bob
12-18-2001, 03:54 AM
i don't remember what is doing GL_CLAMP, but try a GL_REPLACE

GL_CLAMP is a wrap mode (defines how the texture behaves when using texture coordinates outside the range [0, 1]. GL_REPLACE is a texture function, that defines how the texture is combined with the other colors. Did you mean GL_REPEAT?

jide
12-18-2001, 07:18 AM
mmf

sorry, of course i meant GL_REPEAT

Ryo
12-18-2001, 02:58 PM
I thought because my VRAM is so small that texture generation is messed up when VRAM is full.
I use 48 jpg files with dimension of 500*500.

Sometimes, I get a texture like this.



----------
| missing | <- all gray
|----------|
| |
| Normal |
| |
---------- 500*500


Another time I get like this.



----------
| Normal |
|----------|
| missing | <- all gray
|----------|
| Normal |
----------


Which one becomes missing is really unpredictable.

What should I do?

Spiral Man
12-18-2001, 03:05 PM
textures have to be a power of 2. perhaps the driver is padding the textures to 512 by 512?

also, 512x512 is HUGE for a texture, espesiall 48 of them, unless you have an amazing video card, i suggest you use smaller textures...

Ryo
12-18-2001, 11:37 PM
I think gluBuild2DMipmaps function automatically scales to the power of 2.

Unfortunatelly, I do not have a control for the image size.
I agree that 500*500 is pretty big, but my clients wants to use an air photo image with the dimension of 10000*10000.
I divided it to small(?) pieces and experimenting with 3000*4000 region.

Do you think a good video board will solve this problem?

Shag
12-19-2001, 12:09 AM
It does sound like a card/driver problem. But as someone said 48 textures of this size is very large (esp. for 4Mb of VRAM). Assuming you're using 32bit colour, that's over 40Mb of texture memory. The driver should deal with this ... but ...

I assume this textures are applied to a flat plane (an ortho type effect, even in perspective mode)? If not, it may be a z-buffer issue. Not very likely though - if you clear to a grey background it may be.

And you say clients? I don't suppose you can ask someone esle to run your app then? At least that would prove the card problem.

But a possible solution would be to make a montage of all the images, and manually subdivide them to powers of 2 ... not a nice job, but it may make a difference.

Finally ... have you tried running the app with just a small subset of the total number of textures?