From 141b20a612565bf83d8be65ea2c81fc458de60a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 15 Sep 2012 00:55:02 +0200 Subject: [PATCH] Renamed Contexts::*Context to *ContextHandler. Finally (and hopefully) consistent and non-confusing naming. --- ...tractContext.h => AbstractContextHandler.h} | 16 ++++++++-------- src/Contexts/AbstractXWindowContext.cpp | 14 +++++++------- src/Contexts/AbstractXWindowContext.h | 10 +++++----- src/Contexts/CMakeLists.txt | 18 +++++++++--------- .../{EglContext.cpp => EglContextHandler.cpp} | 8 ++++---- .../{EglContext.h => EglContextHandler.h} | 12 ++++++------ .../{GlxContext.cpp => GlxContextHandler.cpp} | 14 +++++++------- .../{GlxContext.h => GlxContextHandler.h} | 12 ++++++------ src/Contexts/GlxWindowContext.h | 6 +++--- src/Contexts/XEglWindowContext.h | 6 +++--- 10 files changed, 58 insertions(+), 58 deletions(-) rename src/Contexts/{AbstractContext.h => AbstractContextHandler.h} (79%) rename src/Contexts/{EglContext.cpp => EglContextHandler.cpp} (91%) rename src/Contexts/{EglContext.h => EglContextHandler.h} (82%) rename src/Contexts/{GlxContext.cpp => GlxContextHandler.cpp} (85%) rename src/Contexts/{GlxContext.h => GlxContextHandler.h} (84%) diff --git a/src/Contexts/AbstractContext.h b/src/Contexts/AbstractContextHandler.h similarity index 79% rename from src/Contexts/AbstractContext.h rename to src/Contexts/AbstractContextHandler.h index 93aeb121e..ba73aa940 100644 --- a/src/Contexts/AbstractContext.h +++ b/src/Contexts/AbstractContextHandler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_AbstractContext_h -#define Magnum_Contexts_AbstractContext_h +#ifndef Magnum_Contexts_AbstractContextHandler_h +#define Magnum_Contexts_AbstractContextHandler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,29 +16,29 @@ */ /** @file - * @brief Class Magnum::Contexts::AbstractContext + * @brief Class Magnum::Contexts::AbstractContextHandler */ #include "ExtensionWrangler.h" namespace Magnum { namespace Contexts { -/** @brief Base for OpenGL contexts */ -template class AbstractContext { +/** @brief Base for OpenGL context handlers */ +template class AbstractContextHandler { public: /** * @brief Get visual ID * - * Initializes the interface on given display and returns visual ID. + * Initializes the handler on given display and returns visual ID. */ virtual VisualId getVisualId(Display nativeDisplay) = 0; /** * @brief Destructor * - * Finalizes and closes the interface. + * Finalizes and closes the handler. */ - virtual ~AbstractContext() {} + virtual ~AbstractContextHandler() {} /** @brief Create context */ virtual void createContext(Window nativeWindow) = 0; diff --git a/src/Contexts/AbstractXWindowContext.cpp b/src/Contexts/AbstractXWindowContext.cpp index b0087b4ad..0fbb95a9e 100644 --- a/src/Contexts/AbstractXWindowContext.cpp +++ b/src/Contexts/AbstractXWindowContext.cpp @@ -27,12 +27,12 @@ using namespace std; namespace Magnum { namespace Contexts { -AbstractXWindowContext::AbstractXWindowContext(AbstractContext* glInterface, int&, char**, const string& title, const Math::Vector2& size): glInterface(glInterface), viewportSize(size), flags(Flag::Redraw) { +AbstractXWindowContext::AbstractXWindowContext(AbstractContextHandler* contextHandler, int&, char**, const string& title, const Math::Vector2& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) { /* Get default X display */ display = XOpenDisplay(0); /* Get visual ID */ - VisualID visualId = glInterface->getVisualId(display); + VisualID visualId = contextHandler->getVisualId(display); /* Get visual info */ XVisualInfo *visInfo, visTemplate; @@ -61,16 +61,16 @@ AbstractXWindowContext::AbstractXWindowContext(AbstractContextcreateContext(window); + contextHandler->createContext(window); /* Capture exposure, keyboard and mouse button events */ XSelectInput(display, window, INPUT_MASK); /* Set OpenGL context as current */ - glInterface->makeCurrent(); + contextHandler->makeCurrent(); /* Initialize extension wrangler */ - ExtensionWrangler::initialize(glInterface->experimentalExtensionWranglerFeatures()); + ExtensionWrangler::initialize(contextHandler->experimentalExtensionWranglerFeatures()); c = new Context; } @@ -78,8 +78,8 @@ AbstractXWindowContext::AbstractXWindowContext(AbstractContext* glInterface, int& argc, char** argv, const std::string& title = "Magnum X/EGL context", const Math::Vector2& size = Math::Vector2(800, 600)); + AbstractXWindowContext(AbstractContextHandler* contextHandler, int& argc, char** argv, const std::string& title = "Magnum X/EGL context", const Math::Vector2& size = Math::Vector2(800, 600)); /** * @brief Destructor @@ -82,7 +82,7 @@ class AbstractXWindowContext: public AbstractWindowContext { virtual void drawEvent() = 0; /** @copydoc GlutWindowContext::swapBuffers() */ - inline void swapBuffers() { glInterface->swapBuffers(); } + inline void swapBuffers() { contextHandler->swapBuffers(); } /** @copydoc GlutWindowContext::redraw() */ inline void redraw() { flags |= Flag::Redraw; } @@ -281,7 +281,7 @@ class AbstractXWindowContext: public AbstractWindowContext { Window window; Atom deleteWindow; - AbstractContext* glInterface; + AbstractContextHandler* contextHandler; Context* c; diff --git a/src/Contexts/CMakeLists.txt b/src/Contexts/CMakeLists.txt index 85b27204c..7a3fd095f 100644 --- a/src/Contexts/CMakeLists.txt +++ b/src/Contexts/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(MagnumContextsExtensionWrangler OBJECT ExtensionWrangler.cpp) set(MagnumContexts_HEADERS - AbstractContext.h + AbstractContextHandler.h AbstractWindowContext.h ExtensionWrangler.h) install(FILES ${MagnumContexts_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) @@ -42,7 +42,7 @@ if(WITH_GLXWINDOWCONTEXT) set(NEED_GLXCONTEXT 1) add_library(MagnumGlxWindowContext STATIC $ - $ + $ $) install(FILES GlxWindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) install(TARGETS MagnumGlxWindowContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) @@ -54,7 +54,7 @@ if(WITH_XEGLWINDOWCONTEXT) set(NEED_EGLCONTEXT 1) add_library(MagnumXEglWindowContext STATIC $ - $ + $ $) install(FILES XEglWindowContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) install(TARGETS MagnumXEglWindowContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) @@ -74,10 +74,10 @@ endif() # GLX window context if(NEED_GLXCONTEXT) - add_library(MagnumGlxContext OBJECT GlxContext.cpp) + add_library(MagnumGlxContextHandler OBJECT GlxContextHandler.cpp) # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumGlxContext PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") - install(FILES GlxContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) + set_target_properties(MagnumGlxContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + install(FILES GlxContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) endif() # EGL context @@ -86,8 +86,8 @@ if(NEED_EGLCONTEXT) if(NOT EGL_FOUND) message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*EGL*WINDOWCONTEXT to OFF to skip building them.") endif() - add_library(MagnumEglContext OBJECT EglContext.cpp) + add_library(MagnumEglContextHandler OBJECT EglContextHandler.cpp) # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumEglContext PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") - install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) + set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + install(FILES EglContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) endif() diff --git a/src/Contexts/EglContext.cpp b/src/Contexts/EglContextHandler.cpp similarity index 91% rename from src/Contexts/EglContext.cpp rename to src/Contexts/EglContextHandler.cpp index fe9d7975d..c21b1ecf7 100644 --- a/src/Contexts/EglContext.cpp +++ b/src/Contexts/EglContextHandler.cpp @@ -13,19 +13,19 @@ GNU Lesser General Public License version 3 for more details. */ -#include "EglContext.h" +#include "EglContextHandler.h" #include "Context.h" namespace Magnum { namespace Contexts { -EglContext::~EglContext() { +EglContextHandler::~EglContextHandler() { eglDestroyContext(display, context); eglDestroySurface(display, surface); eglTerminate(display); } -VisualId EglContext::getVisualId(EGLNativeDisplayType nativeDisplay) { +VisualId EglContextHandler::getVisualId(EGLNativeDisplayType nativeDisplay) { /* Initialize */ display = eglGetDisplay(nativeDisplay); eglInitialize(display, 0, 0); @@ -64,7 +64,7 @@ VisualId EglContext::getVisualId(EGLNativeDisplayType nativeDisplay) { return visualId; } -void EglContext::createContext(EGLNativeWindowType window) { +void EglContextHandler::createContext(EGLNativeWindowType window) { static const EGLint contextAttributes[] = { #ifdef MAGNUM_TARGET_GLES EGL_CONTEXT_CLIENT_VERSION, 2, diff --git a/src/Contexts/EglContext.h b/src/Contexts/EglContextHandler.h similarity index 82% rename from src/Contexts/EglContext.h rename to src/Contexts/EglContextHandler.h index 0190fa299..824aa0177 100644 --- a/src/Contexts/EglContext.h +++ b/src/Contexts/EglContextHandler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_EglContext_h -#define Magnum_Contexts_EglContext_h +#ifndef Magnum_Contexts_EglContextHandler_h +#define Magnum_Contexts_EglContextHandler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::EglContext + * @brief Class Magnum::Contexts::EglContextHandler */ #include "Magnum.h" @@ -26,7 +26,7 @@ #endif #include -#include "AbstractContext.h" +#include "AbstractContextHandler.h" namespace Magnum { namespace Contexts { @@ -44,9 +44,9 @@ typedef EGLInt VisualId; Used in XEglWindowContext. */ -class EglContext: public AbstractContext { +class EglContextHandler: public AbstractContextHandler { public: - ~EglContext(); + ~EglContextHandler(); VisualId getVisualId(EGLNativeDisplayType nativeDisplay); void createContext(EGLNativeWindowType nativeWindow); diff --git a/src/Contexts/GlxContext.cpp b/src/Contexts/GlxContextHandler.cpp similarity index 85% rename from src/Contexts/GlxContext.cpp rename to src/Contexts/GlxContextHandler.cpp index 3f5ada4ac..81fc2ccdd 100644 --- a/src/Contexts/GlxContext.cpp +++ b/src/Contexts/GlxContextHandler.cpp @@ -13,7 +13,7 @@ GNU Lesser General Public License version 3 for more details. */ -#include "GlxContext.h" +#include "GlxContextHandler.h" #include #include @@ -24,14 +24,14 @@ namespace Magnum { namespace Contexts { -VisualID GlxContext::getVisualId(Display* nativeDisplay) { +VisualID GlxContextHandler::getVisualId(Display* nativeDisplay) { display = nativeDisplay; /* Check version */ int major, minor; glXQueryVersion(nativeDisplay, &major, &minor); if(major == 1 && minor < 4) { - Error() << "GlxContext: GLX version 1.4 or greater is required."; + Error() << "GlxContextHandler: GLX version 1.4 or greater is required."; exit(1); } @@ -49,7 +49,7 @@ VisualID GlxContext::getVisualId(Display* nativeDisplay) { }; configs = glXChooseFBConfig(nativeDisplay, DefaultScreen(nativeDisplay), attributes, &configCount); if(!configCount) { - Error() << "GlxContext: no supported framebuffer configuration found."; + Error() << "GlxContextHandler: no supported framebuffer configuration found."; exit(1); } @@ -61,7 +61,7 @@ VisualID GlxContext::getVisualId(Display* nativeDisplay) { return visualId; } -void GlxContext::createContext(Window nativeWindow) { +void GlxContextHandler::createContext(Window nativeWindow) { window = nativeWindow; GLint attributes[] = { @@ -82,12 +82,12 @@ void GlxContext::createContext(Window nativeWindow) { context = glXCreateContextAttribsARB(display, configs[0], 0, True, attributes); XFree(configs); if(!context) { - Error() << "GlxContext: cannot create context."; + Error() << "GlxContextHandler: cannot create context."; exit(1); } } -GlxContext::~GlxContext() { +GlxContextHandler::~GlxContextHandler() { glXMakeCurrent(display, None, nullptr); glXDestroyContext(display, context); } diff --git a/src/Contexts/GlxContext.h b/src/Contexts/GlxContextHandler.h similarity index 84% rename from src/Contexts/GlxContext.h rename to src/Contexts/GlxContextHandler.h index 5612b3831..52f4b8229 100644 --- a/src/Contexts/GlxContext.h +++ b/src/Contexts/GlxContextHandler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Contexts_GlxContext_h -#define Magnum_Contexts_GlxContext_h +#ifndef Magnum_Contexts_GlxContextHandler_h +#define Magnum_Contexts_GlxContextHandler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Contexts::GlxContext + * @brief Class Magnum::Contexts::GlxContextHandler */ #include "Magnum.h" @@ -25,7 +25,7 @@ #undef None #undef Always -#include "AbstractContext.h" +#include "AbstractContextHandler.h" namespace Magnum { namespace Contexts { @@ -37,9 +37,9 @@ OpenGL ES. Used in GlxWindowContext. */ -class GlxContext: public AbstractContext { +class GlxContextHandler: public AbstractContextHandler { public: - ~GlxContext(); + ~GlxContextHandler(); VisualID getVisualId(Display* nativeDisplay); void createContext(Window nativeWindow); diff --git a/src/Contexts/GlxWindowContext.h b/src/Contexts/GlxWindowContext.h index 65f68da50..4813b7d02 100644 --- a/src/Contexts/GlxWindowContext.h +++ b/src/Contexts/GlxWindowContext.h @@ -20,14 +20,14 @@ */ #include "AbstractXWindowContext.h" -#include "GlxContext.h" +#include "GlxContextHandler.h" namespace Magnum { namespace Contexts { /** @brief GLX context -Uses GlxContext. +Uses GlxContextHandler. */ class GlxWindowContext: public AbstractXWindowContext { public: @@ -41,7 +41,7 @@ class GlxWindowContext: public AbstractXWindowContext { * Creates window with double-buffered OpenGL 3.3 core context or * OpenGL ES 2.0 context, if targetting OpenGL ES. */ - inline GlxWindowContext(int& argc, char** argv, const std::string& title = "Magnum GLX context", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXWindowContext(new GlxContext, argc, argv, title, size) {} + inline GlxWindowContext(int& argc, char** argv, const std::string& title = "Magnum GLX context", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXWindowContext(new GlxContextHandler, argc, argv, title, size) {} }; }} diff --git a/src/Contexts/XEglWindowContext.h b/src/Contexts/XEglWindowContext.h index 131c5498c..1f5edcc41 100644 --- a/src/Contexts/XEglWindowContext.h +++ b/src/Contexts/XEglWindowContext.h @@ -20,14 +20,14 @@ */ #include "AbstractXWindowContext.h" -#include "EglContext.h" +#include "EglContextHandler.h" namespace Magnum { namespace Contexts { /** @brief X/EGL context -Uses EglContext. +Uses EglContextHandler. */ class XEglWindowContext: public AbstractXWindowContext { public: @@ -40,7 +40,7 @@ class XEglWindowContext: public AbstractXWindowContext { * * Creates window with double-buffered OpenGL ES 2 context. */ - inline XEglWindowContext(int& argc, char** argv, const std::string& title = "Magnum X/EGL context", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXWindowContext(new EglContext, argc, argv, title, size) {} + inline XEglWindowContext(int& argc, char** argv, const std::string& title = "Magnum X/EGL context", const Math::Vector2& size = Math::Vector2(800, 600)): AbstractXWindowContext(new EglContextHandler, argc, argv, title, size) {} }; }}