Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java 3D for fast 2D painting?  (Read 3140 times)
0 Members and 1 Guest are viewing this topic.
Offline Andi

Senior Newbie





« Posted 2007-06-03 07:04:40 »

Hi,

We are writing a music notation program, which uses of course only 2d images (drawn as quads with textures, because it's much faster than Java 2D). At the moment our library is JOGL, and it works great.
Now we have a little problem with some Vista systems which don't have OpenGL video drivers up to now. So we thought about adding a Direct3D output.

I noticed that Java 3D supports both OpenGL and DIrect3D, so that's great. I can write on a higher abstract level and Java 3D does the low level job for me.

My question: Is Java 3D ok for our purpose? I mean, isn't it too high level? Before we rendered thousands of symbols very quickly with some OpenGL, now it seems that I hav to create a Java object for each symbol? That is quite a lot of overhead. Or should I use the pure immediate mode, which is - hopefully - much faster?

Thanks  Smiley

Andi

Slam Soccer 2006 - The free football game
Offline CommanderKeith
« Reply #1 - Posted 2007-06-03 07:15:55 »

Have you tried Java2D and its various pipelines?  There's a an OpenGL pipeline that uses immediate mode OpenGL (which I've heard is is as fast as JOGL in immediate mode) as well as a software mode pipeline, as well as the D3D pipeline, though this D3D pipeline is quite hopeless at the moment, though it will be as good as the OGL one (very fast) when they release Java 7 (or maybe in the Consumer JRE update which will be an update to Java 6!!).

While I've never programmed in Java3D I've found that it (and LWJGL and JOGL) often don't work for whatever reason. 

If I was you I would use Java2D's OGL piepline (VM argument '-Dsun.java2d.opengl=True') and if there are driver troubles then use the software pipeline (-Dsun.java2d.noddraw=true).

Best wishes,
Keith

Offline Andi

Senior Newbie





« Reply #2 - Posted 2007-06-03 08:17:40 »

We need the high speed and tested Java 2D on many machines, it is much too slow on older ones. Maybe it works on today's computers, but we want to support some older (lets say, from 2000 on or so) machines too, and our tests showed, that it is too slow.
Even when Java 2D internally uses OpenGL or Direct3D, we believe that it is not as fast as our own implementation, because we know where certain things can be optimized while Java 2D has to "guess", and we need the full control (e.g. the "hope" that Java 2D will manage the textures in the right way is not enough for us).

Java 3D: I can only say that the examples work fantastic (e.g. the HelloUniverse runs at 3000 FPS with Direct3D and with 1000 FPS with OpenGL - who said that Java 3D with Direct3D is slow? Wink ).

I just wondered if Java 3D is a too big overhead for our purposes, and if there is a project like JOGL but for Direct3D?
If not, we will use Java 3D and try to avoid all unnecessary overhead.

Is the immediate mode the right way for this? Are there any good tutorials which show how to get best performance out of Java 3D (if necessary, by ignoring all its features like the scene graph?). Thanks!

Slam Soccer 2006 - The free football game
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline keldon85

Senior Member


Medals: 1



« Reply #3 - Posted 2007-06-03 08:56:06 »

If Java2D is fast enough for gaming I'm sure it's fast enough for notation; it sounds like you are doing something wrong. And though DirectX is supported in Vista, it is not supported outside Microsoft platforms such as Mac, or Linux. And don't conform to Microsoft's OS bashing, it's just plain unfair on everyone else  Cry

And you are aware that there is no such thing as 1000FPS, let alone 3000FPS; your monitor has a maximum refresh rate which is usually around 70-80FPS. That figure is no depiction on the performance of either library, and experienced graphics coders often find little (if any difference). When you begin to render full scenes you will most likely find OpenGL outperforming DirectX as Sun appear to have put more effort into it - which is no surprise as DirectX conflicts with their "cross platform" concept.

But nonetheless your implementation seems a little faulted, are you using the appropriate double buffering routines, and accessing the graphics properly ... i.e.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
         // initializing
       int offset = 0;
        int buffer[] = new int [width*height];
        int scansize = width;
        MemoryImageSource _source =new MemoryImageSource(width ,height,_buffer,offset,scansize );
        _source.setAnimated(true);
        _source.setFullBufferUpdates(true);
        Image _imageBuffer= Toolkit.getDefaultToolkit().createImage(_source);
        // setting pixels
       _buffer[x+y*width] = colour;

        // updating
       _source.newPixels();                      // will copy _buffer to _imageBuffer

Buffered images are slow; in fact I was able to draw (shaded) perspective correct texture mapped polygons in software far quicker than I could copy the data to a BufferedImage. And the methods making use of the raster sometimes do not work as the format being used might be byte instead of int.

Offline Andi

Senior Newbie





« Reply #4 - Posted 2007-06-03 09:08:51 »

Thanks for the reply, but, sorry, I have never seen a good game written in Java 2D. Do you know one, that proves your statement?

Perhaps it's all possible in Java 2D... I am not somebody who wants to spend nights over optimizing pieces of code, I am a programmer that want to develop a music notation software (music notation is the main topic, not optimizing some output engine).

The reason why I think about Java 3D is the following train of thoughts:

- OpenGL works great (JOGL would be the solution!), the method works, it allows even 3D effects later (not possible with Java 2D)
- But: Vista (arrgh! I hate it, but many people have it, so I can not ignore it) does not support OpenGL from the beginning, so there must be OpenGL drivers from the video card manufactures. There are still machines without OpenGL support (example: a notebook from Dell with Intel GMA 945, which is quite common)
- Idea: Vista certainly supports DirectX.
- Idea: Use OpenGL when possible (all OSs but Microsoft's...), and DirectX otherwise.
- Try to find a library for DirectX -> not found.
- Try to find a library for OpenGL and DirectX -> found: Java 3D.

If there is the possibility to do the same things with Java 2D, I will try it immediately (really, I'd like to avoid that enourmous Java 3D overhead). But I have seen no demo that shows the great speed of Java 2D yet...

Slam Soccer 2006 - The free football game
Offline Andi

Senior Newbie





« Reply #5 - Posted 2007-06-03 09:37:42 »

And though DirectX is supported in Vista, it is not supported outside Microsoft platforms such as Mac, or Linux. And don't conform to Microsoft's OS bashing, it's just plain unfair on everyone else  Cry

I never said that DirectX will be the only output engine... DirectX is an addition for Windows/Vista machines with no or bad OpenGL support. In fact I don't like DirectX, but I can't tell my users that they must buy a new Linux computer...

Slam Soccer 2006 - The free football game
Offline Andi

Senior Newbie





« Reply #6 - Posted 2007-06-03 11:23:47 »

I just noticed a problem: The immediate mode seems not to be implemented for DirectX at the moment Sad Is it planned for the future?

I'll have to try the retained mode, lots of overhead...

Slam Soccer 2006 - The free football game
Offline keldon85

Senior Member


Medals: 1



« Reply #7 - Posted 2007-06-03 12:38:49 »

Runescape runs entirely in Java2D (or did last year); in fact here are a few others:
 - http://www.idx3d.ch/idx3d/idx3d.html
 - http://www.cs.cf.ac.uk/Dave/JAVA/3d/3d.html
 - http://www.albatrossdesign.com/products/java_viewer/
 - http://mrl.nyu.edu/~perlin/experiments/render/

Or for a more complete list:
 - http://www.garybeene.com/3d/3d-pure.htm

Offline Andi

Senior Newbie





« Reply #8 - Posted 2007-06-03 13:43:26 »


Wow, this one is indeed astonishing. I'll have a further look on it. Thanks for the links!

Slam Soccer 2006 - The free football game
Offline keldon85

Senior Member


Medals: 1



« Reply #9 - Posted 2007-06-03 14:12:07 »

Wow, this one is indeed astonishing. I'll have a further look on it. Thanks for the links!
That's exactly what I thought. I was thinking for ages that Runescape ran Java3D through 1.1, but Java3D wasn't bundled with the old Java runtime environments. Then I realized that my code spent more time copying to buffered images than it did creating them.

But it could be your painting scheme or some really obscure speed issue with an API call that shouldn't really take any time that is making Java2D seem slower than it should be.

But do keep us all posted, I would like to see how the notation software turns out, especially being a musician and all.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #10 - Posted 2007-06-03 19:36:01 »

The only reason that OpenGL is not working on Vista is because the card manufactureres haven't caught up yet.  Woogley had the same issue, but he fixed it.  Check out this for a possible answer http://slick.javaunlimited.net/viewtopic.php?t=429.

If you want a little easier time using OpenGL, you can look at Slick.  I is a 2D library to make it easier to do 2D in OpenGL.

http://slick.cokeandcode.com/

Also, there is PowerTab http://www.power-tab.net/ although it is geared specifically for guitars.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!