Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2011
    Posts
    28
    Rep Power
    0

    Default Anti-Aliasing, and other bugs

    Hey everybody. So, I finally have a working version of Pong. I have some bugs in it still that need to get worked out, but those are a little more complicated. But, I would like some anti aliasing in this. I have a rounded rectangle for my paddle and an oval for my ball. Rounded edges right now are pretty bad looking, and I was curious if there was a way to fix this.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Anti-Aliasing, and other bugs

    Quote Originally Posted by ResidentBiscuit View Post
    Hey everybody. So, I finally have a working version of Pong. I have some bugs in it still that need to get worked out, but those are a little more complicated. But, I would like some anti aliasing in this. I have a rounded rectangle for my paddle and an oval for my ball. Rounded edges right now are pretty bad looking, and I was curious if there was a way to fix this.
    Potentially there are fixes including using RenderingHints on a Graphics2D object, but we've really no idea how to help as you haven't told us anything about your program such as what graphics and GUI library you're using and the code you're using to render your graphics. Please check my link below on "how to ask smart questions" to see what information would help us help you.

  3. #3
    Join Date
    Nov 2011
    Posts
    28
    Rep Power
    0

    Default Re: Anti-Aliasing, and other bugs

    Sorry, new to this forum. The libraries im using are as follows:
    Java Code:
    import java.awt.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.awt.image.BufferStrategy;
    import java.awt.image.MemoryImageSource;
    
    import javax.swing.JFrame;

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Anti-Aliasing, and other bugs

    You're still not telling us much. Again, please read the link that I have indicated. Again, look into using RenderingHints on a Graphics2D object. There are plenty of examples of this on this forum (I know as I've posted a few myself).

  5. #5
    Join Date
    Nov 2011
    Posts
    28
    Rep Power
    0

    Default Re: Anti-Aliasing, and other bugs

    Well, I'm not sure what else you need to know. Basically have some rounded objects in my program that have jagged edges that I would cleaned up. But, with RenderingHints, I have an issue. I use a Graphics object for everything in this, not a Graphics2D and as far as I know, I have to use a Graphics2D object for RenderingHints. So, I tried to make my Graphics object into a Graphics2D object and it worked for the RenderingHints, but then my BufferStrategy ceased to work.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Anti-Aliasing, and other bugs

    Quote Originally Posted by ResidentBiscuit View Post
    Well, I'm not sure what else you need to know. Basically have some rounded objects in my program that have jagged edges that I would cleaned up. But, with RenderingHints, I have an issue. I use a Graphics object for everything in this, not a Graphics2D and as far as I know, I have to use a Graphics2D object for RenderingHints. So, I tried to make my Graphics object into a Graphics2D object and it worked for the RenderingHints, but then my BufferStrategy ceased to work.
    Why are you using a BufferStrategy?

  7. #7
    Join Date
    Nov 2011
    Posts
    28
    Rep Power
    0

    Default Re: Anti-Aliasing, and other bugs

    Im using BufferStrategy to prevent screen flickering

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Anti-Aliasing, and other bugs

    Quote Originally Posted by ResidentBiscuit View Post
    Im using BufferStrategy to prevent screen flickering
    Why not just let Swing's double buffering take care of that for you?

  9. #9
    Join Date
    Nov 2011
    Posts
    28
    Rep Power
    0

    Default Re: Anti-Aliasing, and other bugs

    Quote Originally Posted by Fubarable View Post
    Why not just let Swing's double buffering take care of that for you?
    What do you mean?

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Anti-Aliasing, and other bugs

    Swing JComponents use automatic double buffering which helps greatly to prevent flicker. I'm not sure where you read up on BufferStrategy but it smells somewhat AWT-ish to me.

  11. #11
    Join Date
    Nov 2011
    Posts
    28
    Rep Power
    0

    Default Re: Anti-Aliasing, and other bugs

    I do believe it is AWT, I didn't know Swing had automatic double buffering. This helps a lot. So I can just drop the BufferStrategy, switch my graphics to 2D and then I can use anti-aliasing?

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Anti-Aliasing, and other bugs

    Cast your Graphics to Graphics2D since the Graphics object passed into a paint or paintComponent method is actually a Graphics2D object.

Similar Threads

  1. anti-bot test
    By droidus in forum Java Applets
    Replies: 1
    Last Post: 11-12-2011, 05:44 PM
  2. Aliasing in methods
    By gregoost in forum New To Java
    Replies: 9
    Last Post: 09-06-2011, 11:34 AM
  3. Name this Anti-pattern
    By AdamGibbons in forum Advanced Java
    Replies: 6
    Last Post: 05-09-2011, 04:18 PM
  4. Anti virus
    By gyan916 in forum Advanced Java
    Replies: 3
    Last Post: 08-03-2010, 10:22 AM
  5. Aliasing In 2d Arraylist
    By hatela150 in forum Java 2D
    Replies: 1
    Last Post: 12-11-2008, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •