PDA

View Full Version : How to display a vertex with large values?



myst_iori
06-08-2011, 07:42 PM
Hi,

I read the book and it said the unit of object on screen can be anything, but I'm not sure I understood it correctly. If I have a point with coordinates (7000, 7000, 7000), how can I display this point on window screen? Will it depends on our window size? i.e. the window width and height? I guess not, but I don't know how to explain it correctly.
For z coordinates, it makes sense because the depth could be any value, but for the x and y coordinates, I'm lost. The maximum of width and height on my window is 1024 x 1024. How can I fit that point in?

Thank you,

StefanG
06-09-2011, 01:07 AM
You need to read up on view transformations.

The relation between world space coordinates and screen space coordinates is determined by how you transform the vertices in your code. In classic OpenGL, this is performed by the combination of a "modelview matrix" and a "projection matrix". After these two transformation matrices are applied, followed by a perspective division, the visible range of coordinates for the viewport is [-1,1] in x and y. The mapping to screen pixels can be changed by the glViewport() function if you do not want your viewport to cover the entire window.

In modern OpenGL (3.x and 4.x), your vertex shader is supposed to do all the transformations. Vertex coordinates are sent in to the vertex shader, and in the shader code you can do anything you want to scale, rotate and transform the coordinates. The visible part of your scene will still be [-1,1] in the final transformed values of x and y.

myst_iori
06-09-2011, 06:07 PM
Thank you. I think I need to read the book again.