Results 1 to 2 of 2

Thread: what is a 'context'

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2003
    Location
    ames, IA, USA
    Posts
    6

    what is a 'context'

    please, an explanation of what people mean when i see code that says things like,

    /* Function that is called immediately after a new context is created.
    * Use this function to create context specific data structures.
    * i.e. Display lists, Texture objects, etc.
    *
    * @pre The ogl context has been set to the new context.
    * @post Application has completed in initialization the user wishes.
    */
    virtual void contextInit();

    -----
    i don't understand what 'context' could encompass. please set me straight. feel free to write as much info as necessary to explain,

    -pantheman
    cheers

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: what is a 'context'

    The term 'context' is frequently used in environments where you have a client and server model (hint: OpenGL is one of these).

    Because multiple 'clients' can use the 'server' concurrently, the server must somehow identify which client it serves at any given time. That's done because for each client there is a seperate set of state governing the operation of the server for this particular client.

    Consider two OpenGL applications running simultaneously (in seperate windows on a desktop). One uses textures, the other doesn't. When application #1 calls glEnable(GL_TEXTURE_2D), this state change applies only to its own private connection to OpenGL. Application #2 must not be affected by this.

    You can think of an OpenGL context as an object encapsulating all state for a client. Every GL call you make implicitly references the currently selected context. Or in C++ notation

    current_context->glEnable(GL_TEXTURE_2D);

    This is avoided however, mostly for efficiency reasons (note that DirectX Graphics does use this form of interface). Instead OpenGL uses something I like to call 'object selection' (no idea whether that's a proper technical term). That's where wglMakeCurrent(hdc,rendering_context) comes into play.

    You actually don't have to do much for this to work. A proper OS maintains the current GL context along with thread state, ie if your thread is interrupted by a different thread also using GL, the OS will automatically select the different GL context when it stops your thread, and also automatically switch it back before it resumes your thread.

    Hope this helps

Similar Threads

  1. Replies: 2
    Last Post: 07-23-2018, 10:14 PM
  2. Replies: 1
    Last Post: 06-22-2013, 09:31 PM
  3. Replies: 9
    Last Post: 12-31-2012, 04:20 PM
  4. Replies: 2
    Last Post: 04-26-2010, 09:38 PM
  5. Replies: 1
    Last Post: 06-26-2003, 12:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean