[OpenGL 2D] Match opengl world coord. to screen coord.

Quickly share your Android Code Snippets here...

[OpenGL 2D] Match opengl world coord. to screen coord.

Postby Skywhy » Sat Nov 07, 2009 1:00 pm

Does what it says on the tin.

Code: Select all
gl.glMatrixMode(GL10.GL_PROJECTION);
GLU.gluOrtho2D(gl, 0, _screenWidth, _screenHeight, 0);


Set the projection to match your screen width and height and voila, the origin of the world coordinates in OpenGL is now in the top left hand corner and the world coordinates are matched to you screen coordinates.

Enjoy.
Skywhy
Developer
Developer
 
Posts: 35
Joined: Tue Oct 20, 2009 7:55 pm

Top

Postby qlimax » Wed Dec 30, 2009 7:50 pm

thank you :!:

very usefull !
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby Skywhy » Wed Dec 30, 2009 11:06 pm

You are most welcome, I am happy to help if I can.
Skywhy
Developer
Developer
 
Posts: 35
Joined: Tue Oct 20, 2009 7:55 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 7 guests