mirror of
https://github.com/leozide/leocad.git
synced 2026-10-27 06:20:55 +00:00
442 lines
25 KiB
C++
442 lines
25 KiB
C++
#include "lc_global.h"
|
|
#include <string.h>
|
|
#include "texfont.h"
|
|
#include "lc_context.h"
|
|
#include "lc_glextensions.h"
|
|
#include "lc_texture.h"
|
|
#include "image.h"
|
|
|
|
static const unsigned char TextureData[2048] =
|
|
{
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0xe0, 0x00, 0x18, 0x60, 0x66, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x60, 0x66, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
|
0xf8, 0xb1, 0x03, 0x0f, 0x6e, 0x78, 0xfc, 0xb8, 0xd9, 0x61, 0x66, 0xcc, 0xec, 0x1c, 0x3b, 0x00, 0x0c, 0x73, 0x86, 0x19, 0x73, 0xcc, 0x30, 0xcc, 0x39, 0x63, 0x66, 0xc6, 0x9c, 0x33, 0x67, 0x00,
|
|
0x00, 0x33, 0xcc, 0x90, 0x61, 0x86, 0x31, 0x86, 0x19, 0x66, 0x66, 0xc3, 0x8c, 0x31, 0xc3, 0x00, 0xe0, 0x33, 0xcc, 0x80, 0x61, 0x86, 0x31, 0x86, 0x19, 0x66, 0xe6, 0xc1, 0x8c, 0x31, 0xc3, 0x00,
|
|
0x38, 0x33, 0xcc, 0x80, 0x61, 0xfe, 0x31, 0x86, 0x19, 0x66, 0xe6, 0xc1, 0x8c, 0x31, 0xc3, 0x00, 0x0c, 0x33, 0xcc, 0x80, 0x61, 0x06, 0x30, 0x86, 0x19, 0x66, 0x66, 0xc3, 0x8c, 0x31, 0xc3, 0x00,
|
|
0x0c, 0x33, 0xcc, 0x90, 0x61, 0x06, 0x30, 0x86, 0x19, 0x66, 0x66, 0xc6, 0x8c, 0x31, 0xc3, 0x00, 0x0c, 0x73, 0x86, 0x19, 0x73, 0x8c, 0x31, 0xcc, 0x19, 0x66, 0x66, 0xcc, 0x8c, 0x31, 0xc3, 0x00,
|
|
0xf8, 0xb6, 0x03, 0x0f, 0x6e, 0xf8, 0x30, 0xb8, 0x19, 0x66, 0x66, 0xd8, 0x8c, 0x31, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0xf0, 0xb0, 0x03, 0x37, 0x3b, 0x9f, 0xdf, 0xb0, 0xc1, 0x03, 0xf0, 0xf0, 0x60, 0x3f, 0x63, 0x00,
|
|
0x98, 0x71, 0x86, 0x39, 0x8f, 0x31, 0xc6, 0xb0, 0xc1, 0xc3, 0xf0, 0xf0, 0x60, 0x30, 0x63, 0x00, 0x0c, 0x33, 0xcc, 0x30, 0x87, 0x01, 0xc6, 0x30, 0x63, 0xc6, 0x98, 0x99, 0x31, 0x18, 0x63, 0x00,
|
|
0x0c, 0x33, 0xcc, 0x30, 0x83, 0x03, 0xc6, 0x30, 0x63, 0xe6, 0x19, 0x8f, 0x31, 0x18, 0x63, 0x00, 0x0c, 0x33, 0xcc, 0x30, 0x03, 0x1f, 0xc6, 0x30, 0x63, 0xe6, 0x19, 0x86, 0x31, 0x0c, 0x63, 0x00,
|
|
0x0c, 0x33, 0xcc, 0x30, 0x03, 0x38, 0xc6, 0x30, 0x36, 0x2c, 0x0d, 0x0f, 0x1b, 0x06, 0x63, 0x00, 0x0c, 0x33, 0xcc, 0x30, 0x03, 0x30, 0xc6, 0x30, 0x36, 0x3c, 0x8f, 0x19, 0x1b, 0x06, 0x63, 0x00,
|
|
0x98, 0x71, 0x86, 0x39, 0x83, 0x31, 0x86, 0x39, 0x1c, 0x18, 0xc6, 0x30, 0x0e, 0x03, 0x36, 0x00, 0xf0, 0xb0, 0x03, 0x37, 0x03, 0x1f, 0x1c, 0x37, 0x1c, 0x18, 0xc6, 0x30, 0x0e, 0x3f, 0x1c, 0x00,
|
|
0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
|
0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xf0, 0xe1, 0x03, 0xc6, 0x1f, 0x1e, 0x7f, 0x7c, 0xf8, 0x00, 0x01, 0x7f, 0x80, 0x0f, 0x00,
|
|
0x78, 0x18, 0x33, 0x06, 0xc6, 0x00, 0x03, 0x60, 0xc6, 0x8c, 0x81, 0x03, 0xc3, 0xc0, 0x18, 0x00, 0x60, 0x08, 0x13, 0x06, 0xc7, 0x80, 0x01, 0x60, 0xc6, 0x8c, 0x81, 0x03, 0x83, 0x61, 0x30, 0x00,
|
|
0x60, 0x00, 0x03, 0x06, 0xc7, 0x80, 0x01, 0x30, 0xc6, 0x8c, 0xc1, 0x06, 0x83, 0x61, 0x30, 0x00, 0x60, 0x00, 0x03, 0x86, 0xc7, 0x8f, 0x01, 0x30, 0xc6, 0x8c, 0xc1, 0x06, 0xc3, 0x30, 0x00, 0x00,
|
|
0x60, 0x80, 0xc1, 0xc3, 0xc6, 0x98, 0x1f, 0x18, 0x7c, 0x8c, 0x61, 0x0c, 0x7f, 0x30, 0x00, 0x00, 0x60, 0xc0, 0x00, 0xc6, 0x06, 0x98, 0x31, 0x18, 0xc6, 0xf8, 0x61, 0x0c, 0xc3, 0x30, 0x00, 0x00,
|
|
0x60, 0x60, 0x00, 0x66, 0x06, 0x98, 0x31, 0x18, 0xc6, 0x80, 0x31, 0x18, 0x83, 0x31, 0x00, 0x00, 0x60, 0x30, 0x00, 0xe6, 0x0f, 0x98, 0x31, 0x0c, 0xc6, 0x80, 0xf1, 0x1f, 0x83, 0x61, 0x30, 0x00,
|
|
0x60, 0x18, 0x10, 0x06, 0x46, 0x98, 0x31, 0x0c, 0xc6, 0x80, 0x19, 0x30, 0x83, 0x61, 0x30, 0x00, 0x60, 0x18, 0x30, 0x06, 0xc6, 0x98, 0x31, 0x0c, 0xc6, 0xc0, 0x18, 0x30, 0xc3, 0xc0, 0x18, 0x00,
|
|
0x60, 0xf8, 0xe3, 0x03, 0x86, 0x0f, 0x1f, 0x0c, 0x7c, 0x78, 0x18, 0x30, 0x7f, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0xf8, 0x81, 0x7f, 0xfc, 0x83, 0x0f, 0x06, 0x63, 0xc0, 0x18, 0xc6, 0x00, 0x03, 0xc6, 0x60, 0x00, 0x18, 0x83, 0x01, 0x0c, 0xc0, 0x18, 0x06, 0x63, 0xc0, 0x18, 0xc3, 0x00, 0x03, 0xc6, 0x60, 0x00,
|
|
0x18, 0x86, 0x01, 0x0c, 0x60, 0x30, 0x06, 0x63, 0xc0, 0x98, 0xc1, 0x00, 0x07, 0xc7, 0x61, 0x00, 0x18, 0x86, 0x01, 0x0c, 0x60, 0x30, 0x06, 0x63, 0xc0, 0xd8, 0xc0, 0x00, 0x07, 0xc7, 0x63, 0x00,
|
|
0x18, 0x8c, 0x01, 0x0c, 0x30, 0x00, 0x06, 0x63, 0xc0, 0x78, 0xc0, 0x00, 0x8f, 0xc7, 0x67, 0x00, 0x18, 0x8c, 0x3f, 0xfc, 0x31, 0x00, 0xfe, 0x63, 0xc0, 0x38, 0xc0, 0x00, 0x8f, 0xc7, 0x66, 0x00,
|
|
0x18, 0x8c, 0x01, 0x0c, 0x30, 0x3e, 0x06, 0x63, 0xc0, 0x78, 0xc0, 0x00, 0xdb, 0xc6, 0x6c, 0x00, 0x18, 0x8c, 0x01, 0x0c, 0x30, 0x30, 0x06, 0x63, 0xc0, 0xd8, 0xc0, 0x00, 0xdb, 0xc6, 0x7c, 0x00,
|
|
0x18, 0x86, 0x01, 0x0c, 0x60, 0x30, 0x06, 0x63, 0xc6, 0x98, 0xc1, 0x00, 0x73, 0xc6, 0x78, 0x00, 0x18, 0x86, 0x01, 0x0c, 0x60, 0x38, 0x06, 0x63, 0xc6, 0x18, 0xc3, 0x00, 0x73, 0xc6, 0x70, 0x00,
|
|
0x18, 0x83, 0x01, 0x0c, 0xc0, 0x38, 0x06, 0x63, 0x6c, 0x18, 0xc6, 0x00, 0x23, 0xc6, 0x60, 0x00, 0xf8, 0x81, 0x7f, 0x0c, 0x80, 0x2f, 0x06, 0x63, 0x38, 0x18, 0xcc, 0x3f, 0x23, 0xc6, 0x60, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x7f, 0xc0, 0x03, 0x7f, 0xc0, 0xe3, 0x7f, 0x06, 0x33, 0xb0, 0x01, 0xd8, 0xc0, 0x00,
|
|
0x60, 0x06, 0xc3, 0x60, 0x06, 0xc3, 0x60, 0x06, 0x06, 0x06, 0x33, 0xb0, 0x61, 0xd8, 0xc0, 0x00, 0x30, 0x0c, 0x83, 0x31, 0x0c, 0x83, 0x31, 0x0c, 0x06, 0x06, 0x63, 0x98, 0x61, 0x98, 0x61, 0x00,
|
|
0x30, 0x0c, 0x83, 0x31, 0x0c, 0x83, 0x31, 0x00, 0x06, 0x06, 0x63, 0x18, 0x63, 0x0c, 0x33, 0x00, 0x18, 0x18, 0x83, 0x19, 0x18, 0x83, 0x61, 0x00, 0x06, 0x06, 0x63, 0x18, 0xf3, 0x0c, 0x1e, 0x00,
|
|
0x18, 0x18, 0xc3, 0x18, 0x18, 0xc3, 0xc0, 0x03, 0x06, 0x06, 0xc3, 0x0c, 0xf3, 0x0c, 0x0c, 0x00, 0x18, 0x18, 0x7f, 0x18, 0x18, 0x7f, 0x00, 0x06, 0x06, 0x06, 0xc3, 0x0c, 0x96, 0x06, 0x0c, 0x00,
|
|
0x18, 0x18, 0x03, 0x98, 0x19, 0xc3, 0x00, 0x0c, 0x06, 0x06, 0x83, 0x04, 0x9e, 0x07, 0x1e, 0x00, 0x30, 0x0c, 0x03, 0x30, 0x0f, 0x83, 0x01, 0x0c, 0x06, 0x06, 0x83, 0x07, 0x9e, 0x07, 0x33, 0x00,
|
|
0x30, 0x0c, 0x03, 0x30, 0x0e, 0x83, 0x31, 0x0c, 0x06, 0x06, 0x83, 0x07, 0x0c, 0x83, 0x61, 0x00, 0x60, 0x06, 0x03, 0x60, 0x0e, 0x83, 0x61, 0x06, 0x06, 0x8c, 0x01, 0x03, 0x0c, 0xc3, 0xc0, 0x00,
|
|
0xc0, 0x03, 0x03, 0xc0, 0x1b, 0x03, 0xc3, 0x03, 0x06, 0xf8, 0x00, 0x03, 0x0c, 0xc3, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x0c, 0xec, 0x3f, 0x00, 0x03, 0x00, 0x00, 0x80, 0xf1, 0x80, 0x07, 0xf0, 0x03, 0x08, 0x1c, 0x18, 0x0c, 0x0c, 0x30, 0x00, 0x03, 0x00, 0x66, 0x80, 0x99, 0xc1, 0x0c, 0x1c, 0x0e, 0x3e, 0x36, 0x0c,
|
|
0x18, 0x06, 0x18, 0x00, 0x03, 0x00, 0xc3, 0x80, 0x0d, 0x63, 0x18, 0x06, 0x18, 0x6b, 0x36, 0x06, 0x30, 0x03, 0x0c, 0x00, 0x33, 0x83, 0x81, 0x81, 0x01, 0x63, 0x18, 0xc6, 0x19, 0x6b, 0x36, 0x03,
|
|
0x30, 0x03, 0x0c, 0x00, 0x33, 0xc3, 0x00, 0xc3, 0x00, 0x63, 0x18, 0x63, 0x33, 0x0b, 0x9c, 0x01, 0xe0, 0x01, 0x06, 0x00, 0x03, 0x60, 0x00, 0xc6, 0x80, 0x61, 0x18, 0x33, 0x33, 0x0b, 0xc0, 0x00,
|
|
0xe0, 0x01, 0x03, 0x00, 0x03, 0x30, 0x00, 0xcc, 0xc0, 0x60, 0x18, 0x33, 0x33, 0x3e, 0x60, 0x00, 0xc0, 0x80, 0x01, 0x00, 0x03, 0x60, 0x00, 0xc6, 0x60, 0x30, 0x30, 0x33, 0x33, 0x68, 0x30, 0x07,
|
|
0xc0, 0x80, 0x01, 0x00, 0x03, 0xc0, 0x00, 0x63, 0x60, 0x60, 0x18, 0x33, 0x1b, 0x68, 0x98, 0x0d, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x81, 0x61, 0x00, 0x60, 0x18, 0xe6, 0x0e, 0x6b, 0x8c, 0x0d,
|
|
0xc0, 0x60, 0x80, 0x19, 0x33, 0x03, 0xc3, 0x60, 0x60, 0x60, 0x18, 0x06, 0x00, 0x6b, 0x86, 0x0d, 0xc0, 0xe0, 0xbf, 0x19, 0x33, 0x03, 0x66, 0x60, 0x60, 0x60, 0x18, 0x1c, 0x00, 0x3e, 0x03, 0x07,
|
|
0x00, 0x00, 0xc0, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x60, 0x18, 0xf0, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0xc0, 0x01, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x60, 0x03, 0x00, 0x66, 0x00, 0x0c, 0x00, 0x00, 0x0c, 0x03, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x33, 0xc3, 0x00, 0x0c, 0x00, 0x00, 0x0c, 0x03, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0xc0, 0x01, 0x33, 0xc3, 0x00, 0x0c, 0x7f, 0x00, 0x0c, 0x03, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x1e, 0xc3, 0x00, 0x0c, 0x00, 0x00, 0x0c, 0x03, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0xe0, 0x81, 0x7f, 0xc3, 0x80, 0x7f, 0x00, 0x00, 0x0c, 0x03, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1b, 0x1e, 0xc3, 0x3e, 0x0c, 0x7f, 0x00, 0x0c, 0x03, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x30, 0x0f, 0x33, 0xc3, 0x00, 0x0c, 0x00, 0x00, 0x0c, 0x83, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x06, 0x33, 0xc3, 0x00, 0x0c, 0x00, 0x00, 0x0c, 0x03, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x30, 0x0f, 0x00, 0xc3, 0x00, 0x0c, 0x00, 0x00, 0x0c, 0x03, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0d, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0xff, 0x0d, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
};
|
|
|
|
static const unsigned char GlyphData[] =
|
|
{
|
|
0x20, 0x4b, 0x80, 0x04, 0x21, 0x1e, 0x70, 0x05, 0x23, 0x4f, 0x80, 0x09, 0x24, 0x67, 0x70, 0x09, 0x25, 0x70, 0x70, 0x0d, 0x26, 0x03, 0x80, 0x0b, 0x28, 0x17, 0x80, 0x05, 0x29, 0x1c, 0x80, 0x05,
|
|
0x2a, 0x0e, 0x80, 0x09, 0x2b, 0x26, 0x80, 0x09, 0x2c, 0x16, 0x70, 0x04, 0x2d, 0x21, 0x80, 0x05, 0x2e, 0x1a, 0x70, 0x04, 0x2f, 0x3d, 0x70, 0x04, 0x30, 0x6f, 0x24, 0x09, 0x31, 0x01, 0x37, 0x09,
|
|
0x32, 0x0a, 0x37, 0x09, 0x33, 0x13, 0x37, 0x09, 0x34, 0x1c, 0x37, 0x09, 0x35, 0x25, 0x37, 0x09, 0x36, 0x2e, 0x37, 0x09, 0x37, 0x37, 0x37, 0x09, 0x38, 0x40, 0x37, 0x09, 0x39, 0x49, 0x37, 0x09,
|
|
0x3a, 0x27, 0x70, 0x04, 0x3b, 0x23, 0x70, 0x04, 0x3c, 0x2b, 0x70, 0x09, 0x3d, 0x2f, 0x80, 0x09, 0x3e, 0x34, 0x70, 0x09, 0x3f, 0x41, 0x70, 0x0a, 0x40, 0x57, 0x70, 0x10, 0x41, 0x52, 0x37, 0x0c,
|
|
0x42, 0x5e, 0x37, 0x0c, 0x43, 0x6a, 0x37, 0x0c, 0x44, 0x01, 0x4a, 0x0c, 0x45, 0x0d, 0x4a, 0x0b, 0x46, 0x18, 0x4a, 0x0a, 0x47, 0x22, 0x4a, 0x0d, 0x48, 0x2f, 0x4a, 0x0c, 0x49, 0x3b, 0x4a, 0x05,
|
|
0x4a, 0x40, 0x4a, 0x09, 0x4b, 0x49, 0x4a, 0x0b, 0x4c, 0x54, 0x4a, 0x0a, 0x4d, 0x5e, 0x4a, 0x0e, 0x4e, 0x6c, 0x4a, 0x0c, 0x4f, 0x01, 0x5d, 0x0d, 0x50, 0x0e, 0x5d, 0x0b, 0x51, 0x19, 0x5d, 0x0d,
|
|
0x52, 0x26, 0x5d, 0x0c, 0x53, 0x32, 0x5d, 0x0b, 0x54, 0x3d, 0x5d, 0x0a, 0x55, 0x47, 0x5d, 0x0c, 0x56, 0x53, 0x5d, 0x0b, 0x57, 0x5e, 0x5d, 0x0f, 0x58, 0x6d, 0x5d, 0x0b, 0x59, 0x01, 0x70, 0x0b,
|
|
0x5a, 0x0c, 0x70, 0x0a, 0x5b, 0x41, 0x80, 0x05, 0x5d, 0x46, 0x80, 0x05, 0x5f, 0x38, 0x80, 0x09, 0x61, 0x01, 0x11, 0x0a, 0x62, 0x0b, 0x11, 0x0a, 0x63, 0x15, 0x11, 0x09, 0x64, 0x1e, 0x11, 0x0a,
|
|
0x65, 0x28, 0x11, 0x0a, 0x66, 0x32, 0x11, 0x06, 0x67, 0x38, 0x11, 0x0a, 0x68, 0x42, 0x11, 0x0a, 0x69, 0x4c, 0x11, 0x04, 0x6a, 0x50, 0x11, 0x04, 0x6b, 0x54, 0x11, 0x09, 0x6c, 0x5d, 0x11, 0x04,
|
|
0x6d, 0x61, 0x11, 0x0e, 0x6e, 0x6f, 0x11, 0x0a, 0x6f, 0x01, 0x24, 0x0a, 0x70, 0x0b, 0x24, 0x0a, 0x71, 0x15, 0x24, 0x0a, 0x72, 0x1f, 0x24, 0x07, 0x73, 0x26, 0x24, 0x09, 0x74, 0x2f, 0x24, 0x06,
|
|
0x75, 0x35, 0x24, 0x0a, 0x76, 0x3f, 0x24, 0x09, 0x77, 0x48, 0x24, 0x0e, 0x78, 0x56, 0x24, 0x08, 0x79, 0x5e, 0x24, 0x09, 0x7a, 0x67, 0x24, 0x08, 0x7b, 0x4b, 0x70, 0x06, 0x7d, 0x51, 0x70, 0x06,
|
|
0x00
|
|
};
|
|
|
|
// ============================================================================
|
|
|
|
TexFont gTexFont;
|
|
|
|
TexFont::TexFont()
|
|
{
|
|
memset(&mGlyphs, 0, sizeof(mGlyphs));
|
|
}
|
|
|
|
bool TexFont::Initialize(lcContext* Context)
|
|
{
|
|
if (mTexture)
|
|
return true;
|
|
|
|
mFontHeight = 16;
|
|
mSDF = gSupportsShaderObjects;
|
|
|
|
// Keep the original binary atlas as a fixed-function fallback. SDF rendering
|
|
// requires only the shader support LeoCAD already uses for normal rendering.
|
|
if (!mSDF)
|
|
{
|
|
mTextureWidth = 128;
|
|
mTextureHeight = 128;
|
|
Image Image;
|
|
Image.Allocate(mTextureWidth, mTextureHeight, lcPixelFormat::L8A8);
|
|
for (unsigned int TexelIdx = 0; TexelIdx < sizeof(TextureData) * 8; TexelIdx++)
|
|
{
|
|
const unsigned char Texel = TextureData[TexelIdx / 8] & (1 << (TexelIdx % 8)) ? 255 : 0;
|
|
Image.mData[TexelIdx * 2] = Image.mData[TexelIdx * 2 + 1] = Texel;
|
|
}
|
|
|
|
const unsigned char* Ptr = GlyphData;
|
|
while (*Ptr)
|
|
{
|
|
const unsigned char Glyph = *Ptr++;
|
|
mGlyphs[Glyph].Left = *Ptr++;
|
|
mGlyphs[Glyph].Bottom = *Ptr++;
|
|
mGlyphs[Glyph].Width = *Ptr++;
|
|
mGlyphs[Glyph].Right = mGlyphs[Glyph].Left + mGlyphs[Glyph].Width;
|
|
mGlyphs[Glyph].Top = mGlyphs[Glyph].Bottom - mFontHeight;
|
|
mGlyphs[Glyph].RenderWidth = mGlyphs[Glyph].Width;
|
|
mGlyphs[Glyph].RenderHeight = mFontHeight;
|
|
mGlyphs[Glyph].Offset = 0.0f;
|
|
mGlyphs[Glyph].Left /= mTextureWidth;
|
|
mGlyphs[Glyph].Right /= mTextureWidth;
|
|
mGlyphs[Glyph].Top /= mTextureHeight;
|
|
mGlyphs[Glyph].Bottom /= mTextureHeight;
|
|
}
|
|
|
|
mTexture = new lcTexture();
|
|
mTexture->SetImage(std::move(Image), LC_TEXTURE_WRAPU | LC_TEXTURE_WRAPV | LC_TEXTURE_POINT);
|
|
mTexture->Upload(Context);
|
|
return true;
|
|
}
|
|
|
|
constexpr int Scale = 4, Padding = 8, TileWidth = 96, TileHeight = 80;
|
|
mTextureWidth = mTextureHeight = 1024;
|
|
Image Image;
|
|
Image.Allocate(mTextureWidth, mTextureHeight, lcPixelFormat::L8A8);
|
|
memset(Image.mData, 0, static_cast<size_t>(mTextureWidth) * mTextureHeight * 2);
|
|
|
|
QFont Font(QStringLiteral("Arial"));
|
|
Font.setPixelSize(56);
|
|
Font.setStyleStrategy(QFont::PreferAntialias);
|
|
const QFontMetrics Metrics(Font);
|
|
|
|
const unsigned char* Ptr = GlyphData;
|
|
int GlyphIndex = 0;
|
|
while (*Ptr)
|
|
{
|
|
const unsigned char Glyph = *Ptr++;
|
|
Ptr += 2; // Legacy atlas position; metrics now come from the vector font.
|
|
Ptr++;
|
|
const int Advance = Metrics.horizontalAdvance(QChar(Glyph));
|
|
const int TileX = (GlyphIndex % 10) * TileWidth;
|
|
const int TileY = (GlyphIndex / 10) * TileHeight;
|
|
const int MaskWidth = lcMin(TileWidth, Advance + Padding * 2);
|
|
std::vector<unsigned char> Mask(MaskWidth * TileHeight, 0);
|
|
QImage GlyphImage(MaskWidth, TileHeight, QImage::Format_Alpha8);
|
|
GlyphImage.fill(0);
|
|
QPainter Painter(&GlyphImage);
|
|
Painter.setRenderHint(QPainter::TextAntialiasing);
|
|
Painter.setPen(Qt::white);
|
|
Painter.setFont(Font);
|
|
Painter.drawText(Padding, Padding + (mFontHeight * Scale - Metrics.height()) / 2 + Metrics.ascent(), QString(QChar(Glyph)));
|
|
Painter.end();
|
|
|
|
for (int y = 0; y < TileHeight; y++)
|
|
for (int x = 0; x < MaskWidth; x++)
|
|
Mask[y * MaskWidth + x] = GlyphImage.constScanLine(y)[x] >= 128;
|
|
|
|
// A two-pass chamfer transform is compact and sufficiently accurate for
|
|
// the small, padded glyph tiles. Distances are in high-resolution pixels.
|
|
std::vector<int> ToInk(MaskWidth * TileHeight), ToOutside(MaskWidth * TileHeight);
|
|
for (int i = 0; i < MaskWidth * TileHeight; i++)
|
|
{
|
|
ToInk[i] = Mask[i] ? 0 : 1 << 20;
|
|
ToOutside[i] = Mask[i] ? 1 << 20 : 0;
|
|
}
|
|
auto Relax = [MaskWidth](std::vector<int>& Distance, bool Reverse)
|
|
{
|
|
for (int row = Reverse ? TileHeight - 1 : 0; Reverse ? row >= 0 : row < TileHeight; row += Reverse ? -1 : 1)
|
|
for (int column = Reverse ? MaskWidth - 1 : 0; Reverse ? column >= 0 : column < MaskWidth; column += Reverse ? -1 : 1)
|
|
{
|
|
int& Value = Distance[row * MaskWidth + column];
|
|
const int RowStep = Reverse ? 1 : -1, ColumnStep = Reverse ? 1 : -1;
|
|
if (row + RowStep >= 0 && row + RowStep < TileHeight)
|
|
Value = lcMin(Value, Distance[(row + RowStep) * MaskWidth + column] + 3);
|
|
if (column + ColumnStep >= 0 && column + ColumnStep < MaskWidth)
|
|
Value = lcMin(Value, Distance[row * MaskWidth + column + ColumnStep] + 3);
|
|
if (row + RowStep >= 0 && row + RowStep < TileHeight && column + ColumnStep >= 0 && column + ColumnStep < MaskWidth)
|
|
Value = lcMin(Value, Distance[(row + RowStep) * MaskWidth + column + ColumnStep] + 4);
|
|
}
|
|
};
|
|
Relax(ToInk, false); Relax(ToInk, true);
|
|
Relax(ToOutside, false); Relax(ToOutside, true);
|
|
|
|
for (int y = 0; y < TileHeight; y++)
|
|
for (int x = 0; x < MaskWidth; x++)
|
|
{
|
|
const int SignedDistance = (ToOutside[y * MaskWidth + x] - ToInk[y * MaskWidth + x]) / 3;
|
|
const unsigned char Value = static_cast<unsigned char>(lcClamp(128 + SignedDistance * 8, 0, 255));
|
|
unsigned char* Pixel = Image.mData + ((TileY + y) * mTextureWidth + TileX + x) * 2;
|
|
Pixel[0] = Pixel[1] = Value;
|
|
}
|
|
|
|
mGlyphs[Glyph].Width = Advance / static_cast<float>(Scale);
|
|
mGlyphs[Glyph].Offset = -Padding / static_cast<float>(Scale);
|
|
mGlyphs[Glyph].RenderWidth = MaskWidth / static_cast<float>(Scale);
|
|
mGlyphs[Glyph].RenderHeight = TileHeight / static_cast<float>(Scale);
|
|
mGlyphs[Glyph].Left = TileX / static_cast<float>(mTextureWidth);
|
|
mGlyphs[Glyph].Right = (TileX + MaskWidth) / static_cast<float>(mTextureWidth);
|
|
mGlyphs[Glyph].Top = TileY / static_cast<float>(mTextureHeight);
|
|
mGlyphs[Glyph].Bottom = (TileY + TileHeight) / static_cast<float>(mTextureHeight);
|
|
GlyphIndex++;
|
|
}
|
|
|
|
mTexture = new lcTexture();
|
|
mTexture->SetImage(std::move(Image), LC_TEXTURE_LINEAR);
|
|
mTexture->Upload(Context);
|
|
|
|
return true;
|
|
}
|
|
|
|
void TexFont::Reset()
|
|
{
|
|
mTexture = 0;
|
|
mSDF = false;
|
|
}
|
|
|
|
void TexFont::GetStringDimensions(int* cx, int* cy, const char* Text) const
|
|
{
|
|
*cy = mFontHeight;
|
|
float Width = 0.0f;
|
|
|
|
while (*Text != 0)
|
|
{
|
|
Width += mGlyphs[(int)(*Text)].Width;
|
|
Text++;
|
|
}
|
|
|
|
*cx = static_cast<int>(Width + 0.5f);
|
|
}
|
|
|
|
void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, const char* Text) const
|
|
{
|
|
const size_t Length = strlen(Text);
|
|
|
|
if (!Length)
|
|
return;
|
|
|
|
float* Verts = new float[6 * 5 * Length];
|
|
float* CurVert = Verts;
|
|
|
|
while (*Text)
|
|
{
|
|
int ch = *Text;
|
|
const float GlyphLeft = Left + mGlyphs[ch].Offset;
|
|
const float GlyphRight = GlyphLeft + mGlyphs[ch].RenderWidth;
|
|
const float GlyphTop = Top - mGlyphs[ch].Offset;
|
|
const float GlyphBottom = GlyphTop - mGlyphs[ch].RenderHeight;
|
|
|
|
*CurVert++ = GlyphLeft;
|
|
*CurVert++ = GlyphTop;
|
|
*CurVert++ = Z;
|
|
*CurVert++ = mGlyphs[ch].Left;
|
|
*CurVert++ = mGlyphs[ch].Top;
|
|
|
|
*CurVert++ = GlyphLeft;
|
|
*CurVert++ = GlyphBottom;
|
|
*CurVert++ = Z;
|
|
*CurVert++ = mGlyphs[ch].Left;
|
|
*CurVert++ = mGlyphs[ch].Bottom;
|
|
|
|
*CurVert++ = GlyphRight;
|
|
*CurVert++ = GlyphBottom;
|
|
*CurVert++ = Z;
|
|
*CurVert++ = mGlyphs[ch].Right;
|
|
*CurVert++ = mGlyphs[ch].Bottom;
|
|
|
|
*CurVert++ = GlyphRight;
|
|
*CurVert++ = GlyphBottom;
|
|
*CurVert++ = Z;
|
|
*CurVert++ = mGlyphs[ch].Right;
|
|
*CurVert++ = mGlyphs[ch].Bottom;
|
|
|
|
*CurVert++ = GlyphRight;
|
|
*CurVert++ = GlyphTop;
|
|
*CurVert++ = Z;
|
|
*CurVert++ = mGlyphs[ch].Right;
|
|
*CurVert++ = mGlyphs[ch].Top;
|
|
|
|
*CurVert++ = GlyphLeft;
|
|
*CurVert++ = GlyphTop;
|
|
*CurVert++ = Z;
|
|
*CurVert++ = mGlyphs[ch].Left;
|
|
*CurVert++ = mGlyphs[ch].Top;
|
|
|
|
Left += mGlyphs[ch].Width;
|
|
Text++;
|
|
}
|
|
|
|
Context->SetVertexBufferPointer(Verts);
|
|
Context->SetVertexFormat(0, 3, 0, 2, 0, false);
|
|
|
|
Context->DrawPrimitives(GL_TRIANGLES, 0, 6 * (GLsizei)Length);
|
|
|
|
delete[] Verts;
|
|
}
|
|
|
|
void TexFont::GetTriangles(const lcMatrix44& Transform, const char* Text, float* Buffer) const
|
|
{
|
|
float Width = 0.0f;
|
|
|
|
for (const char* ch = Text; *ch; ch++)
|
|
{
|
|
const int Glyph = *ch;
|
|
Width += mGlyphs[Glyph].Width;
|
|
}
|
|
|
|
float Left = -Width / 2.0f;
|
|
const float Top = mFontHeight / 2.0f;
|
|
const float Z = 0.0f;
|
|
|
|
while (*Text)
|
|
{
|
|
int ch = *Text;
|
|
|
|
const float GlyphLeft = Left + mGlyphs[ch].Offset;
|
|
const float GlyphRight = GlyphLeft + mGlyphs[ch].RenderWidth;
|
|
const float GlyphTop = Top - mGlyphs[ch].Offset;
|
|
const float GlyphBottom = GlyphTop - mGlyphs[ch].RenderHeight;
|
|
lcVector3 Points[4] =
|
|
{
|
|
lcVector3(GlyphLeft, GlyphTop, Z),
|
|
lcVector3(GlyphLeft, GlyphBottom, Z),
|
|
lcVector3(GlyphRight, GlyphBottom, Z),
|
|
lcVector3(GlyphRight, GlyphTop, Z),
|
|
};
|
|
|
|
for (int PointIdx = 0; PointIdx < 4; PointIdx++)
|
|
Points[PointIdx] = lcMul31(Points[PointIdx], Transform);
|
|
|
|
*Buffer++ = Points[0].x;
|
|
*Buffer++ = Points[0].y;
|
|
*Buffer++ = Points[0].z;
|
|
*Buffer++ = mGlyphs[ch].Left;
|
|
*Buffer++ = mGlyphs[ch].Top;
|
|
|
|
*Buffer++ = Points[1].x;
|
|
*Buffer++ = Points[1].y;
|
|
*Buffer++ = Points[1].z;
|
|
*Buffer++ = mGlyphs[ch].Left;
|
|
*Buffer++ = mGlyphs[ch].Bottom;
|
|
|
|
*Buffer++ = Points[2].x;
|
|
*Buffer++ = Points[2].y;
|
|
*Buffer++ = Points[2].z;
|
|
*Buffer++ = mGlyphs[ch].Right;
|
|
*Buffer++ = mGlyphs[ch].Bottom;
|
|
|
|
*Buffer++ = Points[2].x;
|
|
*Buffer++ = Points[2].y;
|
|
*Buffer++ = Points[2].z;
|
|
*Buffer++ = mGlyphs[ch].Right;
|
|
*Buffer++ = mGlyphs[ch].Bottom;
|
|
|
|
*Buffer++ = Points[3].x;
|
|
*Buffer++ = Points[3].y;
|
|
*Buffer++ = Points[3].z;
|
|
*Buffer++ = mGlyphs[ch].Right;
|
|
*Buffer++ = mGlyphs[ch].Top;
|
|
|
|
*Buffer++ = Points[0].x;
|
|
*Buffer++ = Points[0].y;
|
|
*Buffer++ = Points[0].z;
|
|
*Buffer++ = mGlyphs[ch].Left;
|
|
*Buffer++ = mGlyphs[ch].Top;
|
|
|
|
Left += mGlyphs[ch].Width;
|
|
Text++;
|
|
}
|
|
}
|
|
|
|
void TexFont::GetGlyphTriangles(float Left, float Top, float Z, int Glyph, float* Buffer) const
|
|
{
|
|
Left -= mGlyphs[Glyph].Width / 2.0f;
|
|
Top += mFontHeight / 2.0f;
|
|
const float GlyphLeft = Left + mGlyphs[Glyph].Offset;
|
|
const float GlyphRight = GlyphLeft + mGlyphs[Glyph].RenderWidth;
|
|
const float GlyphTop = Top - mGlyphs[Glyph].Offset;
|
|
const float GlyphBottom = GlyphTop - mGlyphs[Glyph].RenderHeight;
|
|
|
|
*Buffer++ = GlyphLeft;
|
|
*Buffer++ = GlyphTop;
|
|
*Buffer++ = Z;
|
|
*Buffer++ = mGlyphs[Glyph].Left;
|
|
*Buffer++ = mGlyphs[Glyph].Top;
|
|
|
|
*Buffer++ = GlyphLeft;
|
|
*Buffer++ = GlyphBottom;
|
|
*Buffer++ = Z;
|
|
*Buffer++ = mGlyphs[Glyph].Left;
|
|
*Buffer++ = mGlyphs[Glyph].Bottom;
|
|
|
|
*Buffer++ = GlyphRight;
|
|
*Buffer++ = GlyphBottom;
|
|
*Buffer++ = Z;
|
|
*Buffer++ = mGlyphs[Glyph].Right;
|
|
*Buffer++ = mGlyphs[Glyph].Bottom;
|
|
|
|
*Buffer++ = GlyphRight;
|
|
*Buffer++ = GlyphBottom;
|
|
*Buffer++ = Z;
|
|
*Buffer++ = mGlyphs[Glyph].Right;
|
|
*Buffer++ = mGlyphs[Glyph].Bottom;
|
|
|
|
*Buffer++ = GlyphRight;
|
|
*Buffer++ = GlyphTop;
|
|
*Buffer++ = Z;
|
|
*Buffer++ = mGlyphs[Glyph].Right;
|
|
*Buffer++ = mGlyphs[Glyph].Top;
|
|
|
|
*Buffer++ = GlyphLeft;
|
|
*Buffer++ = GlyphTop;
|
|
*Buffer++ = Z;
|
|
*Buffer++ = mGlyphs[Glyph].Left;
|
|
*Buffer++ = mGlyphs[Glyph].Top;
|
|
}
|