Hello,
I'm looking for way to draw bitmaps (not primitives) (zoomed and without zoom) antialised.
When I draw bitmap the normal way, allegro functions take floats as position arguments, but the position of the bitmap is rounded to whole pixels, this makes bad effects in the game. The goal would be to be able to draw the bitmap in between two pixels like I show it on this picture:
http://www.kovarex.com/download/bitmap-placement.png
I would expect, that this kind of multisampling setting would do this, but it didn't
al_set_new_display_flags(ALLEGRO_RESIZABLE); al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR); al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES, 6, ALLEGRO_SUGGEST);
If you use 5.0.7 and the D3D driver, multi-sampling does not work.
Elias:
I used the 5.1.2 version, and today we updated to 5.1.3 and it is the same.
The goal would be to make it work either for D3D and opengl if possible.
In 5.1.3 it should work. What happens if you run ex_multisample?
al_set_new_display_option(ALLEGRO_SAMPLES, 6, ALLEGRO_SUGGEST);
I'm not very familiar with exactly what capabilities Allegro can use, but 6 is a weird number for 'normal' samples, I think. Try 4?
weapon_S:
I tried 4 instead of 6 and it is the same, bitmap position is still rounded to pixels.
Elias:
But ex_multisample contains only primitives drawing, I need multisampling for bitmap drawing.
Yes, but does ex_multisample work? al_draw_bitmap just calls the underlying primitive functions as far as I know so either both should work or neither. Anyway, if ex_multisample works but bitmap drawing does not, it sounds like a bug to me. If ex_multisample doesn't work as well, multisampling simply doesn't work for some reason.
Elias:
ex_multisample works
I'll try modifying it to add an al_draw_bitmap call when I get home and see how it looks here.
I'm just firing ideas.
What does al_get_display_option(display, ALLEGRO_RENDER_METHOD); return?
That shouldn't return 0... but I guess something has to be wrong.
weapon_S:
It returns 0.
Does it mean hardware acceleration isn't used?
How could it be possible? The game isn't THAT slow (I can draw up to 20k sprites 60fps, would software acceleration make it?
I tried adding an al_draw_bitmap call to ex_multisample and it does work.
Double-check that:
- none of your bitmaps are created before al_create_display
- you set ALLEGRO_SAMPLE_BUFFERS and ALLEGRO_SAMPLES before al_create_display
- you set ALLEGRO_MIN_LINEAR and ALLEGRO_MAG_LINEAR before any bitmaps are created/loaded
Elas:
This is our display init function
bitmaps are loaded later
This is my modified ex_multisample. If you either comment out the multi-sampling or the bitmap filtering you can clearly see what both do - the former anti-aliases the outline, the latter filters the inside of the texture. So without multisampling the bitmap seems to jump in one-pixel steps. Without the filtering the texture seems to jump in one-pixel steps. With both on it's all smooth.
I'm using Ubuntu/OpenGL here.
In the first post I had only ALLEGRO_MIN_LINEAR, adding ALLEGRO_MAG_LINEAR to new bitmap flags seems to solve the problem.
Could it be, that unscaled bitmaps are affected by the ALLEGRO_MAG_LINEAR flag?
It doesn't say on MSDN [1]. But you almost always want either both or none (and if you scale your bitmaps down more than about 50% you want to enable mipmaps as well). Maybe we should provide new defines like
#define ALLEGRO_BILINEAR_FILTER ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR #define ALLEGRO_TRILINEAR_FILTER ALLEGRO_BILINEAR_FILTER | ALLEGRO_MIPMAP
and then you'd just use bi-linear or tri-linear. And now with all the added 3D support, we also should add an anisotropic filtering option.