Hello Guest

Newbie question regarding current LWJGL context

  • 2 Replies
  • 2757 Views
Newbie question regarding current LWJGL context
« 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

*

Offline spasi

  • *****
  • 2216
    • WebHotelier
Re: Newbie question regarding current LWJGL context
« Reply #1 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.

Re: Newbie question regarding current LWJGL context
« Reply #2 on: December 13, 2010, 14:15:52 »
Thanks, it works.

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