diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 742a5cdd3..447228496 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,10 +37,7 @@ if(WIN32) win32_window.cpp ) - target_link_libraries(src Dwmapi Imm32) - - find_package(glbinding REQUIRED) - target_link_libraries(src glbinding::glbinding Opengl32) + target_link_libraries(src Dwmapi Imm32 Opengl32) set(D3D_SHADERS "d3d10_pixel.hlsl\;ps_4_0" diff --git a/src/opengl_renderer.cpp b/src/opengl_renderer.cpp index 19a58f59d..0b7ecf49c 100644 --- a/src/opengl_renderer.cpp +++ b/src/opengl_renderer.cpp @@ -23,8 +23,10 @@ #ifdef __APPLE__ # include #elif _WIN32 -# include -using namespace gl32; +# include +constexpr int GL_TEXTURE_WRAP_S { 0x2802 }, + GL_TEXTURE_WRAP_T { 0x2803 }, + GL_REPEAT { 0x2901 }; #else # include #endif diff --git a/src/win32_opengl.cpp b/src/win32_opengl.cpp index f3a9e2082..9547f9076 100644 --- a/src/win32_opengl.cpp +++ b/src/win32_opengl.cpp @@ -20,8 +20,9 @@ #include "error.hpp" #include "window.hpp" -#include +#define IMGL3W_IMPL #include +#include // https://registry.khronos.org/OpenGL/api/GL/wglext.h constexpr int WGL_CONTEXT_MAJOR_VERSION_ARB { 0x2091 }, @@ -31,11 +32,6 @@ constexpr int WGL_CONTEXT_MAJOR_VERSION_ARB { 0x2091 }, typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); -static glbinding::ProcAddress getProcAddress(const char *funcName) -{ - return reinterpret_cast(wglGetProcAddress(funcName)); -} - class Win32OpenGL : public OpenGLRenderer { public: Win32OpenGL(RendererFactory *, Window *); @@ -59,7 +55,6 @@ class MakeCurrent { : m_gl { gl } { wglMakeCurrent(dc, m_gl); - glbinding::useContext(reinterpret_cast(m_gl)); } ~MakeCurrent() @@ -74,7 +69,6 @@ class MakeCurrent { struct GLDeleter { void operator()(HGLRC gl) { - glbinding::releaseContext(reinterpret_cast(gl)); wglDeleteContext(gl); } }; @@ -135,31 +129,30 @@ void Win32OpenGL::setPixelFormat() void Win32OpenGL::createContext() { HGLRC dummyGl { wglCreateContext(m_dc) }; // creates a legacy (< 2.1) context - wglMakeCurrent(m_dc, dummyGl); + wglMakeCurrent(m_dc, m_gl = dummyGl); PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB { reinterpret_cast (wglGetProcAddress("wglCreateContextAttribsARB")) }; - if(!wglCreateContextAttribsARB) - throw backend_error { "OpenGL 3 is not available on this system" }; - - // https://www.khronos.org/registry/OpenGL/extensions/ARB/WGL_ARB_create_context.txt - constexpr int attrs[] { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 2, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; - - m_gl = wglCreateContextAttribsARB(m_dc, nullptr, attrs); - wglMakeCurrent(m_dc, m_gl); - wglDeleteContext(dummyGl); - - if(!m_gl) - throw backend_error { "failed to initialize OpenGL 3.2 core context" }; + if(wglCreateContextAttribsARB) { + // https://www.khronos.org/registry/OpenGL/extensions/ARB/WGL_ARB_create_context.txt + constexpr int attrs[] { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 2, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; + + if(HGLRC coreGl { wglCreateContextAttribsARB(m_dc, nullptr, attrs) }) { + wglMakeCurrent(m_dc, m_gl = coreGl); + wglDeleteContext(dummyGl); + } + } - glbinding::useContext(reinterpret_cast(m_gl)); - glbinding::initialize(getProcAddress, false); + if(imgl3wInit()) { + wglDeleteContext(m_gl); + throw backend_error { "OpenGL 3.2 is not available on this system" }; + } } void Win32OpenGL::render(void *) diff --git a/vcpkg.json b/vcpkg.json index 8a15ded55..4ca6bad9d 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -9,7 +9,6 @@ { "name": "boost-variant2", "platform": "!windows" }, { "name": "freetype", "default-features": false, "features": ["png", "zlib"], "platform": "!linux" }, - { "name": "glbinding", "platform": "windows" }, { "name": "libjpeg-turbo" }, { "name": "libpng", "platform": "!linux" }, "cmark",