Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: OpenGL and windows.

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Moscow,Russia
    Posts
    29

    OpenGL and windows.

    I want to create multi-windowed application, but I don't
    want to create many threads.
    I try:

    loop
    {
    wglMakeCurrent(hdc1,ghlrc1);

    //paint in first window

    wglMakeCurrent(hdc2,ghlrc2);

    //paint in second window
    }

    But system crushes. Help me, please.

    Thanks, Peter.

    [This message has been edited by IronPeter (edited 12-09-2000).]

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Zürich, CH
    Posts
    21

    Re: OpenGL and windows.

    I'm not sure about it (I use glut) but maybe you should try:

    loop
    {
    wglMakeCurrent(hdc1,ghlrc1);

    //paint in first window

    wglMakeCurrent(hdc1,NULL);

    wglMakeCurrent(hdc2,ghlrc2);

    //paint in second window

    wglMakeCurrent(hdc2,NULL);
    }

    Or something like that.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Computer Graphics Group, RWTH Aachen, Germany
    Posts
    137

    Re: OpenGL and windows.

    Haw many device contexes r u using?
    For example there is a limitaiton in Win9x for the number of the reserved HDCs. NT doesn't have such a problem. In 9x platform you can use CS_OWNDC in your window class style...(this will help preventing the crash)
    Also I may point, that using wglMakeCurrent & MDI app is very slow solution - wglMakeCurrent is really a slow operations - I have tried it, and so it's written on the NVidia developers FAQ. Try to use SDI app, and to divide the view with glViewport...

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Damascus, Syria
    Posts
    147

    Re: OpenGL and windows.

    I am not sure, but maybe OpenGL can't switch to another rendering context if it didn't finish rendering previous one. So, you shouldn't call wglMakeCurrent until you are sure that all GL commands for the other rendering context are processed. You do so by calling glFinish instead of glFlush. glFlush returns immediately before finishing rendering. Try it.

    George

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2000
    Location
    Germany
    Posts
    2

    Re: OpenGL and windows.

    From your pice of Code I see that you create a single rendering Context for each Window. This is not nescessary and uses huge amounts of MEM especially on GForce Cards btw. ! You should create one rendering context and then bind it to the Device context of the window you are currently drawing in. Then in your WM_PAINT handler of every window you call:
    wglMakeCurrent(CurDC, GlobalRC);
    // Draw
    wglMakeCurrent(NULL, NULL); // Make the rendering context usable to other device contexts i.e windows. This will work.

    If you want to keep your code you should try the following:
    loop
    {
    wglMakeCurrent(hdc1,ghlrc1);

    //paint in first window

    glFlush(); or glFinish();
    wglMakeCurrent(NULL, NULL);

    wglMakeCurrent(hdc2,ghlrc2);

    //paint in second window

    glFlush(); or glFinish();
    wglMakeCurrent(NULL, NULL);
    }

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Moscow,Russia
    Posts
    29

    Re: OpenGL and windows.

    Thank you SUALK2. It works fine. I did not
    think that single rendering context can be used for multi-window rendering.

    Also please excuse my English.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •