I know that if you want to display a sprite on screen (in 2D) you can use glOrtho and essentially make 1 gl unit equal to 1 pixel, so when I plot out the vertices for say a 128x128 image (on a quad), I can define the vertices as -64/64, -64-64, etc and then when I map my texture coords to that quad, the image is displayed at a 1:1 ratio.

However, lets say I wanted to not use glOrtho and wanted to have a perspective view, so I can combine 2D sprites with 3D models and whatnot? I'm at a loss on how to convert/set up the coordinates for the planes/quads I want to draw images to, in a way that will match the resolution of the image. That is, define coordinates or convert them in such a way so that when a 2D sprite is right at the near plane, that sprite is mapped as 128x128 pixels on the screen.

  • 1
    \$\begingroup\$ completely off topic: have more self confidence! \$\endgroup\$
    – Ali1S232
    Sep 21, 2011 at 23:50
  • \$\begingroup\$ (not big enough for a full answer, so I leave a comment) You can use two projections and draw your scene in two passes. Just don't erase or flood fill the back buffer between passes. \$\endgroup\$ Sep 22, 2011 at 1:01
  • 1
    \$\begingroup\$ This is easy enough to do. If it's not well answered when I get home from work, I'll do a big write up for you. \$\endgroup\$ Sep 22, 2011 at 1:16
  • \$\begingroup\$ Nathans answer actually makes sense to me and it was what I was thinking all along, I just thought perhaps there was a better way. But please by all means do a big write up for me! lol the more information the better! \$\endgroup\$
    – user6484
    Sep 22, 2011 at 1:29
  • 1
    \$\begingroup\$ @Ascension, it's a policy on SE sites to make questions more useful. The parts I removed were irrelevant to the core of your question. meta.stackexchange.com/questions/2950/… \$\endgroup\$
    – Tetrad
    Sep 22, 2011 at 5:32

1 Answer 1


You can calculate the size of the screen at the near plane by using a little trigonometry:

screen_width_in_world = 2.0 * tan(0.5 * horizontal_fov) * near_clip_distance
screen_height_in_world = 2.0 * tan(0.5 * vertical_fov) * near_clip_distance

That's the size in world coordinate units of the "window" on the near plane that represents the screen. If you multiply those by 128 / screen_width_in_pixels or 128 / screen_height_in_pixels, you'll get the appropriate world space width and height for your sprite, to make it 128x128 at the near plane (and proportionally smaller as it gets further away). This assumes the sprite is screen-facing.


You must log in to answer this question.