basic skeleton for 2D rendering loop

Hi there,

I’m looking for some very simple example of an rendering loop
done the “right” way for a 2D based animation (say a square black
rectangle boucing in a windows).

I’d like it to run in a window (no fullscreen mode) and under Linux,
and using only the base API (no 1.4.2 unsupported sun.misc.* etc.).

The thing is : I don’t know which method I should use
to “paint/repaint/ redraw” what…

It can be Java 1.4 if it changes something in a Window (I know
that for fullscreen you need 1.4, but here it’s only inside a
Window).

I don’t care if the drawing is not synchronized with the vsync (can
it be anyway inside a window ?).

I’d just like to have a loop that is somewhat “efficient”.

Can anybody help by providing a link or a very simple example
that would run under Linux ?

Thanks in advance,

Jean

Did you want accelerated (active) rendering or just normal AWT event based rendering?

Kev

Hi there,

well I don’t know if I should use accelerated or not… I have two more
questions now.

Is it possible to have accelerated (active) based rendering
inside a Window (and what do I loose then) ?

Is it possible to have a decent animation inside a Window (it is
for animating very few objects (two to tree moving at the same
time) while still using awt ?

It is to do some “finetuning” / variable testing… What I would really
like is to have one “panel” (say the left animating a few sprites)
and another one (say at the right) being a “real” panel, in which
I can modify textfields / slidebars /etc. to modify the parameters
and see the result in real time on the sprites moving in the other
panel. But I can do this in another way (like using only one “panel”)
if this is too jerky.

Actually a skeleton of both ways would help me greatly to
understand what’s suppose to be going “under the hood” :slight_smile:

But I think that for my simple need and for a start, I need an
example of an non-accelerated “awt” rendering loop (what tricks
are there to get better performances ?).

Thanks for your answer,

Jean

http://www.amazon.com/exec/obidos/tg/detail/-/0735713634/qid=1065224811/sr=1-7/ref=sr_1_7/104-0844276-1871118?v=glance&s=books
I found this book in my local Barnes and Noble and in the first chapter there is a very good description and code of a proffesional gamming loop. Even though the book is in C++ if you have any Java experience you wont have any trouble understanding the code. Most of the Barnes and Noble that I have been to now have a game development section in the PC section so you shouldn’t have trouble finding and reading it. I am working on my own variation of it and will post it when finished. Also
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Tuning;action=display;num=1058296748
This post by Marcus_Persson should give you a start.

I can tell u what i did, first read the sun tutorials, change the tutorial codes and try to understand the basic awt framework, try to understand the different kinds of images ( auto, buffered, volatile, etc. ), it was hard for me to understand it, but once u get it, its easy.

Its easy to dray 500 images in less than 4000µs

dont expect to get a professional 2d rendering loop in 1 week, it may take months or years.