Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: 2D performance problems on: 2009-03-29 16:40:31
thanks Ill look further into Volatile images. The reason why I was a bit dismissive of the idea was after reading stuff like this:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4498974

Eg. Graphics2D will only be accelerated on linux using the OpenGL pipeline.
I went with java2d on purpose, because I want my game to be playable without a 3d card. I have experience using OpenGL for 2d (and 3d for that matter)
using lwjgl as well as using the native library directly from C.
I don't want to rely on acceleration but of course I won't actively hinder it either. Bitmask transparency not being noticeable quicker than translucent transparency just
had me a bit flabbergasted. Guess its because the underlying implementation supports X bit alpha channels and have no optimization for the 1bit alpha channel case.
Figured I might be doing it the wrong way hence this topic.

I apologize if my remark about creating the image every frame came off as arrogant, what I meant was that of course I don't convert it every frame Smiley

Kapta: I've been checking out Slick as well as the rest of Kevin's site. Great stuff and ill love to try it out for a future project but in this case it was a design goal
to stay with software rendering.

I'm used to doing 2d with libSDL and was expecting bitmask transparency to be as fast as opaque blitting (since there is no technical reason it couldn't be).



As of now I'm getting acceptable performance blitting the ground layer opaque and the other layers with bitmask transparency, but as you can see there aren't
that many transparent tiles in the screenshot.
2  Java Game APIs & Engines / Java 2D / Re: 2D performance problems on: 2009-03-29 06:31:39
yes im using bufferstrategy(2). On a canvas inside a JFrame under linux. Framesize is 800x600 and I render 27x20 = 540 32x32 tiles minimum each frame.
I've got a simple 3 layer setup: draw layer 1 opaque, 2 bitmask, entities (players and bullet) translucent, layer 3 bitmask. This gives me an acceptable framerate (60-80).
When I first posted this I didn't render layer 1 opaque but with bitmask (colorkey) transparency.

I know per pixel alpha is very slow in software but colorkeying should be just as fast or faster even (since you don't have to draw as many pixel as with opaque), thus I cannot understand
why there is such a dramatic difference between OPAQUE and BITMASK.. and such a small one between BITMASK and TRANSLUCENT.
I blit my tiles from one sheet image (an opaque for layer 1 and a bitmask'ed for layers 2-3) using drawImage(dst, 8 ints etc) (and im not unintentionally scaling, since rendering all tiles as opaque nets a 166+ FPS)
3  Java Game APIs & Engines / Java 2D / Re: 2D performance problems on: 2009-03-29 05:52:36
Thank you for your reply

I've read about volatile images, but I thought they didn't make difference without acceleration, especially under linux where you don't have the directdraw render path.
I don't want to rely on hardware acceleration to archieve a playable framerate, then i'd gone opengl from the beginning.
Just thought java2d was fast enough to blit a tilemap with colorkey transparency to a 800x600 window in software. Anyway i've begun blitting the first layer of tiles as OPAQUE and the rest
as BITMASK. Helps tremendously.
I still can't understand why simple on/off colorkey transparency isn't faster than per pixel alphablending.
An underlying RLE implementation should result in even faster colorkeyed blits than a straight copy.

Quote
Also, you don't want to create a new image every frame, do it once, then just draw on top of the image every frame.
Don't insult my intelligence good sir Wink
4  Java Game APIs & Engines / Java 2D / 2D performance problems on: 2009-03-29 04:27:21
Hello

Im having troubles getting decent performance out of a simple 2d tilescroller. Java alphablending with  translucent transparency is god awful slow, as expected.
What I want is simple colorkeying, eg defining a transparent color in the source. Couldn't find any direct way of doing that. Instead I read up on bitmask transparency.

Im loading image data from RGBA png files. So to get them ready for blitting I converted them like this:

1  
2  
3  
4  
5  
6  
7  
8  
            BufferedImage original = ImageIO.read(in);
            java.awt.GraphicsEnvironment ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
            java.awt.GraphicsDevice gd = ge.getDefaultScreenDevice();
            java.awt.GraphicsConfiguration gc = gd.getDefaultConfiguration();
            BufferedImage bim = gc.createCompatibleImage(original.getWidth(), original.getHeight(), Transparency.BITMASK);
            Graphics2D g2d = (Graphics2D) bim.getGraphics();
            g2d.setComposite(AlphaComposite.Src);
            g2d.drawImage(original, 0, 0, null);


To my horror this is for some reason just as slow as Transparency.TRANSLUCENT Sad
I tried reading img data from GIF instead in case Transparency.BITMASK only works for indexed colormodel, with no noticeable speed difference.
Besides i'd still like to able to use 24 color instead of 8 bit, and I don't think thats whats slowing it down either. I get flawless performance on 24 RGB with Transparency.OPAQUE.

What am I doing wrong? seems like java2d is doing per pixel RGBA blitting when I want it to use  BITMASK (colorkeying).

oh and is there anyway of using colorkeying specifying your own color key as a 24 bit RGB value? And can I even assume that the above code auto converts RGBA data from the png to
RGB + transparency bitmask?
5  Game Development / Networking & Multiplayer / Re: Player movement. on: 2009-03-23 15:37:19
if your client can't see the whole map at once, you should try and implement a sphere of influence system (or circle for 2D). Only send updates for the monsters within the clients sphere of influence.
If you're not already doing so you should also apply some sort of delta compression. If there are 10 monsters within a clients sphere of influence, but 5 of them are standing still, you only
need to send updates for the 5 which are moving.
6  Game Development / Networking & Multiplayer / Re: Eliminating jitter on: 2009-03-19 03:34:18
Guess I kindda solved it myself. Seems one can't do completely smooth movement in a window with java2d (at least using the linux implementation).
I've added a "local player" and I am applying frame delta smoothing and interpolation to both. Its still smooth movement for a sec, then a little jitter etc. Very bursty.
At least my networking code works since the remote player moves as smooth as the local one now.

if anyone can think of anything I haven't tried for doing smooth movement in a window with java2d, im all ears. Guess I should really be asking that question in the java2d forum though.
7  Game Development / Networking & Multiplayer / Re: Eliminating jitter on: 2009-03-18 20:27:16
Yes it makes sense. I've already tried that, was what I meant by "delayed client side interpolation", but the delay is a major problem with that technique, since the characters only starts moving when the first position update arrive from the server. Besides it still looked jumpy (what I did in more detail was constantly interpolating against the received absolute position over 33 ms (since my server tickrate/heartbeat is 30hz)).

Funny thing is, I tried sending the heading instead of absolute coordinates, I still get the jitter, even though the server only updates the clients heading vector, eg the movement is calculated using the usual scale by frame delta time on the client. I then tried running Kevin Glass's space invaders game (http://www.cokeandcode.com/spaceinvaders/si101.jnlp) and noticed that the movement of the player character is also jerky as hell (and that example is using frame delta based movement too).

Using delta frames works very well in OpenGL so i'm a bit puzzled why its so bad for java2d graphics. I think its a combination of regularly occurring FPS bursts as well as the cast of float values to int (actually displaying the graphics with java2d) which causes this.
I'd did a little more browsing on Kevin's excellent site and found this tilemap collision example demo: http://www.cokeandcode.com/collision/tilemaps/tilemap.jar

This demo exhibits much smoother movement albeit still a little jerky but a vast improvement over the 2d space invaders implementation. Curious as to why I looked at the code and found this snippet:

Quote
      long delta = (System.nanoTime() - last) / 1000000;
         last = System.nanoTime();
      
         // now this needs a bit of explaining. The amount of time
         // passed between rendering can vary quite alot. If we were
         // to move our player based on the normal delta it would
         // at times jump a long distance (if the delta value got really
         // high). So we divide the amount of time passed into segments
         // of 5 milliseconds and update based on that

         for (int i=0;i<delta / 5;i++) {
            logic(5);
         }
         // after we've run through the segments if there is anything

         // left over we update for that

         if ((delta % 5) != 0) {
            logic(delta % 5);
         }

Which imho is a quite brilliant implementation of frame delta smoothing. Far as i understand I would get the same result by keeping the last 5 frametimes in a buffer and averaging them, so its a clever way of averaging the frame delta over time.
Now I'd love to apply this technique to my game, but since i'm running the movement on the server and sending back absolute coordinates I don't use the delta for anything client side.

What I could do is apply this to my server movement, but I thought using a Timer/Timertask at 33 ms intervals (1000/30) would guarantee a somewhat steady 30hz tickrate. Can anyone confirm this? and do you guys think it would be good idea to calculate delta time (and smooth the values) on the server? (even though its supposed to run at a fixed rate).
8  Game Development / Networking & Multiplayer / Eliminating jitter on: 2009-03-18 04:01:26
I have implemented a simple client/server multiplayer "move-a-dot" game.
I currently do all the simulation server side. Client sends keypressed, keyreleased messages. Server updates simulation 30 times a second and sends out a packet
to each client containing absolute positions of all clients.

Now when I run this I get horrible jitter and it isn't due to lag (on my own machine I can easily increase the tickrate to 60hz without problems).
First I thought of simply doing some delayed client side interpolation, but it doesn't work that well since player movement on the client is initiated when the server
starts spewing position packets back. (its a glorified telnet client Smiley )

I am using TCP (naggle off) but can't see how changing to UDP would help since my client is capable of receiving 30 packets a second quite well, at least running locally.
After searching this excellent forum for similar issues my question is this:

Is there an easier way to get rid of this problem other than implementing full client side prediction/dead reckoning?.

Now I don't mind learning to implement the aforementioned techniques but it was my impression that they were only seriously needed for game state updates occurring less than 20 times a second?.
In other words am I missing some obvious way of eliminating the jitter?

Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (54 views)
2014-04-15 18:08:23

BurntPizza (52 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (150 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!