Skip to main content
GameDev.net gamedev.net
🔒 Locked

quality problem

Started by mc30900 Jul 9, 2006 at 11:59 AM 15 replies 1.6k views
Original Post
mc30900
mc30900
hello all. i got a texture with a good quality but when i'm using it in my OpenGL program... its quality is way way down. take a look at a screen shot: (the up one is the texture the second is my program): http://img364.imageshack.us/my.php?image=ssbad0mh.jpg any idea what cause this and how can i make the quality better? thanks in advance
Eitsch
Eitsch
what size is your texture?

try dsiabling mipmapping and play around with filtering modes.
mc30900
mc30900
Quote:
Original post by Eitsch
what size is your texture?

try dsiabling mipmapping and play around with filtering modes.

what is mpimapping
and with what filtering modes should i play? can u list those?

thanks in advance
sth
sth
You are scaling the images a bit, which leads to interpolation. Compare the size of the upper and lower images and you'll see.
Eitsch
Eitsch
how do you upload your texture?

it may look like this
gluBuild2DMipmaps(GL_TEXTURE_2D,GL_COMPRESSED_RGB,texture.width,texture.height,texture.type,GL_UNSIGNED_BYTE,texture.imageData);orglTexImage2D(GL_TEXTURE_2D, 0, texture.bpp / 8, texture.width, texture.height, 0, texture.type, GL_UNSIGNED_BYTE, texture.imageData);


what do you use??


the filtering thing: you can tell opengl what it should do if the texel doesn't match your screen resoultion. it looks like this:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
mc30900
mc30900
Quote:
Original post by Eitsch
how do you upload your texture?

it may look like this
*** Source Snippet Removed ***

what do you use??


the filtering thing: you can tell opengl what it should do if the texel doesn't match your screen resoultion. it looks like this:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);


its the first one..
here is my code for the textures:
int LoadGLTextures() // Load Bitmaps And Convert To Textures{    int Status=FALSE;    AUX_RGBImageRec *TextureImage[2];    memset(TextureImage,0,sizeof(void *)*2);    // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit    if ((TextureImage[0]=LoadBMP("Data/a.bmp") ) &&        (TextureImage[1]=LoadBMP("Data/b.bmp"))				)    {        Status=TRUE;        glGenTextures(2, &texture[0]); // Create The Texture        for (int i=0; i<2; i++)        {                    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);            glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);                       gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX, TextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);		}    }    for (int i=0; i<2; i++)    {        if (TextureImage) // If Texture Exists        {            if (TextureImage->data) // If Texture Image Exists            {                free(TextureImage->data); // Free The Texture Image Memory            }                    free(TextureImage); // Free The Image Structure        }    }    return Status;} 


should i play here with somthing?

and if i do with what parameters to play?
thanks in advance
Eitsch
Eitsch

change:

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX, TextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);

and:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

to:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);

and:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
mc30900
mc30900
now i see everything white.
i think there is a problem with showing the texture now.
there are few lines in my code that are connected to the Texture subject
so if it helps, i put them here so you'll have a look at them.

In drawing function:
glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, texture[1]);


in initaliztion function:
glClearDepth(1.0f); // Depth Buffer SetupglShadeModel(GL_SMOOTH); // Enable Smooth ShadingglEnable(GL_DEPTH_TEST); // Enables Depth TestingglDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To DoglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations


any idea what i need to change to get it working?
thanks in advance

[Edited by - mc30900 on July 9, 2006 4:40:29 PM]
mc30900
mc30900
nobody knows?
Kalidor
Kalidor
It seems to me like your textures have dimensions that are not powers-of-two. If that's the case the quality loss was most likely due to gluBuild2DMipmaps resizing your image to power-of-two dimensions before creating the mipmap chain.
mc30900
mc30900
Quote:
Original post by Kalidor
It seems to me like your textures have dimensions that are not powers-of-two. If that's the case the quality loss was most likely due to gluBuild2DMipmaps resizing your image to power-of-two dimensions before creating the mipmap chain.


how do i resize the image to power-of-two dimensions?

and it dont really make sense.. isnt a bmp 2d image? how can it be a 3d?
Eitsch
Eitsch
take a picture program and edit the image size
mc30900
mc30900
Quote:
Original post by Eitsch
take a picture program and edit the image size


but what size should i use??

i have photoshop 8 cs.
can u explain me where i need to go and what i have to do?
thanks in advance
_the_phantom_
_the_phantom_
one where both side are a power-of-two in size...
Eitsch
Eitsch
open your image
image/imagesize and type 512x512 for example.
save it
Kalidor
Kalidor
Quote:
Original post by mc30900
how do i resize the image to power-of-two dimensions?

and it dont really make sense.. isnt a bmp 2d image? how can it be a 3d?
By power-of-two image I mean an image whose dimensions (width/height/depth - it doesn't matter whether it's 1d, 2d, or 3d.) are powers of two. A power of two is a number that satisfies the equation x=2n for some integer n, such as 256 and 512. The dimensions don't have to be equal either, as long as they are all a power of two. On modern cards this restriction is relaxed, but it is still recommended to use power-of-two sized textures. Even if your card does support non-power-of-two textures, gluBuild2DMipmaps will still resize any image passed to it.

You can resize images in any paint-type program like Photoshop. Or just create the image with proper dimensions to begin with.

EDIT: Wow, I was way too slow.
mc30900
mc30900
thanks a lot..i think it helped.
its still not as the real texture but it is much better

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.