|
antialiasing using al_set_blender |
William Labbett
Member #4,486
March 2004
|
hi, can someone explain how I'd do antialiasing with al_set_blender() ? I've got an ALLEGRO_BITMAP and want to draw it four times over itself with offsets (-1, 0) (1, 0) (-1, 0) (0, 1) presuming that's the best way. I've got no experience with this sort of thing.
|
Dario ff
Member #10,065
August 2008
|
AFAIK, the blender routines work for modifying each pixel. I haven't seen some custom blender routine to code something like getting other pixels and use them in the blender. Maybe you'd do fine with a custom shader? TranslatorHack 2010, a human translation chain in a.cc. |
William Labbett
Member #4,486
March 2004
|
I see. It's not that easy to average two colors ? I was originally hoping to just use an openGL accumulation buffer but I think I'd have to use the glut thing for that. That'd be going into unknown territory.
|
Dario ff
Member #10,065
August 2008
|
Why do you want antialiasing? Are there jaggies in the sprites? Just to be sure, you turned linear filtering on in the allegro5.cfg? # Can be 'point', 'linear', 'anisotropic'. # Just a hint, driver doesn't have to obey. min_filter=linear mag_filter=linear
TranslatorHack 2010, a human translation chain in a.cc. |
William Labbett
Member #4,486
March 2004
|
I'm drawing a load of polygons to the screen for an intro to the game. I wanted to antialias them to make things look a bit nicer. {"name":"601148","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/a\/4a845609bf772f99a3dc2d6a10069702.png","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/a\/4a845609bf772f99a3dc2d6a10069702"} {"name":"601149","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/e\/6e9a1d9c717e52042ec288a9116df013.png","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/e\/6e9a1d9c717e52042ec288a9116df013"}
|
Dario ff
Member #10,065
August 2008
|
You're using OpenGL for all of this right? One quick search for a NeHe tutorial found this: The following part looks like what you might be looking for. Notice line #13. 1int InitGL(GLvoid) // All Setup For OpenGL Goes Here
2{
3 if (!LoadGLTextures()) // Jump To Texture Loading Routine
4 {
5 return FALSE; // If Texture Didn't Load Return FALSE
6 }
7
8 BuildFont(); // Build The Font
9
10 glShadeModel(GL_SMOOTH); // Enable Smooth Shading
11 glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
12 glClearDepth(1.0f); // Depth Buffer Setup
13 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Set Line Antialiasing
14 glEnable(GL_BLEND); // Enable Blending
15 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Type Of Blending To Use
16 return TRUE; // Initialization Went OK
17}
TranslatorHack 2010, a human translation chain in a.cc. |
William Labbett
Member #4,486
March 2004
|
I tried this but it didn't make any visible difference. glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); I might try doing it using ALLEGRO_LOCKED_REGION's, but that's a lot of work for a small reward so I might leave for another time.
|
SiegeLord
Member #7,827
October 2006
|
Have you tried multisampling? (see ex_multisample) "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
William Labbett
Member #4,486
March 2004
|
Will do. I've looked at the example and can't see how it relates to antialiasing. What exactly is multisampling ?
|
SiegeLord
Member #7,827
October 2006
|
Multisampling is one way of accomplishing antialiasing. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Dario ff
Member #10,065
August 2008
|
Quote:
ALLEGRO_SAMPLE_BUFFERS: Whether to use multisampling (1) or not (0).
al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_REQUIRE); al_set_new_display_option(ALLEGRO_SAMPLES, 4, ALLEGRO_REQUIRE); Seems like bloody easy! TranslatorHack 2010, a human translation chain in a.cc. |
William Labbett
Member #4,486
March 2004
|
Trouble is I can't see any difference between the normal window and multisample window on the ex_multisample.exe
|
Dario ff
Member #10,065
August 2008
|
Actually, it does have a difference. The display is just too small to notice and the example seems to be a bit bugged under Windows XP(the second "normal" display doesn't refresh). Here's a more visible version of the difference with Multisampling(4) turned on, and without it. {"name":"601152","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/c\/3c8245e56de6e546f68aeb91990defec.jpg","w":802,"h":802,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/c\/3c8245e56de6e546f68aeb91990defec"} If you want to notice the difference, paste one in a new layer(use Gimp, PS, etc.), and switch the visibility of one of them. You'll notice the difference. TranslatorHack 2010, a human translation chain in a.cc. |
William Labbett
Member #4,486
March 2004
|
thanks Dario, that's really helpful. I did what you said and did see the deifference so like you say it is easy!
|
SiegeLord
Member #7,827
October 2006
|
Well, there's also a possibility that his card does not support multisampling. E.g. mine doesn't. Hence my suggestion to check if it works first. EDIT: Nevermind! "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|