10000 software rendered sprites

I discovered the holy grail, the silver bullet that solves all performance problems.
Some of you will be impressed, others will throw eggs at me for cheating.

Post your sprite count when the demo starts lagging.

:wink:

http://www.emaggame.com/
(top left button)

Boo!

I let it run up to 205k, and it didn’t show any performance degradation.

But… when I closed the browser tab, it totally crashed the browser… man, I hate the plugin.

timinginfo   138 ms, ready at 11.34 loading: textures textures.txt           [kdk.textures.n]
timinginfo 11545 ms, ready at 11.55 simpleinit()                             [kdk.aa]
java.lang.ClassCastException: sun.awt.image.DataBufferNative cannot be cast to java.awt.image.DataBufferInt
	at kdk.bx.n(kAi:404)
	at kdk.bq.c(kAi:22)
	at kdk.bq.<init>(kAi:65)
	at kdk.ak.b(kAi:47)
	at kdk.dope.m.setSize(kAi:876)
	at kdk.dope.m.<init>(kAi:120)
	at kdk.dope.m.<init>(kAi:133)
	at kdk.dope.j.<init>(kAi:23)
	at kdk.aa.a(kAi:432)
	at kdk.bf.start(kAi:184)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

So I think that’s 0. Additionally I had to kill the browser because it wasn’t responding.

Windows Vista QuaCore Q6600 (2,4Ghz) NVidia 8800GT, Java 1.6.0_07-b06

Getting bored after 100 000 ;D

But the applet version didn’t work at all… nothing in the consol… juste de java sun logo.

Very strange… maybe the applet issues have something to do with parameters (-Djnlp.packEnabled=true) I pass there, or with some threads I spawn for parallel processing. I will remove both tomorrow.
I know even less about that [quote]java.lang.ClassCastException: sun.awt.image.DataBufferNative cannot be cast to java.awt.image.DataBufferInt
[/quote]
Exception. Is that Linux running some kind of open Java? Mrs Google could not help me.

You should put a FPS counter, it will be better to define when it’s beging to slow down.

Windows XP, Celeron 2,4GHz, Intel 82865G, Java 1.6.0_07-b06 :

  • no problem with the applet
  • around 50 000, it seems to slow down a bit

It never seems to slowdown.

Must be a nice cheat.

Hm doesn’t actually look like 10,000 sprites to me…

Cas :slight_smile:

I think the cheat is that it’s just 5 sprites with about 3 backbuffers that are never cleared.

yes, looks more like 1 billion sprites if you let it run for a week.

here is the pseudocode: (slightly changed, I use rasters of BufferedImages and blit via loops)

	Image pic;
	Image[] buf;
	int width=800,height=600;
	int count = 0;

	public void init() {
		buf = new Image[10];
		for (int i = 0; i < buf.length; i++) {
			buf[i] = new Image(width,height);
		}
		pic = somePicture();
	}

	public void render() {
		count++;		
		getGraphics().drawImage(buf[count % buf.length],0,0,null);
		for (int i = 0; i < buf.length; i++) {
			float frak = (float) i / buf.length;
			float time = (count + frak) / (20f);
			int w=width/2;
			int h=height/2;
			
			int x=w+(int)(w/2*Math.sin(time));
			int y=h+(int)(h/2*Math.sin(time*2.1));
			buf[i].getGraphics().drawImage(pic, x, y, null);			
		}
	}

Funny that the applet works now, I did NO update yet. Java is great. :smiley:

Yeah, it’s an old trick. I’m a bit amazed people fall for it. :wink:
* Markus_Persson does some palette shifting tricks

Yes, I expected more eggs and boo’s :slight_smile:

getGraphics().drawImage(buf[count % buf.length],0,0,null);

Please call graphics.dispose() ! You’re leaking native resources.

don’t worry, that was meant as pseudocode. And there is the main function missing. And 42 more things.

[quote=“Riven,post:15,topic:32915”]
Well, not leaking…

[quote=""]

Not the same PC, not the same OS :wink:

Hmm… good to know, although in theory, you could run out of native resources before the GC is executed, as it doesn’t grow the heap - but chances are slim.

Yeah, and it’ll probably allocate more ram than needed if you don’t dispose() as it has to wait for the gc.