using namespace std;
+namespace {
+
+template<typename T>
+T get_proc(const char *name)
+{
+ return reinterpret_cast<T>(reinterpret_cast<void *>(wglGetProcAddress(name)));
+}
+
+}
+
namespace Msp {
namespace Graphics {
ContextHandle fake_context = wglCreateContext(dc);
wglMakeCurrent(dc, fake_context);
- PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
+ PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = get_proc<PFNWGLCREATECONTEXTATTRIBSARBPROC>("wglCreateContextAttribsARB");
if(!wglCreateContextAttribs)
throw unsupported_gl_mode(opts);
void GLContext::set_swap_interval(unsigned i)
{
- PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = reinterpret_cast<PFNWGLSWAPINTERVALEXTPROC>(wglGetProcAddress("wglSwapIntervalEXT"));
+ PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = get_proc<PFNWGLSWAPINTERVALEXTPROC>("wglSwapIntervalEXT");
if(!wglSwapInterval)
throw runtime_error("wglSwapIntervalEXT not found");
wglSwapInterval(i);