PDA

View Full Version : Reshape function and multiple viewports



Perlice
01-05-2013, 10:28 AM
Hello everyone, I'm trying to learn OpenGl because I need it to pass an exam, but I don't understand how to write the right reshape function if I have two viewports. The first one is bigger and I use gluPerspective to draw in it, the second one is on the bottom of the window and I use gluOrtho2D.

Alice
sorry for my English. I'm Italian :-)

Alfonse Reinheart
01-05-2013, 11:18 AM
There is no "reshape function". Whether you have a "reshape function" at all is entirely up to you. And if you have one, what you do wihtin it is also entirely up to you.

If you need to use a perspective projection sometimes and an orthographic projection other times, then you will need to set one first, do rendering with that, then set the other, and do rendering with that. How you accomplish this is entirely up to you; you will need to make sure that your rendering function has the information necessary to do this. This will often involve storing the window's size somewhere and using that size in your rendering function.

You've made the mistake of thinking that the way a particular tutorial looks is somehow enforced or required. That there must be a "reshape function" and it must call either gluPerspective or gluOrtho or whatever. It's your code; do whatever you need to to make it work.

Perlice
01-05-2013, 11:29 AM
Thanks for your reply :) it's true that I was trying to follow too much a tutorial :-)

Just out of curiosity.. Is there a way to write a reshape function while using two viewports or is it impossible?

Perlice
01-05-2013, 12:28 PM
Thanks for your reply :) it's true that I was trying to follow too much a tutorial :-)

Just out of curiosity.. Is there a way to write a reshape function while using two viewports or is it impossible?
I reply to myself.. Now I think I understand what you meant, if I can't do it in the way I want i can always do it in another way, I just have to watch the problem from a different point of view :)

problem solved :-D