Does the below render antialiased lines when the alpha map is used? It seems that the lines are not antialiased for me when I use the alpha map, but I'm not sure if it is my hardware.
Code:
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Curve;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.opengl.renderer.Renderer;
public class AlphaMapAA extends BasicGame {
private Curve curve1, curve2;
private boolean useAlphaMap;
public AlphaMapAA () {
super("SlickBezier");
}
public void init (GameContainer container) throws SlickException {
curve1 = new Curve(new Vector2f(100, 100), new Vector2f(150, 100), new Vector2f(150, 200), new Vector2f(200, 200));
curve2 = new Curve(new Vector2f(200, 200), new Vector2f(250, 200), new Vector2f(250, 150), new Vector2f(300, 150));
}
public void update (GameContainer container, int delta) throws SlickException {
}
public void render (GameContainer container, Graphics g) throws SlickException {
g.setAntiAlias(true);
g.drawString("Press space to toggle alpha map.", 10, 30);
g.setLineWidth(20);
if (useAlphaMap) {
g.clearAlphaMap();
g.setDrawMode(Graphics.MODE_ALPHA_MAP);
g.setColor(Color.white);
g.fillRect(0, 0, container.getWidth() * 0.33f, container.getHeight());
g.fillRect(container.getWidth() * 0.5f, 0, container.getWidth() * 0.33f, container.getHeight());
g.setDrawMode(Graphics.MODE_ALPHA_BLEND);
}
g.setColor(Color.red);
g.draw(curve1);
g.draw(curve2);
if (useAlphaMap) g.setDrawMode(Graphics.MODE_NORMAL);
}
public void keyPressed (int key, char c) {
if (key == Input.KEY_SPACE) useAlphaMap = !useAlphaMap;
}
public static void main (String argv[]) {
Input.disableControllers();
Renderer.setLineStripRenderer(Renderer.QUAD_BASED_LINE_STRIP_RENDERER);
Renderer.getLineStripRenderer().setLineCaps(true);
try {
AppGameContainer container = new AppGameContainer(new AlphaMapAA());
container.setDisplayMode(420, 300, false);
container.setTargetFrameRate(60);
container.start();
} catch (SlickException e) {
e.printStackTrace();
}
}
}