CMExamples/BitmapFont.cpp

35 lines
710 B
C++
Raw Normal View History

2023-06-28 18:40:06 +08:00
#include<hgl/filesystem/FileSystem.h>
using namespace hgl;
namespace
{
2023-09-13 16:11:23 +08:00
uint8 *bitmap_font_8x16_data=nullptr;
uint8 *bitmap_font_8x8_data=nullptr;
2023-06-28 18:40:06 +08:00
}//namespace
2023-09-13 16:11:23 +08:00
void ClearBitmapFont()
2023-06-28 18:40:06 +08:00
{
2023-09-13 16:11:23 +08:00
SAFE_CLEAR_ARRAY(bitmap_font_8x16_data);
SAFE_CLEAR_ARRAY(bitmap_font_8x8_data);
}
2023-06-28 18:40:06 +08:00
2023-09-13 16:11:23 +08:00
bool LoadBitmapFont()
{
ClearBitmapFont();
2023-06-28 18:40:06 +08:00
2023-09-13 16:11:23 +08:00
filesystem::LoadFileToMemory(OS_TEXT("VGA8.F16"), (void **)&bitmap_font_8x16_data);
filesystem::LoadFileToMemory(OS_TEXT("VGA8.F8"), (void **)&bitmap_font_8x8_data);
2023-06-28 18:40:06 +08:00
return(true);
}
2023-09-13 16:11:23 +08:00
const uint8 *Get8x16Char(const char ch)
2023-06-28 18:40:06 +08:00
{
2023-09-13 16:11:23 +08:00
return bitmap_font_8x16_data+uchar(ch)*16;
2023-06-28 18:40:06 +08:00
}
2023-09-13 16:11:23 +08:00
const uint8 *Get8x8Char(const char ch)
2023-06-28 18:40:06 +08:00
{
2023-09-13 16:11:23 +08:00
return bitmap_font_8x8_data+uchar(ch)*8;
2023-06-28 18:40:06 +08:00
}