|
Anti-aliasing is not working |
Doctor Cop
Member #16,833
April 2018
|
I am trying Anti-aliasing in my code but it's not working. please help me. al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); the code above which I copied from GitHub's Wiki the code which I wrote 1#include <allegro5/allegro.h>
2#include <allegro5/allegro_primitives.h>
3
4int main()
5{
6 al_init();
7 al_init_primitives_addon();
8
9 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
10 al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
11 al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
12
13 ALLEGRO_DISPLAY *display = al_create_display(800, 600);
14
15 al_clear_to_color(al_map_rgb(255, 255, 255));
16 //al_draw_circle(400, 300, 100, al_map_rgb_f(1, 0, 1), 2);
17 al_draw_rounded_rectangle(400-100, 300-20, 400+100, 300+20, 20, 20, al_map_rgb(70, 60 , 100), 2);
18 al_flip_display();
19 al_rest(5);
20
21 al_destroy_display(display);
22 return 0;
23}
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
ALLEGRO_*_LINEAR only works for filtering bitmaps. ALLEGRO_SUGGEST is just that, a suggestion. It doesn't gurantee that the option you requested is active. You have to check with al_get_display_option to see if it was successful. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Doctor Cop
Member #16,833
April 2018
|
Is there a way to get smoother primitives guaranteed? I want to make something with primitives, which library can provide me vector graphics like primitives?
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
There is no guarantee. You can use ALLEGRO_REQUIRE and check for a null display. Also, primitives are not vector graphics. Vector graphics can scale to any size. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
SiegeLord
Member #7,827
October 2006
|
Edgar Reynaldo said: Also, primitives are not vector graphics. This is not correct. Doctor Cop said: I am trying Anti-aliasing in my code but it's not working. What OS? If it's Windows, maybe try OpenGL. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Okay so draw an arc at two different sizes and tell me the curvature is the same. Primitives are approximations. Vector graphics can be drawn with primitives but that doesn't make them the same. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
dthompson
Member #5,749
April 2005
|
Doctor Cop said: which library can provide me vector graphics like primitives? Maybe worth mentioning that if you're including vector graphics storage formats (like SVG) in that question: these can't be rendered with Allegro 5. There might be a library out there that can load an SVG and resolve its paths to vertices for a given scale, but a quick Google yielded nothing for me. However, because of SVG's abundance, I wonder whether this'd make a good add-on? ______________________________________________________ |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Run time generation of SVG images scaled to destination would be cool. Pre-rendered or drawn on the fly? There's a big performance hit for decoding it multiple times, and there's always mip-maps. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
librsvg will do it. You'd have to make cairo render to a memory buffer which could be converted to an ALLEGRO_BITMAP.
|
Doctor Cop
Member #16,833
April 2018
|
Hmm, so vector graphics for GUI is a no? I wonder, How are browsers like Mozilla and Chrome are drawing so smooth layouts?
|
dthompson
Member #5,749
April 2005
|
GUIs absolutely can (and arguably should) be built from vector graphics such that you can do smooth DPI scaling. The user always has the option to veto antialiasing regardless. Doctor Cop said: How are browsers like Mozilla and Chrome are drawing so smooth layouts? Trust me, you don't want to worry about how web browsers optimise their renders. It isn't pretty. Peter Hull said: You'd have to make cairo render to a memory buffer which could be converted to an ALLEGRO_BITMAP. Huh, this'd be great if we're happy to do the initial [expensive] rasterisation at init, so we end up with mipmaps like Edgar's suggesting. ______________________________________________________ |
Erin Maus
Member #7,537
July 2006
|
You can do realtime rendering of resolution independent curves in with antialiasing on a non-MSAA framebuffer: https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf I have an implementation for quadratic curves that's really optimized: https://github.com/aaronbolyard/Algae.Canvas It's just patented until 2026. Thus, unless you license it, you're SOL unless you find a different way of doing it. I decided the difficulties aren't worth it and have been using vector graphics rasterized offline (ItsyRealm) or vector graphics decomposed into straight lines segments then rasterized to a texture at runtime (Lacklore; necessary for changing fill styles, etc at runtime). --- |
|