/
Zamar_Terrier
/
TigorEngineWeb2
Обзор
Документация
Войти
/
Zamar_Terrier
/
TigorEngineWeb2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/window_manager.c
172 строки
5 KB
Ilia Zamaruev
wasi delete and make local mini stb lib
17 фев 2026, 16:41
17 фев 2026, 16:41
f5863af
Код
Авторство
О чём код?
#include "window_manager.h" #include "e_window.h" #include "malloc.h" wManagerWindow _wMWindow; extern TEngine engine; // Internal key state used for sticky keys #define _TIGOR_STICK 3 extern void createKeyTables(void* wData); void wManagerDefaultWindowHints(wManagerWindow *window) { // The default is a focused, visible, resizable window with decorations memset(&window->hints.window, 0, sizeof(window->hints.window)); window->hints.window.resizable = true; window->hints.window.visible = true; window->hints.window.decorated = true; window->hints.window.focused = true; window->hints.window.autoIconify = true; window->hints.window.centerCursor = true; window->hints.window.focusOnShow = true; window->hints.window.xpos = TIGOR_ANY_POSITION; window->hints.window.ypos = TIGOR_ANY_POSITION; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered memset(&window->hints.framebuffer, 0, sizeof(window->hints.framebuffer)); window->hints.framebuffer.redBits = 8; window->hints.framebuffer.greenBits = 8; window->hints.framebuffer.blueBits = 8; window->hints.framebuffer.alphaBits = 8; window->hints.framebuffer.depthBits = 24; window->hints.framebuffer.stencilBits = 8; window->hints.framebuffer.doublebuffer = true; // The default is to select the highest available refresh rate window->hints.refreshRate = TIGOR_DONT_CARE; // The default is to use full Retina resolution framebuffers window->hints.window.ns.retina = true; window->cursorMode = TIGOR_CURSOR_NORMAL; } void wManagerTerminate() { TWindow *window = (TWindow *)engine.window; wManagerWindow *wManager = window->e_window; free(wManager->WindowData); free(_wMWindow.WindowData); free(window->e_window); } int wManagerInit(){ TWindow *window = (TWindow *)engine.window; window->e_window = calloc(1, sizeof(wManagerWindow)); wManagerWindow *wManager = window->e_window; wManager->WindowData = calloc(1, sizeof(wManagerWeb)); _wMWindow.WindowData = calloc(1, sizeof(wManagerWeb)); extern int32_t _wManagerConnectWeb(_wManagerPlatform* platform); _wManagerConnectWeb(&_wMWindow.platform); _wManagerConnectWeb(&wManager->platform); if (!_wMWindow.platform.init()) { wManagerTerminate(); return false; } wManagerDefaultWindowHints(&_wMWindow); wManagerDefaultWindowHints(window->e_window); createKeyTables(_wMWindow.WindowData); createKeyTables(wManager->WindowData); return 1; } int wManagerGetMouseButton(wManagerWindow *window, int button) { if (button < TIGOR_MOUSE_BUTTON_1 || (button > TIGOR_MOUSE_BUTTON_LAST)) { #ifndef NDEBUG //consoleLog("Invalid mouse button %i\n", button); #endif return TIGOR_RELEASE; } if (window->mouseButtons[button] == _TIGOR_STICK) { // Sticky mode: release mouse button now window->mouseButtons[button] = TIGOR_RELEASE; return TIGOR_PRESS; } return (int) window->mouseButtons[button]; } int wManagerGetKey(wManagerWindow *window, int key) { if (key < TIGOR_KEY_SPACE || (key > TIGOR_KEY_LAST)) { #ifndef NDEBUG //consoleLog("Invalid key %i\n", key); #endif return TIGOR_RELEASE; } if (window->keys[key] == _TIGOR_STICK) { // Sticky mode: release key now window->keys[key] = TIGOR_RELEASE; return TIGOR_PRESS; } return (int) window->keys[key]; } void wManagerSetClipboardString(wManagerWindow *window, const char *string) { return _wMWindow.platform.setClipboardString(string); } const char *wManagerGetClipboardString(wManagerWindow *window) { return _wMWindow.platform.getClipboardString(); } void wManagerSetCharCallback(wManagerWindow *window, wManagerCharacterFunc EngineCharacterCallback) { window->callbacks.character = EngineCharacterCallback; } void wManagerSetKeyCallback(wManagerWindow *window, wManagerKeyFunc EngineKeyCallback) { window->callbacks.key = EngineKeyCallback; } void wManagerGetCursorPos(wManagerWindow *window, double *xpos, double *ypos) { window->platform.getCursorPos(window, xpos, ypos); } void wManagerSetCursorPos(wManagerWindow *window, double xpos, double ypos) { window->platform.setCursorPos(window, xpos, ypos); } void wManagerSetMouseButtonCallback(wManagerWindow *window, wManagerMouseButtonFun func) { window->callbacks.mouseButton = func; } void wManagerSetCursorPosCallback(wManagerWindow *window, wManagerCursorPosFun callback) { window->callbacks.cursorPos = (wManagerCursorPos)callback; }