Sign in to follow this  
SnowMoo

Game Viewing Problems

Recommended Posts

Hi, I am currently developing a 2D game using OpenGL. This is my first attempt to program a 2D game but currently, I setted up the framework but there is some problems with the views.
void Resize( int width, int height )
{
	glViewport ( 0, 0, width, height );
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho( 0.0f, width, 0.0f, height, -1.0f, 1.0f );
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}


I used this code to set up a 2D view. However, when I have something set initially in the position of (50,0). When the game runs, the view will be shifted to the left by 50 units.. Can anyone help me solve this problem?? Thanks. [Edited by - SnowMoo on August 19, 2008 10:40:31 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by SnowMoo
Hi,

I am currently developing a 2D game using OpenGL. This is my first attempt to program a 2D game but currently, I setted up the framework but there is some problems with the views.

*** Source Snippet Removed ***


I used this code to set up a 2D view. However, when I have something set initially in the position of (50,0). When the game runs, the view will be shifted to the left by 50 units.. Can anyone help me solve this problem?? Thanks.
You'll probably need to post some more code (specifically, any code where you set up or modify the 'modelview' matrix).

Keep in mind though that in some cases at least, applying a translation of (50,0) will have the implied effect of positioning the camera at (-50,0), which sounds a bit like what you're describing.

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