Hi!
Decided to try new features offered by alx wrapper for Allegro 5. All works fine except getting bitmap font.
alx::Font normalfont; and
alx::Font titlefont;
is declared in the game.h file;
Commented out is my old code which works. Code:
#SelectExpand
1void Game::load_fonts()
2{
3 //ALLEGRO_BITMAP *temp;
4 //const int ranges[] = { 32, 126 };
5
6 ////normalfont
7 //temp = al_load_bitmap("Media/Fonts/ex06.pcx");
8 //al_convert_mask_to_alpha(temp, al_map_rgb(255, 0, 255));
9 //normalfont = al_grab_font_from_bitmap(temp, 1, ranges);
10
11 ////titlefont
12 //temp = al_load_bitmap("Media/Fonts/TITLE_FONT.pcx");
13 //al_convert_mask_to_alpha(temp, al_map_rgb(0, 0, 0));
14 //titlefont = al_grab_font_from_bitmap(temp, 1, ranges);
15
16 alx::Bitmap temp;
17 std::vector<std::tuple<int, int>> ranges;
18 ranges.push_back(std::make_tuple(32, 126));
19
20 //normalfont
21 temp.load("Media/Fonts/ex06.pcx");
22 temp.convertMaskToAlpha(alx::Color(0xFF00FFFF));
23 normalfont.grab(temp, ranges);
24
25 //titlefont
26 temp.load("Media/Fonts/TITLE_FONT.pcx");
27 temp.convertMaskToAlpha(alx::Color(0));
28 titlefont.grab(temp, ranges);
29}
A grabber function from Font.hpp (namespace alx)
#SelectExpand
1 /**
2 Creates a font from a bitmap.
3 @param bmp bitmap.
4 @param ranges ranges.
5 @return true on success.
6 */
7 bool grab
(const Bitmap
&bmp,
const std::vector
<std::tuple
<int, int>>
&ranges
) {
8 std::vector
<int> rangeBuffer
;
9 for(auto t
: ranges
) {
10 rangeBuffer.push_back
(std::get
<0>(t
));
11 rangeBuffer.push_back
(std::get
<1>(t
));
12 }
13 reset
(al_grab_font_from_bitmap(bmp.get
(), rangeBuffer.size
(), rangeBuffer.data
()),
al_destroy_font);
14 return (bool)(*this);
15 }
I tried to debugger the code and all works until debugger brakes when returning from this function in a <memory>file
#SelectExpand
1_Ty *get() const _NOEXCEPT
2 { // return pointer to resource
3 return (this->_Get());
4 }
It mean that there is not a resource from what return a pointer. Temp file is loaded correctly with a pointer to it.
Where then there is the problem?