Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Stephen Chou

how to get the right position using glRasterPos when changing MatrixMode?

This topic is 5200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am not good at English..... i use "ReadPixels" reading from buffer,and want to show it in the screen by pixel,i think glOrtho work better,so i change the matrixmodel from gluPerspective to glOrtho ,but problem comes, it doesn''t come out where i want! when using gluPerspective how to measure the coordinate by pixel? part code below: DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0,0,-50); glCallList(box); glPushMatrix(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glOrtho(0,640,0,480,-10,10); glLoadIdentity(); glRasterPos2i(50,50); glDrawPixels(256,256,GL_RGB,GL_UNSIGNED_BYTE,checkImage); glReadPixels(pos[0],pos[1],256,256,GL_RGB,GL_FLOAT,ixel1); glRasterPos2i(150,150); glDrawPixels(256,256,GL_RGB,GL_FLOAT,pixel1); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }

Share this post


Link to post
Share on other sites
Advertisement
Working with pixel coordinates in perspective projection is not that easy. If you really want to do it, I suggest you look at gluProject/gluUnProject.

However, if all you need is to set the raster position in window coordinates, then use glWindowPos instead. Requires either OpenGL 1.4 or the ARB_window_pos extension. Read more about it here.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!