J3D OpenGL and DirectX SDK differences

What are the main differences for these two, I understand that OpenGl and DirectX are different APIs. Let’s say if I develop on DirectX, will it run OpenGL mode?

As far as I understand DirectX mode is more advanced and up to date due Microsofts love for pc games, is this true?

I hear that people have had problems creating full screen exlusive with DirectX SDK. What is this about?

And finally, how is the Canvas3D buffered, or do I have to use bufferstrategy/ double buffering. I read somewhere in the docs that Canvas3D has innate double buffering. Is this true?

Is it possible to mix 3D and sprite graphics? Like make qui with 2D(Health bars, messages, scripting ect.) and then use 3D for the game itself?

The damn free J3D book is down. I guess I have to wait for awhile until I can start studying how the J3D api works.

I’d like to add one more question that came up while I was studying the sun tutorial, old javagaming forums and the docs/demos.

Is there any way to build a rendering loop as in 2d? I understand that things are handled differently in java3D, but overriding paints and repaints would relieve a lot of resources.

Just to ask, what do you guys use, onscreen or offscreen rendering?

As far as I understand, it can be done through creating offscreen Canvas3D and then rendering it onto buffered image. This however seems to be awfully slow process, at least it was signifigantly slower than onscreen as I tried. There might have been something wrong with my code, as I don’t understand Java3D very well yet.

In all the demos the animations were “automatic” and I couldn’t find rendering loops anywhere. They use paint and repaint right? How do I forfeit this or am I supposed to do it at all?

There are several ways. My current favorite is to have a Behavior/WakeUpCondition snapped to the scenegraph that drives the game. If you use WakeUpOnElapsedFrames(0), this is a real renderloop in teh classical sense. But driving Java3D in such a tight loop will make it unsmooth. I prefer to have a decent fps value and wakeup the behavior in timeslices.

Another option would be to overload postSwap (unsure wether the name is ok, look it up) to do you action whenever the last frame is on the screen. Again, results in a closed loop.

My first guess was to try a seperate thread driving the game, but this is not synchronized with the rendering that it may happen that you update an object position and the camera in different frames…

[quote]I understand that OpenGl and DirectX are different APIs. Let’s say if I develop on DirectX, will it run OpenGL mode?
[/quote]
To the J3d programmer, this should make no difference between the two, in reality theres a couple of points you should remember…

[quote]As far as I understand DirectX mode is more advanced and up to date due Microsofts love for pc games, is this true?
[/quote]
Nope, actually the wrong way around, the DX version is missing a few features here and there, namely:
Can’t adjust wireframe width
Poly offset is ignored
A few other details with line/point rendering that i can’t remember (mainly antialiasing related).

Also I think both versions may have problems with some of the more obscure texture wrapping modes, but this may have been fixed.

[quote]I read somewhere in the docs that Canvas3D has innate double buffering. Is this true?
[/quote]
If i remember correctly, you chose how many buffers you want on creating the Canvas3D.

For the game loop I tend to favour over-riding preRender() in Canvas3D, which works nicely and keeps you in sync properly with the internal rendering.

For 2d, if you want to use Graphics2D or similar, then that involves the rendered scene being read back over the agp, drawn to, and then copied back across into video memory - hence its dog slow :frowning: A much better way is to emulate 2d by using textured quads aligned to face the camera - attaching geometry to the view platform works nicely for HUDs.

Last time i tried it, offscreen rendering wasn’t hardware accelerated, and so very slow, I think I heard this being fixed in a recent version though, or it might still be planned… Note, all the above was from my experiences with J3d about 6-12 months ago, and so some of these problems might have been fixed.

What I’m basically doing now is modifying keyNavigate app so that it looks like the primitive version of a 3D game.

It seems to be that if I want rendering loop I have to overrider or overload something in Canvas3D, but what Herkules said it seems to me that it is not mandatory to even have timer thread. This is very confusing compared to 2D.

My current plan now is to extend class from Canvas3D and then implement it to Runnable. Then over-ride the preRender and then start to worry about what to display.

How does drawing work on Canvas3D. I assume the Canvas3D still works the drawing alone from the scenegraph? Even if I do override preRender the Java3D continues with its normal rendering loop?

Edit:
Pity me looks like I don’t have to play with timers this time or do I since I can access the thread in Canvas3D.

Fun.