Sign in to follow this  
Alder

OpenGL 2D Camera

Recommended Posts

Alder    122
Hey, I'm trying to code a 2D camera with glTranslate... I want the camera to move right/left & zoom/unzoom. When I try the scene I draw a cube so at the begining you see only the front face normaly I should only see the front face since the camera moves right/left but wen I do so you start to see the other side of the cube because the "camera" is probably moving in a sort of big circle?? Someone can explain what's happening? Thanks

Share this post


Link to post
Share on other sites
gregrampage    177
If I understand you correctly it sounds like your program is doing what you told it to do. If you are looking straight at something and then move to the left or right you're going to be able to see the side of it.

If that's not what's going on you're going to have post code for anyone to help, I'm sure.

Share this post


Link to post
Share on other sites
Alder    122
I use perspective!

I could use Orthographic but if I do so can I still zoom unzoom?

If I can zoom with ortho do you suggest me to use it?

Thanks



Share this post


Link to post
Share on other sites
Thaumaturge    3831
I don't think that there should be any problem with creating a zoom effect under the Orthographic projection.

Note that zooming in this case would seem to correspond to either (or both, I suppose) of scaling everything from camera viewpoint or altering the viewing frame to encompass more or less.

The simplest way is, I think, therefore to simply employ a well-placed glScalef - before your rendering code but after your camera placement code, if I'm not much mistaken. You could also alter the viewport, or call glOrtho in your rendering code, making use of your zoom factor in determining the appropriate left, right top and bottom values, I imagine.

Share this post


Link to post
Share on other sites
Neon2302    122
if you prefer 2D look, ortho is the answer

when using ortho you need to specific the left/right/top/bottom coordinate

such as, left = 0, right = 800, top = 0, bottom = 600
if you want to magnify your display you can change is value to be as you want

but my suggestion is 2D graphic shouldn't be zoom. it doesn't quite make sense. I suggest you to magnify your world "glScale" or whatever.

Best Regards

Chet Chetchaiyan

Share this post


Link to post
Share on other sites
Alder    122
I'm gonna try Orthographic with scaling if I have some problem I'm gonna come back :)

Zooming can be good if you want to edit a map. You can unzoom to see the entire map or zoom to put a scenery at a specific place (talking about polymaps not tiles map)
and you can change how far you see the characters.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this