Converting C++ directx code to Java, easy?

I have a pretty ok codebase in Java now but would like to speed up my drawing. I am currently using pure swing so I am totally platform independant. I have contact with a company that hold a good graphics engine written in C++ using DirectX.

Also, by the way I have 7 years experience in Java but only 1 year experience in C/C++

So, my question is what would generally be easiest?

  1. Convert the C++ code to Java
    or
  2. Use my existing Java code and build my own graphical Java code for openGL or DirectX
    or
  3. Convert my whole codebase to C++ so I can use their Graphics

Please motivate your answer, this is a big decision for me to take :slight_smile:

Stick with Java. Use Slick. Easy conversion from Java2D. Very fast. Works on Mac and Linux.

BTW, this thread needs moving to an appropriate forum topic :wink:

Cas :slight_smile:

just about slick, how much datas does it supports for resources? Does an amount of 50MB of graphics data resources support a slick implementation to Game-Animations? ???

Depends on what your codebase does and how many lines of code are in the different parts. I would stick to java and try to separate the rendering code form the rest of the application by refactoring. Try to do it with minimal effort, just to get a feeling of the connection points of your rendering code and your app logic. Do not try to make a general rendering abstraction.

After that you can investigate the needed functionality of your rendering code and decide what would be easiest for you to do. A fourth option might be to convert your rendering code to C/C++ and just create a native binding using JNI or by compiling your code with GCJ and use CNI. But I guess the easiest would be to convert your rendering code to either Slick, LWJGL or JOGL and discard the C++ engine completely.

Downloaded these 2 packages
lwjgl-source-1.1.zip
slick.zip

and extracted them in the correct path and tried using Slick.

There are still source files missing when I try to import
for example

import org.lwjgl.opengl.GL11;

By the way I am using Java 1.4 still (because my JDE does not support newer Java) now if that would have anything todo with it.

you shouldn’t need to download the lwjgl source jar, the full slick download comes with all the dependancies its needs (unless you are using an OS other than windows in which case you’ll have to grab the natives for that version of lwjgl), you just need to add the lwjgl.jar to your external jar path.

You are correct, the JWGL is inside the Slick. But regardless, both the jar files and the.Java files misses classes like GL11 for example. I placed all jars in the same place where I placed Jogg and Jorbis jars that I used from before but I cannot import certain classes because they do not exist.

Also, downloaded GL11.java from the Internet but when I compile I get

“GL11.java”: illegal character: \64 at line 717, column 22"
“GL11.java”: expected at line 717, column 50"


errors everywhere

example of methods that give error.
void glAccum(@GLenum int op, float value);

don’t think you need GL11.java to use slick, GL11.class should be in the lwjgl.jar at org.lwjgl.opengl.GL11.class

Doing openGL means switching to at leist a AWT Canvas. So wondering, has anyone tried mixing openGL with Swing? I have a JFrame which contains 3 swing JPanel and where my map and drawing is done in the center one. So one northPanel, southPanel, centerPanel

Is it possible to have the openGL canvas in center while still using Swing components in the north and south without them interfering with each others because that would be GOLD and means the switch from Swing to openGL would be much easier.

I have used LWJGL sucessfully in a Swing app at some point, although I can’t remember the exact details. Putting a lwjgl canvas in the middle of a border layout worked just fine. ;D

http://members.gamedev.net/tang/Images/SwingGui.png

Wow, that was a quick reply!
So you were able to mix them, that is great!
That is also what I intend to do on my project if I switch to openGL since the Swing UI is fast enough so I want to keep the advantages of the already built Swing components to not have to reinvent the wheel :slight_smile:

you will have to call JPopupMenu.setDefaultLightWeightPopupEnabled(false); at some time, so your popup-menues appear in front of the canvas.