Can you get hold of the native drawable from jogl?

Hello,

I have a C library that makes GL calls (such as delivering vertex, normals, colors, etc) to a GL drawable. I need to interface with this library through a Java application and I could write my own JNI code to setup the GL drawable for this library however it seems like jogl has already encapsulated all the native details for me for the Windows/Linux/Mac flavors. I would like to use jogl to setup the GL drawable and then I would like to get the drawable so that I could hand it off to the C library to deliver the vertices, normals, colors etc.

Is there any way via jogl to get hold of the native drawing area and native GL context? I looked through the source code but it appeared that these methods were protected.

Thanks,
Michael

You can do this, but you will necessarily be writing platform-dependent Java code in similar fashion to how JOGL is written. If you check out and build the JOGL source tree (just follow the build documentation on the JOGL home page) you will see classes such as com.sun.opengl.impl.windows.WindowsGLDrawable and WindowsGLContext which are the real implementations of the abstract GLDrawable and GLContext interfaces. Note that methods like getHDC() and getHGLRC() are public. (Actually the context getters were protected, but changes have just been checked in to make them public on all platforms – thanks for pointing this out.)

Ken,

Thanks for the info. In my scenario I have to use the existing C library to do the rendering. In the future it may be re-written entirely in Java/JOGL but for now I have to settle for the UI and the setup OpenGL to use Java/JOGL and leave the OpenGL rendering (minus the setup of the drawing area and the switching of the GL context) to the existing C library.

Are the checked in changes you mentioned part of the binaries that I download or do I have to wait for the next release?

Thanks,
Michael

The changes are present in the nightly builds you can download from the JOGL home page. If you want to use Java Web Start (which I doubt, since you have a significant native portion of your application) you’ll need to wait for the forthcoming JSR-231 beta 4, hopefully later this week.