graphics - OpenGL: 2D Vertex coordinates to 2D viewing coordinates? -
i'm implementing rasterizer class project, , im stuck on method/how should convert vertex coordinates viewing pane coordinates.
i'm given list of verticies of 2d coordinates triangle, like
0 0 1 2 0 1 0 1 1
and im drawing in viewing pane (using opengl , glut) of size 400x400 pixels, example.
my question how decide in viewing pane put these verticies, assuming
1) want coordinate's centered around 0,0 @ center of screen
2) want fill of screen (lets example, screen maximum x coordinate + 1 lengths wide, etc)
3) have , of opengl's , glut's standard library functions @ disposal.
thanks!
http://www.opengl.org/sdk/docs/man/xhtml/glortho.xml
to center around 0 use symmetric left/right , bottom/top. beware near/far arbitrary chosen (in examples) -1..+1 might problem triangles @ z=1.
if care aspect ratio make sure right-left , bottom-top proportional window's width/height.
Comments
Post a Comment