1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-14 00:54:05 +02:00
This commit is contained in:
XProger
2017-06-19 04:42:28 +03:00
4 changed files with 60 additions and 15 deletions

View File

@@ -11,6 +11,7 @@ namespace Debug {
static GLuint font;
void init() {
#ifdef WIN32
font = glGenLists(256);
HDC hdc = GetDC(0);
HFONT hfont = CreateFontA(-MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0,
@@ -20,6 +21,26 @@ namespace Debug {
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() {
@@ -557,10 +578,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);

View File

@@ -1,2 +1,3 @@
set -e
clang++ -std=c++11 -Os -s -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG main.cpp ../../libs/stb_vorbis/stb_vorbis.c -I../../ -o../../../bin/OpenLara -lX11 -lGL -lm -lpthread -lpulse-simple -lpulse
strip ../../../bin/OpenLara --strip-all --remove-section=.comment --remove-section=.note

View File

@@ -99,7 +99,25 @@ InputKey mouseToInputKey(int btn) {
return ikNone;
}
void WndProc(const XEvent &e) {
void toggle_fullscreen(Display* dpy, Window win) {
const size_t _NET_WM_STATE_TOGGLE=2;
XEvent xev;
Atom wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
Atom scr_full = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = win;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = _NET_WM_STATE_TOGGLE;
xev.xclient.data.l[1] = scr_full;
XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask, &xev);
}
void WndProc(const XEvent &e,Display*dpy,Window wnd) {
switch (e.type) {
case ConfigureNotify :
Core::width = e.xconfigure.width;
@@ -108,7 +126,7 @@ void WndProc(const XEvent &e) {
case KeyPress :
case KeyRelease :
if (e.type == KeyPress && (e.xkey.state & Mod1Mask) && e.xkey.keycode == 36) {
// TODO: windowed <-> fullscreen switch
toggle_fullscreen(dpy,wnd);
break;
}
Input::setDown(keyToInputKey(e.xkey.keycode), e.type == KeyPress);
@@ -183,7 +201,7 @@ int main() {
XNextEvent(dpy, &event);
if (event.type == ClientMessage && *event.xclient.data.l == WM_DELETE_WINDOW)
break;
WndProc(event);
WndProc(event,dpy,wnd);
} else {
int time = getTime();
if (time <= lastTime)

View File

@@ -7,7 +7,12 @@
#include <float.h>
#ifdef _DEBUG
#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