PDA

View Full Version : Expanding the drawing area?



djavan
02-01-2003, 04:32 PM
Hi Everyone

Can anyone please tell me how it is possible to expand the drawing area?

I am drawing a 3D image (based on the XYZ-Coordinates of a set of points) which appears to be larger than my window and therefore I don't see the entire image. I want to know how to expand the drawing area (i.e. maximum XYZ-Coordinates that is seen on my window) when, for example, I enlarge the window to Full-Screen.

I thought I could do this via glViewport (0,0,newWidth,newHeight) but it only enlarges the image to fit the enlarged window (instead of bringing in some/all of the missed out parts).

My highest appreciation is attached.

shinpaughp
02-01-2003, 07:57 PM
What kind of projection are you using... orthographic or perspective? Try changing your values for your projection type call such as glOrtho, glFrustum, or gluPerspective. If you aren't using them, do.

Be especially careful of your near and far values as you will not see any vertices that do not lie between the near and far.

nexusone
02-02-2003, 03:59 AM
glViewport set's you window area in which to render you world to.

glOrtho and glPerspective set's the 3D area in which render from.

What you can do is change you ortho or Perspective view and not change your glViewport.

Just keep the viewport the same size as the window and adjust the orhto or perspective based on object size.

The other option would be to scale down the object with the glscale command.

example:

glViewport( 0, 0, 640, 480)// windows size

glOrtho(-1000.0, 1000.0, -1000.0, 1000.0, -1000.0, 1000.0); //World size

The world will be rendered down to the viewport size.

[This message has been edited by nexusone (edited 02-02-2003).]

djavan
02-02-2003, 10:28 AM
Thanks a lot both you.

I added the following two lines to my Form_Resize routine (I'm using VB):

glViewport 0,0,scaleWidth,scaleHeight
glOrtho -1000.0, 1000.0, -1000.0, 1000.0, -1000.0, 1000.0

and as soon as I change the window size, my picture disappears and never comes back!!

Am I missing something?!?!

shinpaughp
02-02-2003, 01:31 PM
Before you do that, be sure to call:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

Otherwise you are multiplying your current projection/modelview matrix by another glOrtho and it will give strange results.

Afterward, be sure to switch back to glMatrixMode(GL_MODELVIEW) for your rendering.

Also, just in case, verify that your scalewidth and scaleheight variables are correct

[This message has been edited by shinpaughp (edited 02-02-2003).]

nexusone
02-02-2003, 02:01 PM
I would have to see how you are setting up other parts of your code... maybe post you display routine and screen setup.



Originally posted by djavan:
Thanks a lot both you.

I added the following two lines to my Form_Resize routine (I'm using VB):

glViewport 0,0,scaleWidth,scaleHeight
glOrtho -1000.0, 1000.0, -1000.0, 1000.0, -1000.0, 1000.0

and as soon as I change the window size, my picture disappears and never comes back!!

Am I missing something?!?!