From f408f179d257feb6795401db4fa0c1fcc357db81 Mon Sep 17 00:00:00 2001 From: Gemma Peter Date: Fri, 2 Jun 2017 01:21:10 +0100 Subject: [PATCH 1/3] debugBreak function for Linux --- src/utils.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils.h b/src/utils.h index b8241df..3d9312e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -7,7 +7,12 @@ #include #ifdef _DEBUG - #define debugBreak() _asm { int 3 } + #ifdef LINUX + #define debugBreak() raise(SIGTRAP); + #else + #define debugBreak() _asm { int 3 } + #endif + #define ASSERT(expr) if (expr) {} else { LOG("ASSERT %s in %s:%d\n", #expr, __FILE__, __LINE__); debugBreak(); } #ifndef ANDROID From 8e994211d2450e9638233ad7d3e67692c263e2b4 Mon Sep 17 00:00:00 2001 From: Gemma Peter Date: Fri, 2 Jun 2017 01:45:09 +0100 Subject: [PATCH 2/3] Prevent type errors when compiling with GCC --- src/debug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debug.h b/src/debug.h index 1e19566..58a3c7f 100644 --- a/src/debug.h +++ b/src/debug.h @@ -557,10 +557,10 @@ namespace Debug { uint32 data; uint32 dataSize; } header = { - FOURCC("RIFF"), sizeof(Header) - 8 + dataSize, + FOURCC("RIFF"), (uint32) sizeof(Header) - 8 + dataSize, FOURCC("WAVE"), FOURCC("fmt "), 16, { 1, 1, 44100, 44100 * 16 / 8, 0, 16 }, - FOURCC("data"), dataSize + FOURCC("data"), (uint32) dataSize }; fwrite(&header, sizeof(header), 1, f); From e76f38b1e4f749848e54ed693e1a3a0512790e01 Mon Sep 17 00:00:00 2001 From: Gemma Peter Date: Fri, 2 Jun 2017 01:57:41 +0100 Subject: [PATCH 3/3] Debug text font setup for Linux --- src/debug.h | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/debug.h b/src/debug.h index 58a3c7f..ebce4f0 100644 --- a/src/debug.h +++ b/src/debug.h @@ -11,15 +11,36 @@ namespace Debug { static GLuint font; void init() { - font = glGenLists(256); - HDC hdc = GetDC(0); - HFONT hfont = CreateFontA(-MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, - 0, 0, FW_BOLD, 0, 0, 0, - ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, - ANTIALIASED_QUALITY, DEFAULT_PITCH, "Courier New"); - SelectObject(hdc, hfont); - wglUseFontBitmaps(hdc, 0, 256, font); - DeleteObject(hfont); + #ifdef WIN32 + font = glGenLists(256); + HDC hdc = GetDC(0); + HFONT hfont = CreateFontA(-MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, + 0, 0, FW_BOLD, 0, 0, 0, + ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, + ANTIALIASED_QUALITY, DEFAULT_PITCH, "Courier New"); + SelectObject(hdc, hfont); + wglUseFontBitmaps(hdc, 0, 256, font); + DeleteObject(hfont); + #elif LINUX + XFontStruct *fontInfo; + Font id; + unsigned int first, last; + fontInfo = XLoadQueryFont(glXGetCurrentDisplay(), "-adobe-times-medium-r-normal--17-120-100-100-p-88-iso8859-1"); + + if (fontInfo == NULL) { + LOG("no font found\n"); + } + + id = fontInfo->fid; + first = fontInfo->min_char_or_byte2; + last = fontInfo->max_char_or_byte2; + + font = glGenLists(last + 1); + if (font == 0) { + LOG("out of display lists\n"); + } + glXUseXFont(id, first, last - first + 1, font + first); + #endif } void free() {