开发者

Is it possible to make a JFrame always on top of apps. running OpenGL and DirectX?

I am currently working on a notification app, using Java.

I need for the window to be shortly (about 10 sec.) on top of any apps. including the ones running OpenGL and DirectX (e.g. computer games). I know that the JFrame.setAlwaysOnTop(true); only works in window based environments, which OpenGL and DirectX is not. Thought about the OpenGL bindings, but can't seem to find anything about DirectX?

M开发者_StackOverflow社区aybe it is possible using JNI? Any ideas are welcome :-)

Edit: Thanks for the answers guys, but I actually gave up on it and decided to force the game, of which I am making the overlay for, in windowed fullscreen mode. I´ll just have to wait and see what the beta-testers have to say about the reduced fps :-) thanks again


Don't bother with directx and java. That has an impedance mismatch. Java is cross platform, OpenGL is cross platform. If you insist on using directx you can try SWT since it uses native operating system resources you might have a chance.

For opengl what you are looking for is canvas integration with panel/jframe, you can use JOGL for that. I think lwjgl has a implementation too, but the jogl one is better. Then you can set the alwaysOnTop on that jframe.

kenai.com/projects/jogl


Your problem is not related to your code but the graphic device instead. The device can have only one accelerated surface in full screen mode. This is Why you cannot launch two DirectX games in fullscreen if you have a dueal head GPU.

Your best bet is to try to find the DX/OpenGL surface pointer and attach to it using the required APIs. I don't know if this can be done in Java however the approach woul be:

  • get a pointer to the accelerated surface of the game or app that is running
  • create an accelerated graphic device
  • create a non-mimpap texture(screenshot) from your UI
  • get a pointer to the texture surface
  • use the stretch rectangle from this surface to the one you got in step 1
  • present

This may introduce flickering if not using Vsync and refresh rate synched repetition for each frame. This may introduce a substantial framerate drop too.

One example of this is FRAPS, that draws the current framerate on the accelerated app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜