View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# glsl pixel 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.

2 replies to this topic

### #1jeff8j  Members

Posted 12 May 2013 - 12:35 PM

I have old opengl1/1.5 immediate mode code im trying to get updated into opengl es 2 using glsl. I have some code that creates 2d box using glVertex3i to set the location in pixels. I have a box drawing in glsl but its in the center using

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

How can I set it using pixels? Im not concerned about passing the values yet just changing the gl_Position to say put it 100px from the bottom and 100px in from the left that would be a great starting point. Thanks

I figure I might be able to (havent tried) make a box that takes up the whole screen then use the frag shader to only set the pixels I want but then it would have to run over per every pixel on screen but thats got to be inefficient I would think theres a better way?

Edited by jeff8j, 12 May 2013 - 12:41 PM.

### #2deftware  Prime Members

Posted 12 May 2013 - 02:48 PM

You need to set your projection matrix from inside your program so that 0,0 is one corner of the screen (top left, for instance) and some other values X/Y are the opposite corner (eg: resolution_x, resolution_y, or some fixed values that are independent of resolution)..

The reality is that as long as your projection matrix is unknown, you won't be setting *anything* "by pixels" even if you use glVertex3i - which is just glVertex3f, but takes integers instead of floats, but it doesn't mean that it takes coordinates in the form of pixels..

glOrtho() is the key to your success.

### #3jeff8j  Members

Posted 12 May 2013 - 03:19 PM

Thanks I think I understand but now the issue of glOrtho on opengl es 2 lol