How to ensure that a plane perfectly fills the viewport in OpenGL ES -
i'm trying create flat plane such fills viewport in opengl es application. can achieve effect creating plane , experimentally moving forwards , backwards until right effect, i'm must possible work out how far away camera should be. welcome pointers!
i need accurate because plane has texture applied it, want fill window , not clipped @ all.
thanks!
use glfrustum instead of gluperspective set perspective projection. glfrustum define projection in terms of plane want display viewport-filling. pseudocode:
aspect = win.width/win.height bt = tan( fov/2 ) lr = bt * aspect glmatrixmode(gl_projection) glloadidentity() glfrustum( -lr * zclip.near, lr * zclip.near, -bt * zclip.near, bt * zclip.near, zclip.near, zclip.far) glmatrixmode(gl_modelview) glloadidentity() vertices = [ (-lr * planedist, -bt * planedist, -planedist), ( lr * planedist, -bt * planedist, -planedist), ( lr * planedist, bt * planedist, -planedist), (-lr * planedist, bt * planedist, -planedist) ] draw_vertices(vertices)
Comments
Post a Comment