From 0d205a19dc087768da1e803d8dfde27f12cb9d99 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 26 Jan 2021 01:28:33 +0200 Subject: [PATCH] Fix compile errors from function casts in wgl Recent gcc versions don't like casting directly between incompatible function types. --- source/graphics/wgl/glcontext.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/graphics/wgl/glcontext.cpp b/source/graphics/wgl/glcontext.cpp index ebca3f1..6808897 100644 --- a/source/graphics/wgl/glcontext.cpp +++ b/source/graphics/wgl/glcontext.cpp @@ -7,6 +7,16 @@ using namespace std; +namespace { + +template +T get_proc(const char *name) +{ + return reinterpret_cast(reinterpret_cast(wglGetProcAddress(name))); +} + +} + namespace Msp { namespace Graphics { @@ -48,7 +58,7 @@ void GLContext::platform_init(const GLOptions &opts) ContextHandle fake_context = wglCreateContext(dc); wglMakeCurrent(dc, fake_context); - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = reinterpret_cast(wglGetProcAddress("wglCreateContextAttribsARB")); + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = get_proc("wglCreateContextAttribsARB"); if(!wglCreateContextAttribs) throw unsupported_gl_mode(opts); @@ -100,7 +110,7 @@ GLContext::~GLContext() void GLContext::set_swap_interval(unsigned i) { - PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = reinterpret_cast(wglGetProcAddress("wglSwapIntervalEXT")); + PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = get_proc("wglSwapIntervalEXT"); if(!wglSwapInterval) throw runtime_error("wglSwapIntervalEXT not found"); wglSwapInterval(i); -- 2.45.2