Jump to content

  • Log In with Google      Sign In   
  • Create Account


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.

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

#1 jeff8j   Members   -  Reputation: 673

Like
0Likes
Like

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.

Firefox youtube video and audio downloader MP3 MP4 OGG WEBM

https://addons.mozilla.org/en-US/firefox/addon/simple-youtube-converter/


Sponsor:

#2 radioteeth   Prime Members   -  Reputation: 912

Like
0Likes
Like

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.



#3 jeff8j   Members   -  Reputation: 673

Like
0Likes
Like

Posted 12 May 2013 - 03:19 PM

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


Firefox youtube video and audio downloader MP3 MP4 OGG WEBM

https://addons.mozilla.org/en-US/firefox/addon/simple-youtube-converter/





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