problem with 2D zoom
Hello
i have written some code to handle zoom in a 2D game, it is working fine but i noticed that when using some floating scale value, we can see the border of the .png picture i am blitting on the screen (like a white line on the border). For ex if there is no scale (scalefactor=1.0f) its fine of course, if scalefactor=2.3333f (it means this is zoomed OUT) then i see some borders on some png, if scale=3.01 thats fine etc),
to do the zoom job i do this before blitting the png:
// rect represent the screen surface. rect.x and y =0)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(rect.x + (rect.w-rect.w*s)/2, // "s" IS THE SCALE (from 0.6f to 3.0f)
rect.x + s*rect.w + (rect.w-rect.w*s)/2,
rect.y +s*rect.h + (rect.h-rect.h*s)/2,
rect.y + (rect.h-rect.h*s)/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
...BlitPng()
It looks like opengl is messy when the scale factor s is set to some values (always the same),
please helpppppppp :)
If you're using texture clamping (GL_CLAMP), try using GL_CLAMP_TO_EDGE instead. This will prevent the border color from showing up.
Thanks a lot
the answer is not the CLAMP but at least u gave me a clue where to look,
i just changed the 2 MIN and MAP filter algo (changing from LINEAR to NEAREST) and thats it,
here is the 2 lines of code i added before doing the blit:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
cheers thanks!
the answer is not the CLAMP but at least u gave me a clue where to look,
i just changed the 2 MIN and MAP filter algo (changing from LINEAR to NEAREST) and thats it,
here is the 2 lines of code i added before doing the blit:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
cheers thanks!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement