Qt-jambi-interest Archive, June 2007
How to use Java3D or Xith3D in a widget ?
Message 1 in thread
Hello,
I'm trying to use Java3D in a widget without any success.
I've tried to integrate the "HelloUniverse" Java3D example in a QWidget.
You can see this example in action here :
https://j3d-webstart.dev.java.net/test/
I've inspired myself from the "HelloGL" demo from Qt Jambi.
So, firstly i create a private class named 'HelloUniverseGL' extending
QGLWidget class.
In this class, I integrate the code from 'HelloUniverse' original class
with few modifications.
Then, I create the public class 'HelloUniverse' extending QWidget class.
This class is written on the same way as the 'HelloGL' public class.
This doesn't work at all, it compils but I see only a black screen on the
gridlayout where i put this widget.
My code for HelloUniverseGl class is off course not good but i don't know
how to use Java3D in a widget.
Should I use a QGLWidget for that ? or another Qt Widget (QGraphicsView,
QWidget, ...) ?
What is the correct way to use Java3D with Qt Jambi ?
I'm still not sure to use Java3D, i hesitate with the 3D engine Xith3D.
If anyone have any experience with those 3D APIs, feedbacks are welcome.
Thanks you.
Message 2 in thread
Ludo wrote:
> Hello,
>
> I'm trying to use Java3D in a widget without any success.
> I've tried to integrate the "HelloUniverse" Java3D example in a QWidget.
> You can see this example in action here :
> https://j3d-webstart.dev.java.net/test/
>
> I've inspired myself from the "HelloGL" demo from Qt Jambi.
> So, firstly i create a private class named 'HelloUniverseGL' extending
> QGLWidget class.
> In this class, I integrate the code from 'HelloUniverse' original class
> with few modifications.
>
> Then, I create the public class 'HelloUniverse' extending QWidget class.
> This class is written on the same way as the 'HelloGL' public class.
Hi Ludo,
To render Java3D you have to go through the Canvas3D class which is a
java.awt.Canvas subclass and thus part of the AWT / Swing event loop and
rendering pipeline. Since Qt Jambi currently doesn't support mixing AWT
/ Swing components into Qt Jambi you need to use the offscreen rendering
features of Canvas3D and propagate that data to Qt Jambi somehow.
The easiest, yet probably slowest option is to get the offscreen buffer
of the canvas and convert that to a QImage using getPixel / setPixel.
May be usable for small canvases, but unusable for medium to big ones.
To get an ok speed out of this you probably need to go through JAWT and
get the native handles and paint them directly into QWidgets using
BitBlt and the like...
Please note that integration with AWT / Swing is on our roadmap and will
be possible in the future.
best regards,
Gunnar
Message 3 in thread
On Mon, 18 Jun 2007 09:19:30 +0200, Gunnar Sletta <gunnar@xxxxxxxxxxxxx>
wrote:
>
> Hi Ludo,
>
> To render Java3D you have to go through the Canvas3D class which is a
> java.awt.Canvas subclass and thus part of the AWT / Swing event loop and
> rendering pipeline. Since Qt Jambi currently doesn't support mixing AWT
> / Swing components into Qt Jambi you need to use the offscreen rendering
> features of Canvas3D and propagate that data to Qt Jambi somehow.
>
> The easiest, yet probably slowest option is to get the offscreen buffer
> of the canvas and convert that to a QImage using getPixel / setPixel.
> May be usable for small canvases, but unusable for medium to big ones.
> To get an ok speed out of this you probably need to go through JAWT and
> get the native handles and paint them directly into QWidgets using
> BitBlt and the like...
>
> Please note that integration with AWT / Swing is on our roadmap and will
> be possible in the future.
>
> best regards,
> Gunnar
>
Thank you Gunnar,
I've tried your method using BufferedImage.getRGB / QImage.setPixel,
but it's really slow and i can't use it in "real time".
The other drawback is that I can't use it in immediate mode rendering
because
an onscreen canvas must be active and displayed to generate next frames.
Else, only
the first frame is rendered.
I 've not tested to go through AWT and native handles because I don't know
how to make that.
It's too much complex for me for the moment.
Do you think I can hope same performances for Java3D in Jambi as Java3D in
a Swing container ?
Shouldn't it be easier with other 3D engines like JMonkeyEngine or Xith3D ?
What kind of opengl wrapper do you use with QGLWidget ? JOGL, LWJGL or
your own wrapper ?
Do you know when the integration with AWT/Swing will be available ? (when
it will be ready, I suppose! :D )
Thank you very much for your support.
Best regards,
Ludo
Message 4 in thread
Ludovic Marcé wrote:
> Thank you Gunnar,
>
> I've tried your method using BufferedImage.getRGB / QImage.setPixel,
> but it's really slow and i can't use it in "real time". The other
> drawback is that I can't use it in immediate mode rendering because
> an onscreen canvas must be active and displayed to generate next
> frames. Else, only the first frame is rendered.
I suspected that it wouldn't be good enough...
> I 've not tested to go through AWT and native handles because I don't
> know how to make that.
> It's too much complex for me for the moment.
>
> Do you think I can hope same performances for Java3D in Jambi as Java3D
> in a Swing container ?
At this point I really can't say, because I don't know how this
integration can be done. If we get access to the proper window handles
and get the mapping right, then the same kind of speed may be possible,
but I suspect some performance degradation is to be expected when
layering one framework on top of the other.
> Shouldn't it be easier with other 3D engines like JMonkeyEngine or Xith3D ?
> What kind of opengl wrapper do you use with QGLWidget ? JOGL, LWJGL or
> your own wrapper ?
Other than JOGL, I haven't used these other libraries so I can't give
you any good feedback on those. The way QGLWidget works is that we
allocate a GLContext and attach it to a window id in the Qt widget
hierarchy. What this means for JOGL is that we can just say
QGLWidget.makeCurrent()
and then attach JOGL to the current context. From there on out it is
possible to make normal GL calls on it. If the other libraries are also
based on OpenGL then a similar approach should be possible. Looked like
at least LWJGL was primarly OpenGL based on the graphics side from the
docs so maybe this should be possible here...
> Do you know when the integration with AWT/Swing will be available ?
> (when it will be ready, I suppose! :D )
We'll let you know when we have something running, but we're aiming for
next year with this integration.
-
Gunnar