The move to JOGL

Just in case anyone is interested, I’ve moved my stuff over into JOGL from Java2D. Its here,

http://www.cokeandcode.com/astroprime

I’ve actually put together an abstraction layer which can be implemented in Java2D or JOGL, so hopefully I can always swap back if needs be :wink:

Kev

It does look a lot better with JOGL than with Java2D. Although in the JOGL version there is a problem that the keyboard locks up when you have more than two buttons down. So you cant fly, turn and shoot at the same time unlike the Java2D. Still very nice. Have you found it easier or faster to develop with JOGL or just better due to the things openGL can do? Also why did you decide to use JOGL instead of something like LWJGL?

[quote]Although in the JOGL version there is a problem that the keyboard locks up when you have more than two buttons down. So you cant fly, turn and shoot at the same time unlike the Java2D.
[/quote]
Works fine for me ???

Thanks for the responses:

JOGL shouldn’t have any effect on the keyboard. Its infact using the same routines it was before. JOGL might be overriding the AWT thread more… what platform/driver/OS etc… I’d really like to look into it.

JOGL was harder to work in, since I spent time wrapping GL. Hopefully I won’t have to do that again. I’ve not really got any great benefit as yet. I thought I could use Alpha on more platforms with JOGL, but it turns out MacOS isn’t properly supported yet. It does seem to be far far far faster than using Java2D tho :slight_smile: It also took me 2 evenings to get a generic texture loader written that I could use for my sprites. :frowning:

I didn’t use LWJGL simply because it seems to be in flux (excuse the pun) at the moment. Didn’t want to learn into something that was changing. Although it seems JOGL is going to be changing constantly.

So far, so good. JOGL is relatively easy to work in. I’ve my abstraction layer in place, so I can get back to Java2D nice and quickly if needs be :slight_smile: Been focusing mostly on network code recently, reakon I got it down now. Onto actual game play…

Kev

I guess the keyboard thing could be just me. Im running Win2k service pack 4 and jdk 1.4.2 In the Java2D demo everything is fine but in the JOGL emo they keyboad locks up and the pc starts giving me the error beep, when I have more than 2 buttons down.

Oh also what do you mean exactly by a generic texture loader? How does it work? I though the ship was an image and the starfield and cannon fire were just drawn with Java2D or JOGL.

The ship, stars and cannon fire are images actually. But in JOGL there is no concept of an Image. Everything is a textured piece of geometry. Whats more its not in a standard Java Image format, its a byte encoded data buffer.

Now, there had been a few texture loaders for specific file types publicised but I have quite a few different requirements. So it took me a while to write a loader that could load any image I wanted, convert it into a texture to be used by JOGL to create a sprite.

Kev

What is the significance of having a byte encoed data buffer over a gif or png image type in your situation? I take it you first made the sprites in a regular paint program and then converted the image to your specific type through an encoder that you wrote?

I did start a paint package, but I saved my images as PNG or GIF. The byte encoding is how JOGL expects to recieve textures/images. I load up my standard images with ImageIO, which gives me a BufferedImage. However, JOGL doesn’t know anything about BufferedImages, all it knows about its a byte array full of bytes in a certain order. This is where the conversion comes in:

BufferedImage -> JOGL Byte Buffer

Kev

Could you put that code online? I am trying to do the same stuff, but it’s stupid to reinvent everything or even steal it from someone :wink:

thanks!

Sure, actually its already online…

http://www.cokeandcode.com/jogl

Fraid you’ll have to do a bit of hacking to remove my “GameFrame” and just pass in GL instead.

My stuff is all bounds to my 2D graphics abstraction at the moment. Going to implement the Java2D version soon I think, just to do a comparison.

Kev

Kevin;
FYI, It locked my screen the first time I tried to launch via webstart(After it went into fullscreen) After that It didn’t give me the option to run in windowed mode.
It did start drawing the menus, but all i saw was red rectangles.

Thought you’d like to know. S3 SavagePro ddr card.

Been having reports like this all the time, just seems that JOGL/Java ain’t that happy on alot of platforms.

I’ll be adding the Java2D version tonight/tomorrow so hopefully you’ll be able to play in that :slight_smile:

Kev

Incidently, if you want to switch it back into windowed mode (normally you’d do this from within the game), but if you look in your home directory,

C:\Documents and Settings\username on newer windows systems.

You’ll find a directory called .astroprime. It has a client.props file which contains all the settings. Just set fullscreen option to false.

If you get a chance, I’d appreciate you seeing if it works in windowed mode.

Kev

Well, interesting, I’ve swapped back to using Java2D (well, really just implemented a new version of my abstraction). I’m fraid there won’t be a Java2D version any time too soon (probably wait for 1.5). Just doing the basics of my game on a relatively decent machine with a fully accelerated graphics card and 64 meg of memory I go down from an easily sustainable (fixed) 100 fps to around 54.

Although this wouldn’t be terrible, its only the very basics of my game. It also takes so long to draw the screen it has a minor effect on network comms. Although I still think Java 2D has its place, I can’t imagine using it for fast paced actions games ever again.

Kev ‘Possibly Converted’ Glass

PS. I really would appreciate someone pointing out what i’m doing wrong. I’ll even post my embarrsing code if you want…

I have changed the Texture-Classes a little bit. They don’t need the GameFrame Classes anymore. And I fixed a bug with images that have a width/height that’s not a fraction of 2. You can find them there:

http://www.informatik.uni-oldenburg.de/~troggan/bodo/Texture.java
http://www.informatik.uni-oldenburg.de/~troggan/bodo/TextureLoader.java

Thanks again for that, its made my considerably easier. About the red textures btw, just ensuring that I’m asking for the right mode seems to have fixed the problems I’ve seen… but then I can only test it by turning off acceleration of my laptop…

Kev

Could you be more specific on what you changed? Now we have the 2 things fixed :smiley:

I actually saw it in that code you set me…

GLCapabilities cap = new GLCapabilities();
cap.setRedBits(bpp/4);
cap.setGreenBits(bpp/4);
cap.setBlueBits(bpp/4);
cap.setAlphaBits(bpp/4);

then initialise the canvas with this capabilities.

I detect the bpp from the graphics device with getDisplayMode().getColorDepth().

Everything seems to be happy after this, will test again on monday on the work (low spec of doom) machine.

Incidently, my stuff goes down to around 20 fps with no graphics acceleration at all.

Kev

I tested that with an old Matrox Card, but I saw only Red Boxes ???..hope you have more luck with it.

Damn it, my problem is I don’t have anyway of testing the red box thing relyably.

Kev