Java OpenGL bindings the illusion

Everyone is fascinated by that aproach and saying that binding open gl is the way to go for java games. Then they make some benchmarks showing some balls bouncing arround and pulling out great frame rates.

But this is just an illusion, Java3D does a lot more things than visualizing geometry. It does scene graph traversal and optimization, behavior and lod everything itegrated in the model. A game is much more than some balls bouncing on the screen, and thats why java bindings will never replace java 3d.

Read my avatar message: Java3D rules. :stuck_out_tongue:

Of course that many people report performance problems but Java3D is a high level graphics API. Most of the problems come from bad use of memory not leaving time for the gc to work, not calling the gc immedeatly after setup, not stoping the renderer during setup, excess use of memory allocation during rendering times (which should be used only during setup phases), dangling sub-graph trees, you name it. In java3d there are one million ways to screw up your code if you don’t read the specification right.

With all this said of course that java3d cannot compete with a C++ engine, neither an open gl binding running any real game. But we can use your imagination and make games that don’t render so much polygons and don’t use so much heavy textures. With this in mind java3d has anything we need to build great games. Remenber that a game quality is not measured by the number of polygons it is capable of drawing per frame.

No… your avatar says Java games rock!

That being said… what’s your point? Use Java3D. Nobody’s stopping you.

hey zingbat, i couldn’t have say it better!

Yeah, but I like using OpenGL! ;D

Well, the original poster’s experience of Java3D certainly differs from mine.

The real problems that I have had with Java3D, the ones that can not be worked around and would be labeled ‘showstoppers’ in commercial applications, are none of the issues mentioned above. They also do not have to do with reading the specification wrong, rather they have had to do with core design decisions of the API and its proprietary nature. Those problems are also solved by an open API like JOGL.

Specificly, Java3D’s multi-threaded and opaque architecture as well as political issues surrounding the API is keeping Java3D from being a serious alternative for typical consumer-grade multimedia. The political issues have to do with the API being closed source so developers can not fix the architecture problems and the inter-company issues that is stopping Java3D from being available on Mac.

Just try playing sound with JavaSound or JMF (even worse with video) while rendering a slightly complex scene and watch the thread-chaos either turn the rendering into a slideshow or make the sound stutter. The opaque architecture offers very little opportunity for the programmer to affect any of this and the closed source policy prevents programmers from fixing or working around the bugs in Java3D’s own sound API, bugs that have plagued the API from day one and are still not solved in the most recent release.

Sure, you can write some limited games, such as Law and Order, in Java3D, but I bet Shockwave3D would have been a much better alternative for the job. Especially with its tight integration with popular 3D-modeling apps and its Mac portability. The developers apparently had to port the game to GL4Java to get Mac portability, but that wasn not too hard because the game did not use much 3D at all (which is why they could even use Java3D).

Another reason for using an OpenGL binding is of course because such bindings tend to support extensions, such as programmable shaders, much quicker than Java3D, but that’s not such a big problem YET since most consumers still seem to have cards without programmable shaders.

I hope I have cleared up some of the motivations behind using a 3rd party OpenGL binding. I am just curious, if Zingbat and MisterX really thinks that Java can’t compete with C++ for real games, are you guys just here to learn how to use Java for scripting in your C++ engines? or are you maybe working strictly on the server side? Anyway, I don’t think that belief is shared by most developers here.

No stencil buffer access = no shadows #1
No hardware shader access, vertex or fragment. = no shadows #2

Shadows built with user defined and control geometry, yes.
I’ve doen it, but it is a pain and CPU intensive, especially for many objects.

Multi-pass rendering beyond the multi-texture support is extremely cumbersome is at best.

IMHO, it’s non-extendible renderer is it’s greatest weakness ( and would-be greatest revision effort)

Nuff for now.

I have been programming Java3D for 5 years now. It did a great job for many different applications as well as games.
Unfortunately even low-end game graphics have raced passed J3D 1.3.1 renderer.

Yes, scene graphs are nice.
Unfortunately, due to the way graphics hardware evolves, close access is probably going to be needed by most game developers to stay visually competitive.
Of course, graphics aren’t everything.
But then again, movies stars aren’t ugly. :wink:

I’ve looked into Java3D a bit. But the lack of Mac support (and if memory serves its Linux support isn’t so hot either), I stopped. It doesn’t make sense to go with Java but then deny yourself one of Java’s greatest strengths, relative ease of going cross platform.

So what we’re all saying is, Java 3D needs more development?

Kev

There are many (2d and 3d) games out there which don’t need a high level 3d API to blit some nice 2d or 3d textured images to the screen.
So using Java3d for such purposes meant pure overkill.

On the other hand, there are many 3d “thingies” out there which really are very good to program if you use a high level API like Java3d. So using Jogl for such purposes meant pure “re-inventing of the wheel”. :slight_smile:

High level APIs are naturally general in some way and so don’t fit to every purpose. You won’t use a Quake style indoor engine for a flight simulator and the other way round.

I’d say: use the Java API which fits your needs best - as long as you stay with Java. :slight_smile:

Also, like Tortoise put it: because Java3d is currently only available to some platforms (but situation improves hopefully?) you’ve to consider this if you want to be platform neutral.

Generally, a low level API like OpenGL does not negate a high level API. And the other way round.

Actually I don’t know why this thread has been started. :wink:

Exactly, the world is big enough, everyone can take it’s favorite piece of cake (API). ::slight_smile:
J3D is high-level and JOGL-LWJGL are low-level access libs. Both have their use.

[quote]…I am just curious, if Zingbat and MisterX really thinks that Java can’t compete with C++ for real games…
[/quote]
…hmm…yes. I think that java will always be a little behind c++/c# technologies. However, i also think this distance is becoming smaller and smaller. (And i’m not making anything with c++ or engines nor anything like)
And now, let me ask you a question in return:
Why, if you’re so concerned about performances, didn’t you go with c# and managed DX by sacrifying multi-platform? Is it that important for you?! (the very large majority of end consumers are Windows after all, exept for special apps)

Personally, i have chosen java because of java3D, not the opposite. I found this easy api perfect for a hobbyist like me, to code is very intuitive with it and i like very much how it is structured. If j3d didn’t existed, i would allready be on c# and DX!

[quote] So what we’re all saying is, Java 3D needs more development?
[/quote]
It would definitely be a good thing if Sun turned Java3D open source and allowed developers to dig into it. I think mr Yazel’s Xith3D renderer may soon make the core functionality of Java3D obsolete though (we still need Java3D’s data structures since Xith3D uses those).

[quote] Why, if you’re so concerned about performances,
[/quote]
To say that I’m “concerned with performances” because I want to render 3D graphics and play sound at the same time on a consumer-grade machine is a bit of stretch I think. It is also you who seem to think that the statement “java will always be a little behind c++” means the same as “java can’t compete with C++”. Personally, I do value platform independence and productivity over a 1 fps performance increase and I think both those things make Java very competitive against C++.

I am not going into a language war with you about C#, sorry. I applaud Microsoft for making the C# effort and using its influence to legitimize JIT-compiled languages to skeptical audiences.

I’ve done a bit of C# and D3d, although only a little bit, and not only was it quite annoying to use but installing the DirectX9 runtime completely broke all the DirectX powered games I had installed and gave me no way to rollback the installation. That was quite annoying.

I have used Java3D for 4 years and I think it is a wonderful API. I think our project has stretched its capabilities to its limits. But there is no doubt that we pay a price for all that capability and generality. In fact I am just now beginning to realize how much work we went to over the years to circumvent the limitations imposed by Java3D.

After about 3 weeks of effort we are very close to being able to render Magicosm with the Xith3D engine running on JOGL.

A test scene:

Shawn is right… try to implement shadows in Java3d… pretty impossible. But we were able to implement dynamic shadow volumes in one day with Xith3D:

I think for gaming the perfect solution lies somwhere in the middle. A scenegraph is a great way to assemble your virtual world, but its not a great way to render overlays, particle systems, do dynamic lighting, shadows, reflections, render to textures for dynamic imposters, etc. Basically 90 percent of the tricks in the game developer’s tool box cannot be used in Java3D. Read Game Programming Gems I, II and III and then try to implement almost anything in there without access to the renderer and you are in for a heap of frustration.

Looking good already - the armour on the knight type dude is particularly impressive. The impression of them all having just appeared several miles above the ground made me smile as well…

I always thought it was possible to do many of the things you mention with J3D, it was just that the ways to do them just seemed to be clunking workarounds rather than elegant solutions.

I think there are some misconceptions about Java3d here. There is nothing in Java3d that can be considered a mistake or a bad design decision. You need to know the engine limitations, make some benchmarks to sound and graphics and design your game to stay bellow those limits.

So you like good lookings make your textures look good with 64 pixels wide, dont use too much textures. Its just a matter on how you do the textures.

For instance the last rock wall texture i made used an images of 512x512 pixels to work with the spray tools and all the other tools well. Also used three layers for: one for the rock texture, another for dirt and slime in the walls, another for deficiencies in the bricks; plus some other for give bright in some areas and relief to the bricks.
Finnaly the texture was shrinked to 64x64 pixels .png and it looks very good. I just avoid making simplistic tiles, these textures tile even if they are rotated at any angle. Tried it with a level but i need to had special textures with special corners, ceilling guides and floor guides for places where walls joins with ceillings and floors.

Sound is not good enough use midis not mp3 and sounds with a low sampling. Most sound cards with intruments banks and can play midi better than an mp3 and can also filter low sampled wavs to sound nicer.

OK you don’t have shadows or pixels shaders. Neither fallout or deusex or half-life or system shock or even thief. These are some of the greatest games that have been made and many people prefer them to some new games that are nothing more than visuals.

So you can’t use as much polygons as a C++ engine like Quake3 or Unreal2. This depends on the type of game you are doing. If it is a MMORPG the landscape must be very big. In that case use advanced lod techniques and benchmark the engine. If it is a dungeon crawl or a quake3 like game closed environment use lod to disable rooms that arent visible in the players proximity. Use different geometries for distance objects. Once the distance of an object from the player doubles you can lod it. Every polygon counts

Dont use brute force rendering with Java3D, thats what a scene graph is for. If you don’t take advantage of Java3D best features your game will crawl.

Look at Gothic 2 for instance. I have a 1Ghz cpu with a DirectX 8.1 card (low price). I can play with the max features at high but sometimes the game crashes to desktop because its pushing the limits. This is not just a problem of Java3D. The LOD in this game is amazing. You have distance LOD, interior and exterior LOD, once you enter an interior the fps rate rases considerably, but outside in the town it drops. For this you need a mix of several lod techniques and a good api with a scene graph like java3d.

The other aproach is to bind opengl to java and use the new hardware godies like shaders and everything that comes with OpenGL 1.4. Of course that if yiu want to do this, when you get your engine running OpenGL 1.5 is out and then its all over again. ;D

[quote] Sound is not good enough use midis not mp3 and sounds with a low sampling. Most sound cards with intruments banks and can play midi better than an mp3 and can also filter low sampled wavs to sound nicer.
[/quote]
So you are saying that because sound runs like crap, I should make the sound’s quality crap? No thanks.

[quote] OK you don’t have shadows or pixels shaders. Neither fallout or deusex or half-life or system shock or even thief. These are some of the greatest games that have been made and many people prefer them to some new games that are nothing more than visuals.
[/quote]
We are talking about technology, right? Then we are talking about 5 year old games. I’d sure as hell hope Java3D could match that. But here we are 5 years later, and guess what we can do a lot more. No reason we shouldn’t just because good games back then didn’t.

[quote] Look at Gothic 2 for instance. I have a 1Ghz cpu with a DirectX 8.1 card (low price). I can play with the max features at high but sometimes the game crashes to desktop because its pushing the limits. This is not just a problem of Java3D. The LOD in this game is amazing. You have distance LOD, interior and exterior LOD, once you enter an interior the fps rate rases considerably, but outside in the town it drops. For this you need a mix of several lod techniques and a good api with a scene graph like java3d.
[/quote]
You can solve this problem in many ways. Java3D doesn’t magically make it disappear.

[quote] The other aproach is to bind opengl to java and use the new hardware godies like shaders and everything that comes with OpenGL 1.4. Of course that if yiu want to do this, when you get your engine running OpenGL 1.5 is out and then its all over again.
[/quote]
At least I’d be using OGL 1.4 what’s J3D’s capabilities? 1.2? 1.3?

Hell, man, I’m not even anti-Java3D but you sure are making me wish I was.

I sense a religious war.

The problem with J3d is that it’s just a scenegraph that tries to “almost-kinda” be a low level renderer as well (they provide immediate mode rendering, after all). It’s way too high level for any kind of cutting edge development.

I’d MUCH rather use something like the Xith3d scenegraph/renderer than J3d.

Oh, and for crying out loud, j3d is slower than painting by hand and faxing the images to the user. :wink:

zingbat, although it is very kind of you to tell us all this, you are probably talking to some of the most informed Java3D programmers there are. And a bunch of well meaning incompetents like me :slight_smile: . Preaching to the converted doesn’t even begin to express it. So appreciate that pretty much everyone here takes most of what you have said in favour of Java3D pretty much as granted. I mean have you seen the screenshots of what David Yazel has achieved in Magicosm?

You’re not barking up the wrong tree, by any means, but if (as it seems) Java3d is going to die soon anyway, and if we can replace it with something more open that has all those “wouldn’t it be nice if” features or at least, being open source, enables us to add them if we want, then who is losing out? Ultimately, it will make it easier to put together the 3D part of the games we want to write.

It won’t mean that the 3D part is any more than 10% of the game engine and it won’t make it any quicker or easier to create the content or gameplay that will make it interesting, but after all, that’s the fun bit…

[quote]So appreciate that pretty much everyone here takes most of what you have said in favour of Java3D pretty much as granted. I mean have you seen the screenshots of what David Yazel has achieved in Magicosm?
[/quote]
Kill me if I’m wrong, but I thought Magicosm was using Xith3D (based on Jogl) now…

Not yet Markus, but soon.

BTW your Wurm demo is bitchin!