Slick Forums

Discuss the Slick 2D Library
It is currently Mon May 20, 2013 4:19 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Nov 20, 2008 11:49 pm 
Offline
Game Developer
User avatar

Joined: Sun May 25, 2008 9:45 am
Posts: 578
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();
      }
   }
}

_________________
SingSong Karaoke - http://singthegame.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2008 12:26 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Thats correct, the alpha map overrides the alpha values. Antialisasing of lines requires control over the alpha. The two are incompatible I think.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2008 4:38 pm 
Offline
Game Developer
User avatar

Joined: Sun May 25, 2008 9:45 am
Posts: 578
Damn. Any ideas on how I can achieve the same effect with antialiasing? I need to erase portions of the bezier curves to indicate the notes you have hit. The lines would look quite a lot nicer with antialiasing. :?

_________________
SingSong Karaoke - http://singthegame.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2008 7:29 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Draw the lines with antialiasing on, then draw the background with the inverse of the alpha map you're using now?

Kev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group