JOGL used with native methods

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JOGL used with native methods

stepasite
Hi,

I am wondering how to use JOGL for OpenGL rendering from native methods called via JNI. I want to initialize context in JOGL and move rendering routine to native method called from display().

Let's stay on Windows only. There are only OpenGL headers of version 1.1 on Windows. Can I use GLEW for loading OpenGL in native method when it is already initialized by JOGL? Or should I better download OpenGL headers from OpenGL.org? Or should I use headers that come with JOGL (I mean headers located at <jogl-master>/make/stub-includes/opengl/GL)?

I tried to find any example how to use JOGL as only wrapper for rendering via native methods, but could not find anything. Any help would be much appreciated.


Thanks in advance for any help,
Pavel
Reply | Threaded
Open this post in threaded view
|

Re: JOGL used with native methods

gouessej
Administrator
Hi

Why not doing the opposite? You can create the context in your native source code, create an external context based on it with GLDrawableFactory.createExternalGLContext() and call your native drawing method in GLEventListener.display(). Another solution consists in creating the context in Java code with JOGL and calling your native drawing method in GLEventListener.display(). I'm not sure you can create a GLContext without creating a GLDrawable. Maybe Sven can confirm.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL used with native methods

stepasite
Thanks for the quick reply.

I think that your proposed solution is exactly what I need.

This solution will let me initialize OpenGL in native method with GLEW, create OpenGL context and then get it in JOGL via GLDrawableFactory.createExternalGLContext().

But I am not sure how I can create new GLCanvas/GJPanel using this context or how to assign it to any existing one. As context passed to constructor serves  as sharing context (that is not assigned).
Reply | Threaded
Open this post in threaded view
|

Re: JOGL used with native methods

Sven Gothel
Administrator
In reply to this post by gouessej
On 02/14/2014 03:06 PM, gouessej [via jogamp] wrote:
> Hi
>
> Why not doing the opposite? You can create the context in your native source
> code, create an external context based on it with
> GLDrawableFactory.createExternalGLContext() and call your native drawing
> method in GLEventListener.display().

I would use the other solution below,
since one of JOGL's strength is to be able to create the context for the
'user' w/o the hassle of dealing w/ the platform details.

> Another solution consists in creating the
> context in Java code with JOGL and calling your native drawing method in
> GLEventListener.display(). I'm not sure you can create a GLContext without
> creating a GLDrawable. Maybe Sven can confirm.

Sure you can create the context w/o a drawable (technically)
but we require a drawable to be bound to make it current
_while_ creating it.

~Sven



signature.asc (894 bytes) Download Attachment