Ok, thanks a lot to davedes for the advice. I adjusted the slick code, and now it renders at roughly the same speed as the libdgx code ;D So the main issue appeared to be the use of the “begin” and “end” commands, and using drawEmbedded instead of draw. I just have to figure out rotation etc…
Here’s the faster code:
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
public class SlickTest extends BasicGame {
private Image image;
private long lastFpsTime;
private float angle;
public SlickTest() {
super("Test");
}
@Override
public void render(GameContainer container, Graphics graphics) throws SlickException {
image.startUse();
for (int i = 0; i < 30000; i++) {
angle += 6.28f / 200f;
image.drawEmbedded(200 + (float) Math.cos(angle) * 100f, 200 + (float) Math.sin(angle) * 100f,
image.getWidth(), image.getHeight());
}
image.endUse();
}
@Override
public void init(GameContainer container) throws SlickException {
image = new Image("image/test.png");
lastFpsTime = System.nanoTime();
}
@Override
public void update(GameContainer container, int delta) throws SlickException {
if (System.nanoTime() - lastFpsTime > 1000000000) {
System.out.println(container.getFPS());
lastFpsTime = System.nanoTime();
}
}
public static void main(String[] args) throws SlickException {
AppGameContainer app = new AppGameContainer(new SlickTest());
app.setShowFPS(false);
app.setDisplayMode(800, 600, false);
app.setTargetFrameRate(300);
app.start();
}
}