OpenGL 2D accelerated game... how?

:slight_smile:

Hi, this is my first post here, I’m braziliam, I study computer science and I work with web apps development using Java and Struts with database Oracle…

I’m making efforts in learning games development, with success (I have successfully made a nice Tetris), and I want to go deeper into this stuff…

;D

I already know how to use FullScreen Exclusive Mode API, BufferStrategy, and also Graphics2D and so…

But now I want to know: how do I use JOGL to make a hardware accelerated 2D game? I just want to use it like someone uses DirectDraw… to render 2D screens using a double buffer…

The problem is: with FullScreen Exclusive Mode API, the use of transparent images (like PNG or even a translucent BufferedImage) makes the game extremely slow, what makes me believe that such images aren’t hardware accelerated, but if I can use OpenGL to accelerate the rendering process it won’t be a problem and I will be able to use heavy images to make a wonderful, imaging-rich game.

Then… how do I make it?

Thanks!

:wink:

It’s probably going to worth your while to have a read of the Red Book, paying particular attention to material on using an orthographic projection.
You’ll probably also learn a lot just by hacking around with the JOGL examples.

On the other hand, you could continue to use Java2D and simply wait for the OpenGL pipeline to become widespread :slight_smile:
At any rate, good luck!

Thanks for the hint.

Is this orthographic projection easy to use for what I want?

About waiting for the OpenGL pipeline to become widespread, it would happen just within new versions of Java, right? So it may not be such a good idea, because nothing guarantees that it will happen already in Java 6, and besides that, it will take a time for the new version become widely used… it’s probably better to wait before using it… (am I wrong?)

An ortho view is easy - it’s just a view matrix setup so you don’t get objects shrinking as they move further away. You don’t even have to know how to tinker with the matrix, it’s just:

glOrtho(left, right, top, bottom, near, far);

Eg. for 800x600 you’d probably have:
glOrtho(0, 800, 0, 600, -1, +1);
which gives you one unit per pixel. You might want to look at the space invaders tutorial/source here: http://www.lwjgl.org/demos.php which shows you all the basics you need.

:smiley:

This is great!

Thank you very much!

:wink:

I’ll see it and if I have other questions I ask…!

Even Java-5.0 included the OpenGL pipeline, although that one delivered with java 6 performs much better and is much more stable.

lg Clemens