A scene based 2D graphics library for Java

Hi,

I have written a new library called Scenic. Scenic is a scene based 2D graphics library. It uses DirectX 9.0 for rendering and uses JNI to access DirectX. The library is mostly written in Java, but lowlevel rendering is done with c++. Because the library uses DirectX, it works only on Windows. The library is less then a month old, so it has not been tested a lot.

Please visit the homepage at:

http://users.tkk.fi/~jitulkki/scenic/java/

You can run a demo by clicking the following link:

http://users.tkk.fi/~jitulkki/scenic/java/scenic.jnlp

I have tested the library only on Radeon 9500 so there is no guarantee that it will work on other cards. Currently the library does not use vertex or pixel shaders, so it should work with quite many cards. You need to have DirectX 9.0 installed.

I will propably make big changes to the library so there is no point in writing a documentation yet. I have not published the source code, but will possibly publish it some time.

Seems to work - though nothing is displayed until I do a maximize followed by a restore (back to a window).

This is on a Geforce 6800 dual monitor system

Sad, since its windows-only developers need to decide to platform-lockin at design-time withought a great chance to escape the trap later :frowning:

First I tried to do this on Linux using jogl but I could not get hardware acceleration to work with jogl. Then I tried to do it on Windows using jogl, but rendering to textures didn’t work. So I decided to write my own native library using DirectX. I chose DirectX mainly because it is simpler then OpenGL with all extensions. The fact that it doesn’t work on Linux doesn’t bother me much because I could not get hw-acceleration to work on Linux under Java. I also think that Linux needs to mature more on the 3d front before it is really usable (for normal people). For example I remember how I searched the web for a month before I found a patch to make the ATI driver to work with my agp chipset.

Well but thats ATIs fault, their drivers are (known to be) crap.
With my nvidia-card I start the installed, change “nv” to “nvidia” and I get hw accerlation.

However, easy cheesy.

I’ve changed the library so that it should work with nvidia cards wihout need to resize the window. I’ve also added initial documentation. The jar files are available if someone wants to develop stuff using the library.

I also implemented round joints and square and round caps. The antialias demo uses a new pattern for testing antialiasing. The library implements high-quality polygon antialiasing using common hardware. The algorithm is analytic, so there is no need for supersampling. Unlike some simpler algorithms this algorithm does not enlarge the polygons, and it should work well even for polygons that contain fine detail.

Nice work!
It works quite well with my P4 PCI-E GeForce 6600 GT.
Are you going to release the win32 src code too ?

Mik

Granted I have not looked too deeply into DirectX because I hate the idea of being locked into any one specific platform (especially Windows!), but from what I see it’s pretty similar in terms of level of difficulty! Could it be, maybe, that DirectX is just what you know and have chosen to stick with it? Not that that’s wrong! ;D

Then I must be a bloody genius because I am writing a LWJGL based application than runs under Linux for work! ;D

But seriously, if platform dependance is not a big deal for you then cool, but I fear that you have severely limited the number of people who are going to use your library!

I think it would be nice to have the library work on Linux. Like I said I could not get hardware acceleration to work with jogl on Linux. I also tried writing my own native library but with no success if I used AWT. Without AWT things work fine, but it is more complicated to implement and less flexible for the user. The problem seems to be that the window that AWT creates does not have the correct visual. One solution is to create a child window which has the correct visual. However then the AWT-library does not receive repaint notifications from the X-server so it is not a very practical solution.

You could try the Light Weight Java Game Library (www.lwjgl.org), I am using their AWTGLCanvas and it works beautifully!

The source code is now available from the homepage

http://users.tkk.fi/~jitulkki/scenic/java/

The source package contains an eclipse project. The native c++ code is compiled with Microsoft Visual C++ 6.0.

What would be useful is to develop a well designed and simple 2D API on top of LWJGL that would compete with the simplycity fo Java2D. I know SPGL but I think there is almost no documentation and it doen’t seem to be actively supported.

I ported the code to X / OpenGL. I found a way from lwjgl source code to make OpenGL work with AWT. The OpenGL code works only on Linux, on Windows I still use DirectX. I access OpenGL using my own native code instead of using lwjgl. This is easier since I can share a lot of c++ code between the DirectX and OpenGL renderers.

The OpenGL renderer uses the GL_EXT_framebuffer_object extension. I could not get pbuffers to work with my ati drivers, however the framebuffer extension works fine and is a lot better choice. You will propably need quite recent drivers though.

You can try the Java Web Start demo from the home page: http://users.tkk.fi/~jitulkki/scenic/java/

Hello again,

I have released version 0.9 of the library.

Major changes in version 0.9 include:

  • Added square, radial and conical gradients.
  • Added line dash patterns.
  • Added support for multiple simultanious canvases.
  • Added zooming and scrolling to the demo.
  • Changed Shape and Brush classes to be subclasses of SceneLeaf.
    This makes the library more flexible.
  • Added short descriptions for all public classes.

The library is now hosted on java.net at:

https://scenic.dev.java.net/

A java webstart demo can be launched by clicking the following link:

http://users.tkk.fi/~jitulkki/scenic/java/scenic.jnlp