Screen Coordinates and (0,0) Position,
Members - Reputation: 102
Posted 05 August 2012 - 03:47 PM
Members - Reputation: 2027
Posted 06 August 2012 - 12:54 PM
Follow my RTS game ICBM
Members - Reputation: 183
Posted 08 August 2012 - 03:54 PM
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.