Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Changing states vs Changing context

  1. #11
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Quote Originally Posted by Silence View Post
    Well, it can be (it seems that effectively Windows MDIs work like this).
    All common GUI toolkits work like this. If you want to use multiple threads, you have to do this yourself.

    Quote Originally Posted by Silence View Post
    For example, in Unix, if you want 2 distinct windows, you'll generally open 2 distinct displays, then having to call the event checking function twice, one for each display.
    None of the common toolkits do this. Certainly, it doesn't apply to Xt, GTK+, Qt, wxWidgets, GLUT or GLFW.

    You could do it yourself, but it will cause problems as the application will appear to the X server as multiple, distinct clients.

    Quote Originally Posted by Silence View Post
    Both ways will lead to the same approach for multiple OpenGL windows in the same program: you will create two windows, two threads, and within each thread, create a context that you will keep current for all its life.
    Using GUI functions from multiple threads tends to be avoided. Some toolkits specifically disallow this, others officially support it (but don't have a particularly good track record for getting it right).

  2. #12
    Member Regular Contributor
    Join Date
    Jul 2012
    Thank you.

  3. #13
    Junior Member Newbie
    Join Date
    Jun 2017
    Quote Originally Posted by GClements View Post
    This is true for almost any application which doesn't explicitly use multi-threading. All of the common GUI toolkits invoke event callbacks in the main thread.
    Ok, so what about using the same context for all windows as follows, does its performance will be better than replacing contexts?

    hglrc = handle for context.

    // make context active for window 1
    wglMakeCurrent(hdc1, hglrc);
    // draw here for window 1

    // make context active for window 2
    wglMakeCurrent(hdc2, hglrc);
    // draw here for window 2

    // make context active for window N
    wglMakeCurrent(hdcN, hglrc);
    // draw here for window N

Posting Permissions

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