OpenGl coordinate units!

I am new to OpenGl. I am making a 3D Graph inside a rectangular widget(ince, I am using QT). What I am not understanding is - What are the OpenGl coordinate units?

I know the width and the height of the dialig box/widget, but the 3D Graph which I am drawing inside it, is using it’s own units, thereby I am not in control of the graph. Actually I am scaling the 3D figure, but since I don’t know the units of opengl, I am not able to do it.

Any help from you guys would be highly esteemed.
Thanks s much


bottom-left is 0:0 -1:-1, top-right is 1:1 . You can flip y and fixup scaling and aspect-ratio manually via matrices.

Thanks, well could you kindly elaborate a bit about matrices to be used? Strangely, my opengl origin seems to be at the centre of the widget and not at the corner!!

Again, [-1;1], this means that 0 is the screen’s centre.
Refer to glOrtho tutorials on the net; everyone that has your problem searches for “2d in opengl”

Thanks so much friend! I did not know which BUZZ word to look on internet to solve my problem. Your hint will be helpful. I will just look into it.

Thanks so much

Whoops, I just noticed my initial reply had incorrect info, sry
the “bottom-left is 0:0” is “-1:-1” .

Only in textures the bottom-left is 0:0.

ahaa!! I see, it was helpful.
Thanks so much :slight_smile:

I have a simple OpenGL question. I have retrieved the world coordinate and one vector by using gluUnproject. I have given my object a certain transformation which is stored in matrix myTransformation. Now I want to convert that coordinate and vector to my object space. Is it enough just to multiply the coodinate as well as vector in world space to give them transformation in object space? Sorry this question may not directly related to glfw. Still if any one have the answer, it will be highly appreciated.



Hello Ilian,
I followed the approach you suggested, but I am still struggling with it.

Initially my code was:
glViewport(0, 0,(GLint)width,(GLint)height);
gluPerspective(45.0f,(GLfloat)width/(GLfloat),height, 0.1f,1000.0f);

Now as you suggested, I looked out for glOrtho and it did work, but the problem is that I lost the 3d touch in the figure.
glViewport(0, 0,(GLint)width,(GLint)height);
glOrtho (0, width, 0, height, 0.1f,1000.0f);

My problem is that how to move now from glOrtho to glPerspective? Unless, I get back to glPerspective, I cannot see
thr 3d view. Your suggestions will be esteemed.
Thanks so much