Bad rendering loop?

Ok, its not that complicated to read at all.
1.) the number tells you how often this pipeline-functionality has been used.
2.) The name of the pipelinefunctionality used, almost everything with “loops” in it and a high count in 1.) is evil.

In fact your profile here shows that everything happens in the software rendering loops. If you did trace your BufferedImage implementation, then this is no surpise - everything is done in SW except blitting some images. If no you’re doing some fancy stuff which cannot be accalerated by the default java2d-pipeline.

Try wether -Dsun.java2d.opengl=True helps (java displays wether this works or not). Use Java-6 if you plant to try it.

The following operations could cause problems on the windows default pipeline:

  • Antialiasing
  • Translucent stuff (transparent images work)
  • Image transformations

The X11 pipeline seems to be even a little bit trickier, e.g. Substance LNF is very slow on Linux but works OK on Windows. However accalerated stuff is on X11 as fast / almost as fast / faster than on Windows.

Best wishes, lg Clemens

OK, I understand that. But even if they are high, what can I do about it?

Also, I did some messing around with both BufferStrategy and BufferedImage. It seems that if I’m drawing only transparent PNG images (and a String to show the FPS display), I can draw over 25,000 images and still get almost 80 frames per second (no differance whether using BufferStrategy or a BufferedImage). My screen size is 1024x768 (my screen resolution, however, is 1280x1024; not in FSEM). My images are 16x16, 204 colors. However, on the down side, my CPU was shot upto like 90%. I’m using code that is supposed to load the images as accelarated (using the video RAM and not CPU), however, if it was in the video memory, shouldn’t my CPU usage be a lot lower? Or is it because I’m running through almost 80 for…loops in one second in which each loops 25,000 times?

Here’s the code I got from Kev’s site, cokeandcode.com - from his Space Invaders 101 tutorial:

		try {
			URL url = getClass().getClassLoader().getResource("Image.png");
			Image source = ImageIO.read(url);

			GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
			image = gc.createCompatibleImage(source.getWidth(null), source.getHeight(null), Transparency.BITMASK);
			image.getGraphics().drawImage(source, 0, 0, null);
		} catch(Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}

UPDATE: A BufferStrategy actually gets about 10 frames per second more (almost 90 frames per second) than using a BufferedImage (about 80 frames per second) when doing what’s explained above.

UPDATE: I get pretty close to 100 frames per second with FSEM (about 96 FPS average, using BufferStrategy, 1024x768x32 at 75mhz).

25k images :o
I’m surprised it works that well beyond 1k :slight_smile: Your high CPU usage is from all that drawing I guess. Do you even use sleep() ? If not it’s logical that CPU usage is near 100% becouse it’s doing your program all the time.

Yes, I’m sleeping for one millisecond every frame. So I’m assuming this is pretty damn good? So my code should be OK then, right?

OK, I just looked at my code and realized my screen size is actually 640x480x32 at 75mhz. I thought I had it at 1024x768… However, I still get 90 frames per second even at 1280x1024x32 at 75mhz.

UPDATE: I’m so stupid. :frowning: More than like 9/10 of the images weren’t even on the screen. I changed my code to actually draw ALL 5,120 images to screen, and I get only about 30 frames per second (at 1280x1024x32, 75mhz).

Here’s a summery of how many images I can draw at 5 major used resolutions and the average framerated displayed.
320x240, 300 images, 250 frames per second
640x480, 1200 images, 110 frames per second
800x600, 1850 images, 77 frames per second
1024x768, 3072 images, 49 frames per second
1280x1024, 5120 images, 30 frames per second

Thank you all very much for all of your help (especially to trembovetski, for pointing that a BufferStrategy is much better). After realizing that when using a BufferStrategy in combination with accelarated images (placing them in video memory), my game now runs at over 500 frames per second in any resolution tested with (with a BufferedImage, I could not get that to happen, usually at the highest res. 1280x1024, it ran at only 40-60 fps). Thank you all again so much for the great information!!!

Also by the way… sorry for the double post, I just wanted you guys to receive the “New reply” notification to see I got it working just the way I needed it.

–Jamison