🔒 Locked
quality problem
Advertisement
Original Post
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
how do you upload your texture?
it may look like this
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);
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);
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
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);
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:
in initaliztion function:
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]
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 Calculationsany idea what i need to change to get it working?
thanks in advance
[Edited by - mc30900 on July 9, 2006 4:40:29 PM]
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.
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?
one where both side are a power-of-two in size...
Quote: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.
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?
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement