Original Post
🔒 Locked
2D Camera question
Advertisement
Instead of changing the position of every object to simulate a moving camera (which I think is what you suggested), why not just do a global transform (glTranslatef(x, y, z);) or use gluPerspective() to simulate a camera? In my experience the following form is very easy:
where x, y, and z are floats that are manipulated by GetInput().
SetupWindow();while(mainLoop) { GetInput(); clearBuffers(); glTranslatef(x, y, z); Render();}where x, y, and z are floats that are manipulated by GetInput().
hmmm, im stuck on another problem now. I'm having trouble getting the y axis to be correct when i move the camera (increase, decrease y value) using gltranslate or glulookat.
My program is using an ortho view. gluUnProject to get mouse coordinates then
mouseY = viewport[3] - objY;
Then simply a glTranslate or gluLookAt to move the scene around (same effect basically for 2d). The problem is the Y value is upside down after the camera is moved. There is no problem with the X axis it works fine. So basically when i move an object in my program after ive moved the camera's y position, the object moves the oppposite Y direction. I've tried inversing the value but it doesnt work.
Any help would be great :) sorry if its explained poorly but this problem is confusing be a fair bit as i just cant get it working.
My program is using an ortho view. gluUnProject to get mouse coordinates then
mouseY = viewport[3] - objY;
Then simply a glTranslate or gluLookAt to move the scene around (same effect basically for 2d). The problem is the Y value is upside down after the camera is moved. There is no problem with the X axis it works fine. So basically when i move an object in my program after ive moved the camera's y position, the object moves the oppposite Y direction. I've tried inversing the value but it doesnt work.
Any help would be great :) sorry if its explained poorly but this problem is confusing be a fair bit as i just cant get it working.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement