Jump to content
  • Advertisement
Sign in to follow this  
Tiresias

OpenGL problem with 2D zoom

This topic is 3337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Advertisement
If you're using texture clamping (GL_CLAMP), try using GL_CLAMP_TO_EDGE instead. This will prevent the border color from showing up.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!