Mouse callbacks from external native window

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

Mouse callbacks from external native window

Dominik Pospisil
Hi all,

I am using jogamp to render GL scene inside native (c++) application. The (native) window and GL context are both created by the native app. I am obtaining the GL context via:

GLContext ctx = GLDrawableFactory.getDesktopFactory().createExternalGLContext();

My question is if it is also possible get notified of the mouse events inside the native window created by the app? I was looking for a way how to wrap a NativeWindow instance around the existing native window but did not find any way how to do it.

Many thanks!

- Dominik
Reply | Threaded
Open this post in threaded view
|

Re: Mouse callbacks from external native window

elect
Dominik Pospisil wrote
I am using jogamp to render GL scene inside native (c++) application.
May I ask why?
Reply | Threaded
Open this post in threaded view
|

Re: Mouse callbacks from external native window

gouessej
Administrator
In reply to this post by Dominik Pospisil
You can call a native method inside the Java NEWT or AWT listeners, can't you?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Mouse callbacks from external native window

Dominik Pospisil
Yes, but the native app which I am not in control of does not give me access to the mouse/keyboard neither.

I am not using any AWT so i can't use awt mouse listeners. The AWT system event queue do not receive any events related to the native window. The only info about mouse which I can get is from java.awt.MouseInfo, but it does not provide access to mouse button statuses, just the possition :(

- Dominik
Reply | Threaded
Open this post in threaded view
|

Re: Mouse callbacks from external native window

gouessej
Administrator
If you don't use NEWT GLWindow, AWT GLCanvas, SWT GLCanvas or Swing GLJPanel, JOGL won't have access to the mouse events. There is no API in JOGL to get the mouse events of a window not created by JOGL and it's not going to change any time soon for security reasons. Maybe you can use JInput to get the mouse button statuses.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Mouse callbacks from external native window

Dominik Pospisil
I understand the security concers. But maybe just the window of the GL context you can attach to? If you can render to a surface, I don't see as a security issue being able to listen to it's mouse events...
Reply | Threaded
Open this post in threaded view
|

Re: Mouse callbacks from external native window

gouessej
Administrator
If the window hasn't been created by JOGL even though JOGL "knows" its OpenGL external context, there is no mean of obtaining its mouse events. There is nothing magic, JOGL is able to manage only the events of the windows it creates that it passes to its listener. Maybe you can wrap the window created by your native C++ code into a proxy surface by using this method, see how it is used in our SWT canvas, you'll have a chance to get the mouse events. You have to find how to use this proxy surface to create a NEWT window and then you'll be able to add a mouse listener into it.

I plan to implement a new input API for NEWT but only focused NEWT windows will be managed.

Julien Gouesse | Personal blog | Website