Browse Source

GL: don't use member function pointers in ContextState.

Since I'm touching this anyway. Making the internals better, one step at
a time.
pull/525/head
Vladimír Vondruš 5 years ago
parent
commit
37e5d689f7
  1. 8
      src/Magnum/GL/Context.cpp
  2. 4
      src/Magnum/GL/Context.h
  3. 9
      src/Magnum/GL/Implementation/ContextState.h

8
src/Magnum/GL/Context.cpp

@ -1129,7 +1129,7 @@ bool Context::isCoreProfileInternal(Implementation::ContextState& state) {
that */
if(_version < Version::GL320)
value = Implementation::ContextState::CoreProfile::Compatibility;
else value = (this->*state.isCoreProfileImplementation)() ?
else value = state.isCoreProfileImplementation(*this) ?
Implementation::ContextState::CoreProfile::Core :
Implementation::ContextState::CoreProfile::Compatibility;
}
@ -1137,14 +1137,14 @@ bool Context::isCoreProfileInternal(Implementation::ContextState& state) {
return value == Implementation::ContextState::CoreProfile::Core;
}
bool Context::isCoreProfileImplementationDefault() {
bool Context::isCoreProfileImplementationDefault(Context&) {
GLint value = 0;
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &value);
return value & GL_CONTEXT_CORE_PROFILE_BIT;
}
bool Context::isCoreProfileImplementationNV() {
auto extensions = extensionStrings();
bool Context::isCoreProfileImplementationNV(Context& self) {
auto extensions = self.extensionStrings();
return std::find(extensions.begin(), extensions.end(), "GL_ARB_compatibility") == extensions.end();
}
#endif

4
src/Magnum/GL/Context.h

@ -881,8 +881,8 @@ class MAGNUM_GL_EXPORT Context {
MAGNUM_GL_LOCAL void setupDriverWorkarounds();
#ifndef MAGNUM_TARGET_GLES
MAGNUM_GL_LOCAL bool isCoreProfileImplementationDefault();
MAGNUM_GL_LOCAL bool isCoreProfileImplementationNV();
MAGNUM_GL_LOCAL static bool isCoreProfileImplementationDefault(Context& self);
MAGNUM_GL_LOCAL static bool isCoreProfileImplementationNV(Context& self);
#endif
void(*_functionLoader)(Context&){};

9
src/Magnum/GL/Implementation/ContextState.h

@ -28,13 +28,6 @@
#include "Magnum/Magnum.h"
#include "Magnum/GL/GL.h"
#ifdef _MSC_VER
/* Otherwise the member function pointers will have different size based on
whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND
IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */
#include "Magnum/GL/Context.h"
#endif
namespace Magnum { namespace GL { namespace Implementation {
struct ContextState {
@ -47,7 +40,7 @@ struct ContextState {
Compatibility
} coreProfile = CoreProfile::Initial;
bool (Context::*isCoreProfileImplementation)();
bool(*isCoreProfileImplementation)(Context&);
#endif
};

Loading…
Cancel
Save