void EmRenderWindow::initContext() { printf("Setting Emscripten Canvas size\n"); emscripten_set_canvas_size(m_width, m_height); EmscriptenWebGLContextAttributes attrs; emscripten_webgl_init_context_attributes(&attrs); attrs.depth = 1; attrs.stencil = 1; attrs.antialias = 1; attrs.majorVersion = 2; attrs.minorVersion = 0; assert(emscripten_webgl_get_current_context() == 0); printf("Creating Emscripten WebGL context\n"); m_window = emscripten_webgl_create_context("canvas", &attrs); printf("Created Emscripten WebGL context %i\n", m_window); emscripten_webgl_make_context_current(m_window); #if defined TOY_PLATFORM_LINUX || defined TOY_PLATFORM_BSD m_nativeHandle = (void*)(uintptr_t)glfwGetX11Window(_window); #elif defined TOY_PLATFORM_OSX m_nativeHandle = glfwGetCocoaWindow(_window); #elif defined TOY_PLATFORM_WINDOWS m_nativeHandle = glfwGetWin32Window(m_glWindow); #endif }
static void* glfwNativeWindowHandle(GLFWwindow* _window) { # if BX_PLATFORM_LINUX || BX_PLATFORM_BSD return (void*)(uintptr_t)glfwGetX11Window(_window); # elif BX_PLATFORM_OSX return glfwGetCocoaWindow(_window); # elif BX_PLATFORM_WINDOWS return glfwGetWin32Window(_window); # endif // BX_PLATFORM_ }
wnd_t app_window_gethandle() { ASSERT(g_app); ASSERT(g_app->wnd); #if defined(_LINUX_) return glfwGetX11Window(g_app->wnd); #elif defined(_WIN_) return glfwGetWin32Window(g_app->wnd); #elif defined(_OSX_) return glfwGetCocoaWindow(g_app->wnd); #endif }
void * getNativeWindowHandle(GLFWwindow * window) { void * nativeWindowHandle = nullptr; ON_WINDOWS([&] { nativeWindowHandle = (void*)glfwGetWin32Window(window); }); ON_LINUX([&] { nativeWindowHandle = (void*)glfwGetX11Window(window); }); ON_MAC([&] { nativeWindowHandle = (void*)glfwGetCocoaWindow(window); }); return nativeWindowHandle; }