PDA

View Full Version : Texture Quality?



ncn213
11-21-2009, 05:17 AM
Hi All,
I load a bmp in my texture. When I see bmp in paint its is good, but when I see that in opengl with 100% zoom its quality is less than paint.Which setting should I do?

My MagFilter is Linear and MinFilter Is LinearMipmapNearest.

Yann LE PETITCORPS
11-21-2009, 11:59 AM
What is the original definition of your .bmp ?

If you want to enlarge a 16x16 icon into a 1024x764 (or more) this is normal that the quality cannot be as good as this ...

@+
Yannoo

ZbuffeR
11-21-2009, 04:59 PM
"its quality is less than paint" :do you mean the texture apears blurry ?

First try "trilinear" filtering :
MinFilter with LinearMipmapLinear.
If it works, maybe your 100% zoom is only 99,9% so with LinearMipmapNearest it means "use a lower res mipmap".

Extreme test :
MagFilter with Nearest and MinFilter with Nearest.

If you could post screenshots it would be much easier to help you.

ncn213
11-22-2009, 12:56 AM
Hi ZbufferR

My bmp is 1024*1024 and its a map.
when i see that in paint its text s ok, but when see in opengl
its text isn't good.
I don't tray your above solution yet.I do an say you the result.

ncn213
11-22-2009, 04:06 AM
Hi ZbufferR
I do your above solution.
I do all possible MAG and MIN filtter, but my image has still less quality than i view it in paint or MS Picture Manager.

My opengl view is -1 to 1 x, -1 to 1 y and 1 to -1 z.In glOrtho.

Yann LE PETITCORPS
11-22-2009, 04:19 AM
And what is your screen definition ?
(I don't think that this can be this, but in the case ...)

And when you reduce the size of the opengl window, it's the same thing ?

You only map the picture on a simple quad or you make a quad for each pixel ?


@+
Yannoo

ncn213
11-22-2009, 07:24 AM
Hi Yann LE PETITCORPS,

My screen is 800*600.

And yes, when I reduce the size of gl window, or create texture from half of image, result is the same.

I Only map the picture on a simple quad.

Yann LE PETITCORPS
11-22-2009, 09:40 AM
And you see a very better picture at exactely the same 800x600 definition with Paint ?

With what you load this picture into an OpenGL texture ?

Can you give me the picture at yann.lepetitcorps@free.fr please ?


@+
Yannoo

ZbuffeR
11-22-2009, 11:40 AM
1024*1024 -> 800*600 this not 100% zoom.
try with a 1024*1024 window.

ncn213
11-22-2009, 11:38 PM
Hi ZbufferR,
My problem exist on 1024*1024 window.
I don't set any gl setting and in nvidia setting,I set texture quality to high.

ZbuffeR
11-23-2009, 06:18 AM
Give more details and screenshots please.

ncn213
11-23-2009, 09:48 PM
Hi ZbufferR,
Its some of my code :
//----- Load Teature Function -----
glBindTexture(GL_TEXTURE_2D, ImageTex);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );

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

gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Width, Height, GL_BGR_EXT, GL_UNSIGNED_BYTE, Data);

glNewList(ImageList,GL_COMPILE);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, 1.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0, -1.0, 0.0);
glEnd();
glDisable(GL_TEXTURE_2D);
glEndList();
//----- Display Function -----
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, ImageTex);
glCallList(ImageList);
//----- Resize Function -----
glViewport(0,0,(GLsizei)cx,(GLsizei)cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(XLeft,XRight,YDown,YUp,1.0,-1.0);
// 4 above variable indicate 100% zoom.
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
////////////////
The result of view in opengl window is this:
http://www.4shared.com/file/158522085/8026808f/1-OpenGL.html

And when view in MS Picture Manager teh result is:
http://www.4shared.com/file/158522084/f721b019/2-MSPicMang.html

ncn213
11-23-2009, 10:43 PM
Oh sorry
link above have problem
please try this link for viewing image :
http://www.4shared.com/file/158544183/c2ace5f1/TexQuality.html

M/\dm/\n
11-29-2009, 05:17 AM
I think there is some problem with magnification/minification. Dimensions doesn't match and you get a resized/blended texture.

Try to set ortho to (0.f; 1023.f; 0.f, 1023.f), don't use mipmaps you don't need them for now. draw a quad from 0.f to 1023.f and set tex coords from 0.f to 1.f. And set window size to 1024x1024px. If it looks good backtrack 1 step at a time to find what was the problem.

Also, if your input file is not power of 2, then it's possible file loading routines are resizing it to the nearest, I think DevIL did that.

mark ds
11-29-2009, 06:10 AM
How are you creating a 1024x1024 window? If you're using CreateWindow(Ex) to set the window dimensions, then you need to look at AdjustWindowRect(Ex) -

http://msdn.microsoft.com/en-us/library/ms632667%28VS.85%29.aspx