summaryrefslogtreecommitdiff
path: root/themes/WebglContext.h
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-10-05 07:11:20 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-10-05 07:11:20 -0400
commit2fff4c30c18a1b89c3240222cd915e7607563896 (patch)
treef3e31e68aa95318e96f484e2321ddc1d07b9d5e0 /themes/WebglContext.h
parentd781d5a3c1ec6872361db2a15786dfc0db9780f3 (diff)
Resizing working as intended
Diffstat (limited to 'themes/WebglContext.h')
-rw-r--r--themes/WebglContext.h38
1 files changed, 7 insertions, 31 deletions
diff --git a/themes/WebglContext.h b/themes/WebglContext.h
index 366c675..71540f0 100644
--- a/themes/WebglContext.h
+++ b/themes/WebglContext.h
@@ -1,42 +1,18 @@
#pragma once
#include "types.h"
+#include <cstring>
#include <emscripten.h>
#include <emscripten/html5.h>
#include <GLES2/gl2.h>
#include <EGL/egl.h>
-EM_BOOL onScreenSizeChanged(int eventType, const EmscriptenUiEvent *uiEvent, void *userData);
-
struct WebglContext {
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context;
- int width = 800;
- int height = 600;
-
- void init(const char* query, int inWidth = 800, int inHeight = 600) {
- width = inWidth;
- height = inHeight;
- emscripten_set_canvas_element_size( query, width, height);
-
- EmscriptenWebGLContextAttributes attrs;
- emscripten_webgl_init_context_attributes(&attrs);
-
- attrs.enableExtensionsByDefault = 1;
- attrs.majorVersion = 3;
- attrs.minorVersion = 0;
-
- context = emscripten_webgl_create_context(query, &attrs);
- makeCurrentContext();
-
- glClearColor(0, 0, 0, 0.0f);
+ int32 width = 800;
+ int32 height = 600;
+ char query[128];;
- emscripten_set_resize_callback(query, this, false, onScreenSizeChanged);
- };
-
- void makeCurrentContext() {
- emscripten_webgl_make_context_current(context);
- };
-
- void destroy() {
- emscripten_webgl_destroy_context(context);
- }
+ void init(const char* inQuery);
+ void makeCurrentContext();
+ void destroy() ;
};