How to change projection..??

Hello there…

My initial projection area is set in such a way that my lower left coordinate is (0,0), i.e.

glOrtho(0, width, 0, height, -1, 1);

Now i need to move this projection area so that my lower left corner begins at (100, 150) i.e.

glOrtho(100, width, 150, height, -1, 1);

then, how do i do it.?? I tried specifying the same values as mentioned above… But it moves in such a way that only half of the displayed item is shown on the screen…

How do i do this so that my full displayed data comes at the center when i change the projection…??

Thanks in advance

Please check the meaning of the parameters of the glOrtho()!!!
I do not have strength to cite (again) the syntax of the functions. :frowning:
And use glTranslate() for panning, don’t change the projection!


I’m sorry… i forgot to mention one thing… I found out the min and max point from the data set and i got the two extreme points where my dataset is located… Then I used these extreme points to define a projection…

glOrtho(min_x, max_x, min_y, max_y, -1, 1);

With this the output what i get is what i mentioned in my previous post… Only half part is visible… So i thought this type of behavior could be possible because, min_* and max_* are unprojected values (values on glcanvas)… and I’m using those values as parameters for glOrtho() which is giving such output…

Thus, First i projected min_* and max_* and then passed these values as parameters for glOrtho()… When i do this, dataset doesn’t come in the display area… It comes somewhere else…

Where have i gone wrong…?? First of all what i did is correct way of solving.?? I used gluProject() function to project… So i have a small doubt here… Do i need to subtract the y coordinate from the height of canvas, as we did for gluUnProject()…?? If so then should it be before calling gluProject or after calling…??

Thanks again.

Did you read my previous answers/posts for your questions?
Of course that you don’t see anything, because everything is wrong! Forget functions gluProject/glUnproject!!! Because they use projection matrix setup by glOrtho, and you made some kind of circular dependency.

The only way-out is to learn how projection (in GL means) works. You said that you had read 3rd chapter of the Red book. After this, I really doubt… :frowning:

Oh…!!! I’m sorry sir… :frowning:

Hey, cheer up! :slight_smile:
And don’t call me sir, please!

You are still thinking in 2D and in physical coordinates. Read again chapter 3, and try to understand how viewing works. It is too comprehensive topic to be explained here.

Keep your projection parameters centered around coordinate-system center, and translate whole scene (viewing transformation) so that it can be seen from the viewer standing in the coordinate-system center.


You are my sir… You only guided me when i needed some one… :slight_smile:

Anyways, Initially, i was doing the same (translate whole scene at the center)… But in this case the problem is i need to keep track of both the original values and current coordinate system values…

Original values to display(print) and Converted values to show the position or information about the object for the user… For example, user wants to know what is the location of a particular Node… So he clicks on it and the x,y values of that Node will be displayed in the property window… This X,Y should be the lat/lon values or values in the corresponding coordinate system…

So i need to keep two values for each object… Wont it be a bad idea of programming which utilizes more memory.?? If i just change my projection, then in that case both the values will be same… so no need to keep two different values…

What say…??


Thank you, but I’ll rather be a friend. :wink:

If you just translate (or subtract and translate) then you don’t have to store coordinates in both systems. Addition is a very cheap operation. Even the multiplication is not expensive operation considering that there is no user that can click few billions times per second to make it noticeable. :slight_smile:
Even if there is such a super-user, Windows sampling rate will not allow that.

On the other hand, lack of precision can be a problem if you deal with full coordinates. If you are drawing the borders of the countries using lat/lon coordinates, that’s ok. But, if you want to draw a map of a city, than draw the conclusion by yourself. One degree is more than 100km (of course, depends from Latitude, but it does not change the conclusion) and a street is few meters wide. It is on the edge of ability to even be presented in the same system if you are using floats (remember, most graphics cards cannot deal with double precision values, and if they can (GTX260 and up) it is reserved for CUDA, not for OpenGL [I beg anyone to correct me if this is not true]). To draw a street, for example, on the proper way, you need a submeter-precision.

Something off-the-topic: I’m very disappointed by the decision of NVIDIA to disable its OptiX SDK for GeForce graphics cards. :frowning: