I have read that you can define your OpenGL unit by using
As far as I understood if you use something like
glViewport(0,0,600,600) then 1 OpenGL unit = 600 pixels. Now my problem is what happens if the 2 sizes aren't equal? How do you calculate your OpenGL unit?
glViewport actually defines the size of your window, so
By default opengl's coordinate system sees
Be sure to note that screen coordinates are not opengl coordinates
Try this tutorial's lesson 2 & 3 on setting up the viewport correctly.
|show 2 more comments|
glViewport is just a transformation; see here for an explanation of where it fits into the pipeline and how it's applied. It may be helpful to think of it as defining an area of the window to draw to, but you should also understand that in reality it's something else.
Regarding "units", OpenGL does not define any "units" at all at any stage in it's pipeline, nor does it provide any means by which you may do so. It's up to you to decide how co-ordinates map to "units" in your own program (C/C++/etc) code; so for example if you see a call to glTranslate you get both the choice of and the responsibility for what the values passed to it mean in terms of your own code.