Browse Source

Creating Context instance in all *Context classes.

The naming is now kinda schizofrenic, hope I come up with something
better.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
13bb600c3e
  1. 6
      src/Contexts/EglContext.cpp
  2. 8
      src/Contexts/EglContext.h
  3. 7
      src/Contexts/GlutWindowContext.cpp
  4. 10
      src/Contexts/GlutWindowContext.h
  5. 6
      src/Contexts/GlxContext.cpp
  6. 8
      src/Contexts/GlxContext.h
  7. 6
      src/Contexts/Sdl2WindowContext.cpp
  8. 8
      src/Contexts/Sdl2WindowContext.h

6
src/Contexts/EglContext.cpp

@ -15,9 +15,13 @@
#include "EglContext.h"
#include "Context.h"
namespace Magnum { namespace Contexts {
EglContext::~EglContext() {
delete c;
eglDestroyContext(display, context);
eglDestroySurface(display, surface);
eglTerminate(display);
@ -81,6 +85,8 @@ void EglContext::createContext(EGLNativeWindowType window) {
}
/** @bug Fixme: On desktop OpenGL and Mesa EGL implementation OpenGL version is 1.0, which is wrong */
context = new Context;
}
}}

8
src/Contexts/EglContext.h

@ -28,7 +28,11 @@
#include "AbstractContext.h"
namespace Magnum { namespace Contexts {
namespace Magnum {
class Context;
namespace Contexts {
#ifndef DOXYGEN_GENERATING_OUTPUT
/* EGL returns visual ID as int, but Xorg expects long unsigned int */
@ -64,6 +68,8 @@ class EglContext: public AbstractContext<EGLNativeDisplayType, VisualId, EGLNati
EGLConfig config;
EGLSurface surface;
EGLContext context;
Context* c;
};
}}

7
src/Contexts/GlutWindowContext.cpp

@ -15,6 +15,7 @@
#include "GlutWindowContext.h"
#include "Context.h"
#include "ExtensionWrangler.h"
namespace Magnum { namespace Contexts {
@ -38,6 +39,12 @@ GlutWindowContext::GlutWindowContext(int& argc, char** argv, const std::string&
glutDisplayFunc(staticDrawEvent);
ExtensionWrangler::initialize();
c = new Context;
}
GlutWindowContext::~GlutWindowContext() {
delete c;
}
}}

10
src/Contexts/GlutWindowContext.h

@ -28,7 +28,11 @@
#include "AbstractWindowContext.h"
namespace Magnum { namespace Contexts {
namespace Magnum {
class Context;
namespace Contexts {
/** @nosubgrouping
@brief GLUT context
@ -52,6 +56,8 @@ class GlutWindowContext: public AbstractWindowContext {
*/
GlutWindowContext(int& argc, char** argv, const std::string& title = "Magnum GLUT context", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600));
~GlutWindowContext();
inline int exec() {
glutMainLoop();
return 0;
@ -246,6 +252,8 @@ class GlutWindowContext: public AbstractWindowContext {
int& argc;
char** argv;
Context* c;
};
/* Implementations for inline functions with unused parameters */

6
src/Contexts/GlxContext.cpp

@ -18,6 +18,8 @@
#include <GL/glxext.h>
#include <Utility/Debug.h>
#include "Context.h"
#define None 0L // redef Xlib nonsense
namespace Magnum { namespace Contexts {
@ -83,9 +85,13 @@ void GlxContext::createContext(Window nativeWindow) {
Error() << "GlxContext: cannot create context.";
exit(1);
}
c = new Context;
}
GlxContext::~GlxContext() {
delete c;
glXMakeCurrent(display, None, nullptr);
glXDestroyContext(display, context);
}

8
src/Contexts/GlxContext.h

@ -27,7 +27,11 @@
#include "AbstractContext.h"
namespace Magnum { namespace Contexts {
namespace Magnum {
class Context;
namespace Contexts {
/**
@brief GLX interface
@ -62,6 +66,8 @@ class GlxContext: public AbstractContext<Display*, VisualID, Window> {
Window window;
GLXFBConfig* configs;
GLXContext context;
Context* c;
};
}}

6
src/Contexts/Sdl2WindowContext.cpp

@ -14,6 +14,8 @@
*/
#include "Sdl2WindowContext.h"
#include "Context.h"
#include "ExtensionWrangler.h"
namespace Magnum { namespace Contexts {
@ -52,9 +54,13 @@ Sdl2WindowContext::Sdl2WindowContext(int, char**, const std::string& name, const
sizeEvent->window.data1 = size.x();
sizeEvent->window.data2 = size.y();
SDL_PushEvent(sizeEvent);
c = new Context;
}
Sdl2WindowContext::~Sdl2WindowContext() {
delete c;
SDL_GL_DeleteContext(context);
SDL_DestroyWindow(window);
SDL_Quit();

8
src/Contexts/Sdl2WindowContext.h

@ -27,7 +27,11 @@
#include "AbstractWindowContext.h"
namespace Magnum { namespace Contexts {
namespace Magnum {
class Context;
namespace Contexts {
/** @nosubgrouping
@brief SDL2 context
@ -179,6 +183,8 @@ class Sdl2WindowContext: public AbstractWindowContext {
SDL_Window* window;
SDL_GLContext context;
Context* c;
bool _redraw;
};

Loading…
Cancel
Save