Login  Register

Obtaining OpenGL Context Handle without Passing as a Variable.

Posted by millerni456 on Apr 01, 2014; 11:00pm
URL: https://forum.jogamp.org/Obtaining-OpenGL-Context-Handle-without-Passing-as-a-Variable-tp4032092.html

Hey all,

I'm not sure how to do this (or if it is even possible).

Here is what I don't want to do.  I don't want to keep a handle of OpenGL's context (using GL2 data type) and pass it around each function that has to perform OpenGL operations.  Instead, I wanted to know if I can access the current OpenGL context handle via some functions in the JOGL library.

NOTE: I am not talking about switching the context to a different thread!

Also,  if it is possible to grab the current context without passing as a parameter or using a global variable, then is there any significant performance drop when accessing that context's handle?  I understand there is a performance drop when switching the context's thread, but again... this is not what I'm seeking to do.


I'm just looking for some guidance because I don't want to have GL2 in every method declaration in my application
EDIT: I just want to make it clear that I don't want any global variables either.  I'm trying to make the OpenGL operations hidden from the outside world.  (I guess a private global variable would do, but I'm still curious about accessing the thread's current OpenGL context handle.)

Thanks everyone!
- Nick Miller