Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Java Tile Engine Super Slow


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
23 replies to this topic

#21 fourpak   Members   -  Reputation: 100

Like
0Likes
Like

Posted 16 October 2011 - 06:43 PM

Just had to comment that this thread helped fix MY stupid little code problem which was making me crazy. thanx!


Anyway, I ran across an article describing a speed issue in Java itself which may or may not be applicable
to the original poster or may no longer exist in java7 but here's the link anyway:

http://www.jhlabs.co...ged_images.html

It describes how certain methods can confuse Java's handling of hardware acceleration:
-Raster.getDataBuffer()
-BufferedImage.getRGB()/setRGB()
-BufferedImage.getSubImage()
-Attaching an ImageObserver to a BufferedImage
-Filtering a BufferedImage with FilteredImageSource

Man, seems like the more i learn the less i know!
Strong typing is for people with weak memories.


Sponsor:

#22 jameszhao00   Members   -  Reputation: 271

Like
0Likes
Like

Posted 16 October 2011 - 07:56 PM

Have you profiled your code? (http://www.yourkit.com/ for example)

By the way, the following change halved the frame time on my computer (after taking into account the 10ms sleep delay)


In Level.java
// create blank camera canvas
cameraImage = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()0].getDefaultConfiguration().createCompatibleImage(SCREEN_WIDTH, SCREEN_HEIGHT);
//cameraImage = new BufferedImage(1280, 768, BufferedImage.TYPE_INT_ARGB);
//cameraImage.createGraphics();
cameraG = cameraImage.getGraphics();

The above creates temporary surfaces that don't require conversion when copying to a destination buffer.

Also, look into VolatileImage.

#23 Stani R.   Members   -  Reputation: 886

Like
0Likes
Like

Posted 20 October 2011 - 09:41 AM

Colton, I've only skimmed most of the replies and the code since I'm at work but I haven't seen anyone suggesting turning on Java2D hardware acceleration yet. Have you tried that? AFAIK it's off by default. See here for how to enable it.

#24 Outline   Members   -  Reputation: 99

Like
-1Likes
Like

Posted 22 October 2011 - 11:05 AM

its super slow because you using GUI system as your render >_<...
just use a graphic API like OpenGL to render your game.
my 3d java game (using LWJGL) renders me over 4,000 fps.

for more info:

http://en.wikipedia.org/wiki/OpenGL
http://lwjgl.org/

hope its help you...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS