View Full Version : Blurred textures - need it sharp
12-20-2008, 12:06 PM
With my c++ app you are allowed to load images as a texture of arbitrary size. The quad I want to texture is a lot bigger than the texture or is shown a lot bigger, but has same xsize/ysize ratio.
While mapping the texture to the quad, it getīs blurred, but i need the image shown really sharp.
These are no real images. Just some bitmaps holding area information represented by different colors - like a chessboard, with exact edges between different colors.
-load image (eg 50x05px)
-get its ratio
-draw a quad with same ratio (1,1)(-1,1)(-1,-1)(1,-1)
-render it in adjustable display window e.g. 500x500
Thanx a lot in advance
12-20-2008, 01:13 PM
The easiest way to avoid the blur wuld be rescalng the texture to match the display size. If the edges are clearly detectible, it won't be difficult to write a function that does it.
If your image is really like chesboard, that is, it can be subdivided in uniformly-coloured rectangles of the same size, then you can also encode the image with every texel representing such rectangle and then use a shader to reproduce the final image.
12-20-2008, 02:15 PM
Just disable bilinear filtering :
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
12-20-2008, 02:26 PM
True, I haven't thought of that :D
12-29-2008, 06:00 AM
Thanks a lot again, ZbuffeR and Zenga - again, what iīve searched. - Problem solved by disabling bilinear filtering.
01-10-2009, 04:35 AM
I found the problem as solved, but with very tiny pictures it wontīt work.
In bmp format i made a 1x5 pixel image, 24bit color depth, and 96dpi hoizintal and vetical resolution. Index 0..4 as usual I set manually the
pixelcolor at (0,2) to yellow:
My app is parsing this image befor it get loaded as texture. Each white pixel get alpha = 0.
When showing it nor any color, neither yellow is displayed.
2) picer i set up with
parse ist again
It gets blue, at one corner blurred red where it should be, BUT also on opposit side but just the edge?!
Here my init-stuff:
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Thought this shout enable the interpolation??
What can i do?? I have no clue. do you need some more Infos?
BTW: The tiny images are just for testing reason and iīm still using Qt with QtGlWidget - Iīm still checkt this out, if ther comes the interpolation. Nothing found jet.
01-10-2009, 01:01 PM
Add also this :
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
There are separate setting for enlarged and reduced textures, look up the documentation :
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.