PDA

View Full Version : Partitioned display window, all looking at origin from different angle



jonny
01-25-2001, 07:51 AM
I'm trying to partition a display window into four parts, that show a different side of an object, front, side, top... ( like 3d studio max ), anyway I cannot figure out how to have 4 cameras in one window, but in different regions, all looking at the origin, but from different angles

if this was the window:

-------------------- one would be top view, one would be side, one would be
| | | front...
| | |
--------------------
| | |
| | |
---------------------

any help would be greatly appreciated

Kilam Malik
01-25-2001, 08:17 AM
Supposing, you have a Draw() function, doing all your drawing. With glViewPort you define the region, where openGL should draw:

int x, y; // Screen width and height.

// Set projection:
glOrtho or gluPerspective or glFrustum()...
glViewPort(0, 0, x/2, y/2);
Draw();

glOrtho or gluPerspective or glFrustum()...
glViewPort(0, y/2, x/2, y/2);
Draw();

glOrtho or gluPerspective or glFrustum()...
glViewPort(x/2, 0, x/2, y/2);
Draw();

glOrtho or gluPerspective or glFrustum()...
glViewPort(x/2, y/2, x/2, y/2);
Draw();

chennes
01-25-2001, 08:18 AM
Actually, your best solution is probably to actually partition the window itself (not the drawing area) into the panes that you want. Then, create four drawing areas. That way, most expose events will only hit one or two of the drawing areas, not all of them. Then, the problem is easy.

Chris

Kilam Malik
01-26-2001, 05:57 AM
Chennes,

as I remember, you can specify which part of the screen is redrawn. Sure, in your solution it works automatically. But you have to switch the render contexts, which would be an extra effort.

Kilam.

coco
01-26-2001, 06:18 AM
Two things:
-You can render to diferent windows (diferent HDCs) using a single context. It's in the specs, I didn't invent this.
-Multiple rendering contexts and sharing display lists and textures is a something I have nt been able to put to work in some cards.

I choose one big window using various glViewport calls, or various windows with a single rendering context. It has worked very well for me, in multiple video cards, consumer and pro.

chennes
01-26-2001, 07:08 AM
How do you use the same rendering context in various windows? In my code, I think I've ended up with four different rendering contexts, but if I can avoid the overhead of switching contexts that'd be great. Primarily I use a partitioned window because it allows easy automatic resizing of the partitions, so I need to keep it that way.

Chris

coco
01-26-2001, 09:37 AM
simply use wglMakeCurrent( MyGlobalRenderContext, MyWindow1) to render in window1, and so on. When you create the rendering context, use the hdc of any of the windows. The wglMakeCurrent documentation says:
"It need not be the same hdc that was passed to wglCreateContext when hglrc was created, but it must be on the same device and have the same pixel format. "

That's it.

chennes
01-27-2001, 12:20 PM
How much overhead does this actually avoid. I have to call glXMakeCurrent to switch contexts anyway - how is it faster to use it with the same context and a different drawable?

Chris

[This message has been edited by chennes (edited 01-27-2001).]