Skip to main content
GameDev.net gamedev.net
🔒 Locked

Java2D vs SDL

Started by adam_ Mar 13, 2004 at 7:48 PM 7 replies 2.9k views
Original Post
adam_
adam_
I was playing with java a bit and was working on a small game when I decided to check what numbers java was capable of working with 2d. I used a 640 x 480 pxl window to test. 32bit colors. SDL managed around 600 fps when only blitting a very small image. Java managed a whooping 200000+ fps.. I used the same way to check fps. Only the timer was different. SDL used SDL_GetTicks() and Java used System.nanoTime(). I know that using OpenGL on the same machine in the same way results in about 5000fps. How can this be possible? Shouldnt c++ be way faster than java? And Java2d supports stuff like scaling,rotating and the likes so if it can substain those kinds of fps doing that, thats just scary Machine tested on was amd 2500+,512mb, ati 9500pro. Java applet was run in appletviewer. SDL app was using SDL_DisplayFormat on image. Can these results really be true?
Deranged
Deranged
well SDL_GetTicks() checks in milliseconds and System.nanoTime()

checkes in nanoseconds so they are a whole your java time/~10-100 off.



typedef unsigned long long int me;
typedef signed short char you;
adam_
adam_
Okey I am stupid. Or java is
I had my fps counting code in the gameloop and not in the update function.
Java wont redraw the screen every time you tell it to, so 1000 times around the gameloop can result in the screen being redrawn 10 times. thats why I was getting strange fps ;P

But looking at the Java2D demo that comes with the sdk it does look good, scaling,rotating and more and decent fps.=)
hplus0603
hplus0603
1000000 nanoseconds == 1000 microseconds == 1 millisecond = 0.001 seconds.
enum Bool { True, False, FileNotFound };
Deranged
Deranged
so basicly the java prog is really running 200 fps. and the opengl app is running 500 fps



typedef unsigned long long int me;
typedef signed short char you;

[edited by - DerAngeD on March 13, 2004 9:48:06 PM]
adam_
adam_
Actually I did take that into account so the way I was counting fps was correct I was only doing it at the wrong place in the Java app.
OrangyTang
OrangyTang
quote:
Original post by adam_
Java wont redraw the screen every time you tell it to, so 1000 times around the gameloop can result in the screen being redrawn 10 times. thats why I was getting strange fps ;P

Sounds like you''re using a regular Swing component - automatic double buffering, but because it common use is application GUIs with lots of static graphics paint requests tend to get queued up and batched together.

Instead use BufferStrategy for a video memory double buffer which is under much tighter control.
Reaper_Unreal
Reaper_Unreal
I''d suggest that you take a look at the [URL=http://www.wildtangent.com/]WildTangent[/URL] libraries. It''s a great little library, the latest revision will even let you do some 3D. The few games that I''ve seen made with it looked pretty good. It''s definately faster than the standard java libraries, but you can still write games in Java. You ould also use C or C++. It''s pretty cool, if you''re serious about making games in Java, take a look.

She walked into my office like a centipede with 98 missing legs.
She walked into my office like a centipede with 98 missing legs.
yspotua
yspotua
quote:
Original post by Reaper_Unreal
I''d suggest that you take a look at the [URL=http://www.wildtangent.com/]WildTangent[/URL] libraries. It''s a great little library, the latest revision will even let you do some 3D. The few games that I''ve seen made with it looked pretty good. It''s definately faster than the standard java libraries, but you can still write games in Java. You ould also use C or C++. It''s pretty cool, if you''re serious about making games in Java, take a look.

She walked into my office like a centipede with 98 missing legs.


Be careful downloading Wild Tangent, it installs ''usage monitoring'' software that many classify as spyware.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.