#pragma once #include "types.h" #include #include #include #include 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); }; void makeCurrentContext() { emscripten_webgl_make_context_current(context); }; void destroy() { emscripten_webgl_destroy_context(context); } };