View Full Version : OpenGl coordinate units!

mullerpeter8

06-29-2010, 08:22 AM

Hello,

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

Ilian Dinev

06-29-2010, 08:49 AM

[-1;1]

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.

mullerpeter8

06-29-2010, 10:32 AM

Hi,

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!!

Ilian Dinev

06-29-2010, 11:31 AM

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"

mullerpeter8

06-29-2010, 11:40 AM

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

Ilian Dinev

06-29-2010, 11:50 AM

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.

mullerpeter8

06-29-2010, 12:02 PM

ahaa!! I see, it was helpful.

Thanks so much :)

jenny_wui

06-29-2010, 07:27 PM

Hello,

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.

Thanks,

Jenny.

mullerpeter8

06-30-2010, 07:31 AM

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);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

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);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

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

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.