X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fwgl%2Fglcontext.cpp;h=68088970ac13cab32cd856a2a23980d838ad3bf7;hb=0d205a19dc087768da1e803d8dfde27f12cb9d99;hp=35ec8e9b1983471f5dd12e476f4a662d2deaa7c4;hpb=c703f5b01bf5d7eeb13091e64109b58f5d12f53c;p=libs%2Fgui.git diff --git a/source/graphics/wgl/glcontext.cpp b/source/graphics/wgl/glcontext.cpp index 35ec8e9..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); @@ -60,6 +70,12 @@ void GLContext::platform_init(const GLOptions &opts) ctx_attribs.push_back(WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB); } + if(opts.core_profile) + { + ctx_attribs.push_back(WGL_CONTEXT_PROFILE_MASK_ARB); + ctx_attribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB); + } + if(opts.gl_version_major) { ctx_attribs.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB); @@ -94,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);