|
Using different sampling for scaled bitmap |
simon77c
Member #20,398
June 2021
|
Can anyone tell me whether or not it is possible to change sampling of the bitmap scaling while doing any variant of al_draw_scaled_bitmap()? I don't want it to be only nearest neighbour and I don't want it to be only bi-linear. Is it possible? Or should I use some external library for it? If so, can you recommend such a library? (I'm an absolute newcomer to this and I have less than 1 month of c++ experience too, so might have ignored a part of allegro which does this) |
Edgar Reynaldo
Major Reynaldo
May 2007
|
https://liballeg.org/a5docs/trunk/shader.html https://liballeg.org/a5docs/trunk/shader.html#al_set_shader_sampler That may do the trick. You might have to create and use your own shader though. 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 |
simon77c
Member #20,398
June 2021
|
Also, I have another question on these bitmaps. Why does each pixel occupy 4 times the size as normal, and why are channels stored as floats instead of chars? i was going to use a 20000x8000px bitmap, but realized that it would seriously affect ram usage. Edit: i used al_set_new_bitmap_flags with ALLEGRO_MEMORY_BITMAP and it cut the memory usage in 4. |
Dizzy Egg
Member #10,824
March 2009
|
I think you're referring to pixel format; a 32-bit image will use 8bits each for RGB, and 8bits for alpha. That's 32bits for each pixel.
---------------------------------------------------- |
simon77c
Member #20,398
June 2021
|
Uhh, nope. I was getting 16 bytes per pixel on 32 bit bmp's, 12 bytes per pixel on 24 bit bmps, and so on. it was multiplying itself by four. i think it's because a,b,g and r are new_float_byte() things (i think they mean floats) according to al_load_bitmap_flags (check no_premultiplied_alpha, it clearly says allegro does new_float_byte() for all 4 four channels). |
Edgar Reynaldo
Major Reynaldo
May 2007
|
If you're using the DX driver, load your bitmaps with ALLEGRO_NO_PRESERVE_TEXTURE. That will keep only ONE copy of a bitmap around. Dizzy Egg is right, one byte for each color component makes 4 bytes, or 32 bits. 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 |
simon77c
Member #20,398
June 2021
|
Now it's solved, using ALLEGRO_VIDEO_BITMAP no longer keeps 4 copies of one image, when i use ALLEGRO_OPENGL. It also cuts cpu + gpu usage in half, ram in 1/4th and increases fps by twice. I wonder what I did with the DX backend to cause overuse of my resources:-( |
|