I ran into a very strange problem, I tried searching for an answer for days and days. My game just got a new particle system, but was too slow to be playable. Unfortunately, Buf
Here's a few things to check:
Without knowing the console/error output of your setBuffers function it's difficult to tell. Is Intel using createBufferStrategy(2); while NV uses createBufferStrategy(3); ? if so that could be part of the issue with it using extra memory.
Have you tried the java2d System.properties yet? http://docs.oracle.com/javase/1.5.0/docs/guide/2d/flags.html Especially the trace property for debugging.
Windows only
System.setProperty("sun.java2d.transaccel", "True");
System.setProperty("sun.java2d.d3d", "True");
System.setProperty("sun.java2d.ddforcevram", "True");
All platforms
System.setProperty("sun.java2d.opengl", "True");
For debugging
System.setProperty("sun.java2d.trace", "timestamp,log,count");
//// -Dsun.java2d.trace=[log[,timestamp]],[count],[out:],[help],[verbose]
Toolkit.getDefaultToolkit().sync(); doesn't actually force monitor VSync, that's done by BufferCapabilities (in your setBuffers function).
BufferStrategy bf = getBufferStrategy();
if (bf != null) {
BufferCapabilities caps = bf.getCapabilities();
try {
Class ebcClass = Class.forName(
"sun.java2d.pipe.hw.ExtendedBufferCapabilities");
Class vstClass = Class.forName(
"sun.java2d.pipe.hw.ExtendedBufferCapabilities$VSyncType");
Constructor ebcConstructor = ebcClass.getConstructor(
new Class[] { BufferCapabilities.class, vstClass });
Object vSyncType = vstClass.getField("VSYNC_ON").get(null);
BufferCapabilities newCaps = (BufferCapabilities)ebcConstructor.newInstance(
new Object[] { caps, vSyncType });
createBufferStrategy(2, newCaps);
// TODO: if success, setCanChangeRefreshRate(false) and setRefreshRate(60).
// Possibly override refreshRateSync()?
}
catch (Throwable t) {
// Ignore
t.printStackTrace();
}
}
EDIT this code was from (http://pulpcore.googlecode.com/hg-history/3c4001969922b93048e0a166395115df059a2059/src/pulpcore/platform/applet/BufferStrategySurface.java)
Also, you should be calling setBuffers AFTER the Canvas constructor has run and it's been added to the JFrame.
I'm "relatively sure" you don't need to call super.paint(g); I don't know if its what's causing your specific issue, but you should remove the line from your paint function.
Though you don't show the code, your explosion mechanism using 200 randomly moving sprites could be a major cause for errors. Figure out the maximum number of explosions you want to have on the screen at one time and generate those sprites N * 200 before hand, put them in an array list ArrayList(N) and then in your code reference them cyclically. ExplosionClass = explosionList.get(currentExplosionIndex % explosionList.size());