Screen Coordinates and (0,0) Position

Started by
2 comments, last by scyfris 11 years, 8 months ago
Is there anyway I can make OpenGL ES 2.0 to accept coordinates (for Vextex for example) in int meaning the pixels instead of the default float system? Also how can I set the point (0,0) to be at the top left corner of screen instead of the default one at the exact middle of the screen (to make using the pixel coordinates system easier)?
Advertisement
glMatrixMode(GL_PROJECTION);
glOrtho/glOrtho2d()

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

All matrix operations are removed in ES2, but the idea is the same - send your own projection matrix.

As to integer positions, use glVertexAttribIPointer (note the I).

As to integer positions, use glVertexAttribIPointer (note the I).


I'm not sure I've ever heard of glVertexAttribIPointer...

Use glVertexAttribPointer with the type parameter set to GL_INT
(check out spec of glVertexAttribPointer at http://www.opengl.org/sdk/docs/man/xhtml/glVertexAttribPointer.xml)

In your GLSL shader, you would also want to use ivec instead of vec for your attribute.

You would of course need to set up your modelview and projection matrix to map model coordinates (specified in integer x, y) to the actual pixels of the screen.
If you are using C++, I would suggest looking at GLM, OpenGL Mathematics Library. It contains direct support for all matrix operations (for matrix creation) which are deprecated in newer OpenGL versions and nonexistant in OpenGL ES (including glOrtho2D which is immensely useful), and it contains generic vector/matrix operations. It's at http://glm.g-truc.net/ and can be used directly with the OpenGL ES API. You will still have to track and upload your matrix to the GLSL shaders, but GLM would at least allow you to create these matrices.

This topic is closed to new replies.

Advertisement