Jump to content

  • Log In with Google      Sign In   
  • Create Account


Screen Coordinates and (0,0) Position


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 nathanpc   Members   -  Reputation: 102

Like
0Likes
Like

Posted 05 August 2012 - 03:47 PM

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)?

Sponsor:

#2 dpadam450   Members   -  Reputation: 856

Like
0Likes
Like

Posted 06 August 2012 - 12:54 PM

glMatrixMode(GL_PROJECTION);
glOrtho/glOrtho2d()

#3 wolfscaptain   Members   -  Reputation: 200

Like
0Likes
Like

Posted 07 August 2012 - 03:33 PM

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).

#4 scyfris   Members   -  Reputation: 168

Like
0Likes
Like

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS