|
This thread is locked; no one can reply to it. |
1
2
|
al_draw_rotated_bitmap() giving distorted edges |
Thinkal VB
Member #16,859
May 2018
|
I was just running an animation using frames. But when I changed the rotation the edged became distorted but for rotation = 0 degrees it's crystal clear and fine. I am using #define PI 3.141592653589793f for converting the degree to radian. The data type used to store the value in radians is a float. What would be the potential cause of this problem? float Position::getRadRotX() const |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Something you can do is turn on multi-sampling. You have to enable it before creating your display : al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS , 1 , ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES , 4 , ALLEGRO_SUGGEST); ALLEGRO_DISPLAY* d = al_create_display(...); if (al_get_display_option(d , ALLEGRO_SAMPLE_BUFFERS) != 1) { cout << "Failed to enable multisampling on the display." << std::endl; } cout << "There are " << al_get_display_option(d , ALLEGRO_SAMPLES) << " sample buffers in use." << std::endl;
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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you, Edgar Reynaldo for the replay std::cout<< says:- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
That's curious. What platform are you on? 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 |
Thinkal VB
Member #16,859
May 2018
|
Windows 10 64bit. Visual Studio 2017 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Okay, and what Allegro driver are you using? OpenGL or DX? Show your display set up code. 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 |
Thinkal VB
Member #16,859
May 2018
|
void debug() al_init(); al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); display = al_create_display(dispData.width, dispData.height); } |
Edgar Reynaldo
Major Reynaldo
May 2007
|
That's really weird, because I'm running mostly the same setup as you, and I know I have a working multisampling example around here somewhere. Let me find it. Run a debugging build, and see what allegro.log has to say about the display. EDIT 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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you Edgar Reynaldo for helping out, |
Edgar Reynaldo
Major Reynaldo
May 2007
|
See my edit. From allegro.log it looks like none of the display formats tested support multi-sampling. They all say "samples 0/0" in the log. Try the OpenGL driver. 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 |
Thinkal VB
Member #16,859
May 2018
|
Don't know how to switch to open GL in windows 10. |
Thinkal VB
Member #16,859
May 2018
|
Thank you, Edgar Reynaldo for your kind support. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
This is probably a bug in the DX driver. You might try to increase the samples to 8 but I think 2 or 4 will give the most optimal results. How many samples did it end up with? What does allegro.log say? 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 |
Thinkal VB
Member #16,859
May 2018
|
I replaced the value of PI with const float PI = 104348 / 33215; I switched back to d3d and used the same code as "const float PI = 104348 / 33215;" and the result was the same as when the OpenGL was rendering with 4 buffers. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Are you drawing your sprite on the back buffer or another bitmap? If you're drawing it on another bitmap it won't be multi-sampled unless you enable multi-sampling on the bitmap as well. al_set_new_bitmap_samples(8); al_create_bitmap(w,h); As for your float problem. int/int always gives you int. You need to specify a floating point literal value as such by using .0f on the end of it. Otherwise you get integer division, which discards the remainder. Here's multi-sampling enabled through al_set_new_bitmap_samples : https://www.allegro.cc/files/attachment/611523 Actually, 8 samples looks the best. 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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you Edgar Reynaldo, for bearing with me ... |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Okay, I'm thinking that MultiSampling doesn't do anything for sprite drawing. Try this instead : Before you load your sprites, call the following code : al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MIPMAP); ALLEGRO_MIPMAP won't do anything if the width and height of the image are not a power of two. You can also try ALLEGRO_MAG_LINEAR, but it can make sprites blurry when enlarging them. 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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you Edgar Reynaldo, |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Well, I'm glad it's improved somewhat. Could you show a screenshot of the sprite with ALLEGRO_MIN_LINEAR enabled? Is it really any smoother? I've never had this problem before, but I haven't been rotating sprites much. I tried out rotation on multi-sampled primitives and enabled down scaling and ALLEGRO_MIN_LINEAR. While it doesn't do much for full size sprites, it looks pretty good when actually scaling down. You might try increasing the resolution of your graphics and scaling them down in your game, but whether that is worth it or not is up to you. I will agree, there are some rather jagged edges when rotating sprites, even multi-sampled primitive sprites. 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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you Edgar Reynaldo, One more thing - Should the actual bitmap have to be in the power of two or just the sub-bitmaps have to be in power of two. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
If you want mipmaps, the source image has to be power of two in width and height (not necessarily the same though). mipmaps are really only good if you change the scale of your sprite often at runtime. That's what mipmaps are, pre-scaled versions of your image. I will play with this some more over the next few days. Could you attach the image you're using for your player? I'd like to try some things. 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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you Edgar Reynaldo, |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Note for the future - if you're going to attach multiple files, like a game project, it's best to put it in a .zip file so there's only one file to download. I will take a look at the assets. You only need power of two textures if you want mipmaps. mipmaps are only good if you're planning to zoom in EDIT Here's the demo - MinMag.zip. For some reason, mipmapping made the images fade when drawn at less than actual size. https://www.allegro.cc/files/attachment/611584 Rotate around the center with the mouse. Mouse wheel changes zoom. 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 |
Thinkal VB
Member #16,859
May 2018
|
Thank you, Edgar Reynaldo, for your kind support. |
|
1
2
|