c++ - Draw in non-normalised coordinates - glFrustum -
on using glfrustum,
glmatrixmode(gl_projection); glloadidentity(); glfrustum(-1, 1, -1, 1, 0.1, 1000.0); glloadmatrxi(gl_modelview); glbegin(gl_quads); //a room's left wall glvertex3f(-1.0, 1.0, 0.0); glvertex3f(-1.0, 1.0, -0.4); glvertex3f(-1.0, -1.0, -0.4); glvertex3f(-1.0, -1.0, 0.0); glend(); all drawings happen in -1, 1 (notice above snippet //a room's left wall) i.e.
x- axis: -1 becomes left, 1 becomes right origin in centre.
y-axis: 1 becomes top , -1 becomes right origin in center
does glfrustum automatically change coordinates [-1,1]?
normally, draw cube specifying screen coordinates follows:
eg: ofbox(512,384,0,10) gives me box in center of screen [window width: 1024, window height: 768]
what if want keep drawing draw in pixel coordinates , don't want make things complex myself trying convert pixel coordinates drawing normalised coordinates if use glfrustum?
i think you're still having hard time imagining frustum is, , how relates projection. spoken frustum pyramid tip cut off @ distance:

if used opengl projection matrix bounds of frustum define volume in view space coordinates (i.e. after modelview transformation) turned cube of extents {-1, 1}²×{0, 1} projection transformation , homogenous divide.
the extents of near plane define extents in view space coordinates – world space view point being placed @ (0,0,0) – mapped (i.e. "stretched" and/or "pinched") extents of rendering window defined glviewport.
in short words: use glviewport define pixel coordinates in window things should go , glfrustum sort of "cut" slice out of view space (which world space moved in such way camera @ (0,0,0)).
Comments
Post a Comment