Blurred textures - need it sharp

Hi,

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.

My way:
-load image (eg 50x05px)
-get its ratio
-draw a quad with same ratio (1,1)(-1,1)(-1,-1)(1,-1)
-texture it
-render it in adjustable display window e.g. 500x500
-> blurred

Any ideas?
Thanx a lot in advance

1 Like

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.

Just disable bilinear filtering :
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

True, I haven’t thought of that :smiley:

Thanks a lot again, ZbuffeR and Zenga - again, what i´ve searched. - Problem solved by disabling bilinear filtering.

Hello Again,
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
1)
pixelcolor at (0,2) to yellow:
white-white-yello-white-white

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.

  1. picer i set up with
    blue-blue-blue-blue-red
    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:
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Thought this shout enable the interpolation??
glEnable(GL_COLOR_MATERIAL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

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.

Thanx

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 :
http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml