Browse Source

Platform: actually properly implement WindowlessWglApplication.

That was unprofessional from me, sorry, because it didn't even compile.
When I got it to compile, it crashed right away, because I was querying
GLX function instead of WGL function. But even after that it was still
crashing BECAUSE APPARENTLY YOU HAVE TO CREATE CONTEXT TO BE ABLE TO
CREATE CONTEXT, YO DAWG.

Fuck all this GL shit. Gimme something sane already. Ugh.
pull/132/head
Vladimír Vondruš 11 years ago
parent
commit
39149998d1
  1. 21
      src/Magnum/Platform/WindowlessWglApplication.cpp
  2. 6
      src/Magnum/Platform/WindowlessWglApplication.h

21
src/Magnum/Platform/WindowlessWglApplication.cpp

@ -104,14 +104,29 @@ bool WindowlessWglApplication::tryCreateContext(const Configuration& configurati
const int pixelFormat = ChoosePixelFormat(_deviceContext, &pfd);
SetPixelFormat(_deviceContext, pixelFormat, &pfd);
const int attributes = {
const int attributes[] = {
WGL_CONTEXT_FLAGS_ARB, int(configuration.flags()),
0
};
/* Create context and make it current */
const PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>( wglGetProcAddress(reinterpret_cast<LPCSTR>("glXCreateContextAttribsARB")));
/* Create temporary context so we are able to get the pointer to
wglCreateContextAttribsARB() */
HGLRC temporaryContext = wglCreateContext(_deviceContext);
if(!wglMakeCurrent(_deviceContext, temporaryContext)) {
Error() << "Platform::WindowlessWglApplication::tryCreateContext(): cannot make temporary context current:" << GetLastError();
return false;
}
/* Get pointer to proper context creation function and create real context
with it */
typedef HGLRC(WINAPI*PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int*);
const PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>( wglGetProcAddress(reinterpret_cast<LPCSTR>("wglCreateContextAttribsARB")));
_renderingContext = wglCreateContextAttribsARB(_deviceContext, 0, attributes);
/* Delete the temporary context */
wglMakeCurrent(_deviceContext, nullptr);
wglDeleteContext(temporaryContext);
if(!_renderingContext) {
Error() << "Platform::WindowlessWglApplication::tryCreateContext(): cannot create context:" << GetLastError();
return false;

6
src/Magnum/Platform/WindowlessWglApplication.h

@ -41,6 +41,11 @@
#include "Magnum/OpenGL.h"
#include "Magnum/Platform/Platform.h"
/* Define stuff that we need because I can't be bothered with creating a new
header just for two defines */
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
namespace Magnum { namespace Platform {
/**
@ -199,7 +204,6 @@ class WindowlessWglApplication::Configuration {
#endif
constexpr /*implicit*/ Configuration() {}
~Configuration();
/** @brief Context flags */
Flags flags() const { return _flags; }

Loading…
Cancel
Save