Can I display 2 or more windows at a time?

Hi all,

Can I display 2 or more windows at a time using OpenGL? where the editing in one window will affect the others simulteniously… can anyone help me please?

regards,
songeb

Yes you can. OpenGL uses a s.c. rendering context to interact with the window. Every window has its own rendering context. All the OpenGL commands affect only a single rendering context. You can select which window to render to by chaning the OpenGL rendering context. This is done under Windows with the wglMakeCurrent() function, and under the X Window System with glXMakeCurrent().

By the way, the OpenGL rendering context is a very huge context (a single context holds the entire OpenGL state). So swithcing contexts is something that is very expensive in terms of performance (it invloves stalling the rendering pipeline, setting up the graphic card for the new state etc).

If you only need to render two (or more) views, you are normally better off by rendering both views in a single window (using scissors and viewport to select different rendering areas of the window).

[This message has been edited by marcus256 (edited 02-11-2002).]

what is scissors? how do I use it? sorry I’m just a beginner man…

Scissors let you “cut away” rendering that goes outside of a defined rectangle of the screen. Go to this link:
http://hem.passagen.se/opengl/glfw/glman.html

…and check out the description of glScissor and glViewport.

Here’s an example:

You have a 1024x768 display window, which you want to split into two 512x768 windows. Then do this in your main rendering loop:

// Clear window
glClear( GL_COLOR_BUFFER_BIT | | GL_DEPTH_BUFFER_BIT );

// Enable scissor test
glEnable( GL_SCISSOR_TEST );

// Select and render into first window area
glScissor( 0, 0, 512, 768 );
glViewport( 0, 0, 512, 768 );
RenderFirstView();

// Select and render into second window area
glScissor( 512, 0, 512, 768 );
glViewport( 512, 0, 512, 768 );
RenderSecondView();

// Disable scissor test
glDisable( GL_SCISSOR_TEST );

// Swap buffers (if you use a double buffered display)
... (e.g. glfwSwapBuffers() if you use GLFW)

Projection and modelview matrix setup etc. is done as usual in each Render***View() function.

[This message has been edited by marcus256 (edited 02-12-2002).]

hmmm ok thanks a lot…

how about if I want to have let’s say 2 screens with dimension each 768 * 768 pixels? Can I use scroll bar in this case? how do I use it?

regards,
songeb

Hmmm… I don’t think you can use a scroll-bar (unless you implement it yourself, OpenGL-style). I may be wrong though. Anyway it does not seem like a good solution. Better to do e.g. a 1000x500 window with 2 x 500x500 parts in it. Or use a 1024x768 window, do two 512x512 areas and do something useful with the lower part of the display.

Our appplication has the standard scrollbars without any problem.

How do you do that? can tell me?

regards,
songeb

I have tried several times but always fail to get the desired result. For my project I’ll have 2 windows screen. 1rst window will be for an texture object display using orthogonal projection and the second one is the 3D visualisation using perspective projection. How do I put this projection type and also the model view so that I can display both window?

Oh ya I need to use gluLookAt(…) for this project. Is this the one causing the problem?

Is there any other way I can do to resolve the problem? I need to get the second window updated simultenously as the first window changed.

regards,
songeb

[This message has been edited by songeb (edited 02-20-2002).]

gluLookAt should not be a problem. I made an example program (with gluLookAt) which works nicely. You can find it here (source and executable): twoviews.zip

For a more advanced example, see this: splitview.zip

The latter displays three orthogonal views (wireframe) and one solid view (with lighting) of a torus. You can even click and drag the mouse to rotate the views. Personally, I think that it’s not too bad for a program that is less than 500 lines of code.

Both use GLFW (here: http://hem.passagen.se/opengl/glfw/ ).

[This message has been edited by marcus256 (edited 02-21-2002).]