LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: fred_em on November 29, 2010, 13:36:19

Title: Newbie question regarding current LWJGL context
Post by: fred_em on November 29, 2010, 13:36:19
Hi,

I have an application written in Java and C++. The rendering loop is managed on the C++ side.
Part of the rendering loop is calling back from C++ into Java - I have the necessary JNI layering code for this.

When I am inside a Java callback, wglMakeCurrent (on the C++ side) has already been called.

In my Java callback function called from C++, I tried calling glBlendFunc() or other OpenGL functions but I get a NullPointerException.
I believe there is something that I must do in order for LWJGL to work, like initialize something.

What shall I do to get started?

Thanks
-F
Title: Re: Newbie question regarding current LWJGL context
Post by: spasi on November 29, 2010, 14:05:23
Hi fred_em,

You need to call GLContext.useContext(Object) after the wglMakeCurrent call on the C++ side. Both calls must be executed in the same thread and the Object argument can be any object that uniquely identifies your externally managed context (make sure .hashCode() returns something sensible, the object will be stored in a HashMap in LWJGL). You should be able to use the LWJGL API without problems after that.
Title: Re: Newbie question regarding current LWJGL context
Post by: fred_em on December 13, 2010, 14:15:52
Thanks, it works.

However, I have another, more serious issue that may prevent me from using LWJGL.