Browse Source

Renamed EglContext to XEglContext.

X11 window and event handling will be used also elsewhere for desktop
OpenGL, reflect its presence in the class name.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
61cac0f1b3
  1. 2
      CMakeLists.txt
  2. 4
      modules/FindMagnum.cmake
  3. 12
      src/Contexts/CMakeLists.txt
  4. 10
      src/Contexts/XEglContext.cpp
  5. 20
      src/Contexts/XEglContext.h

2
CMakeLists.txt

@ -14,7 +14,7 @@ option(WITH_PRIMITIVES "Builf Primitives library" OFF)
option(WITH_SCENEGRAPH "Build SceneGraph library" OFF)
option(WITH_SHADERS "Build Shaders library" OFF)
cmake_dependent_option(WITH_EGLCONTEXT "Build EglContext library" OFF "TARGET_GLES" OFF)
cmake_dependent_option(WITH_XEGLCONTEXT "Build XEglContext library" OFF "TARGET_GLES" OFF)
cmake_dependent_option(WITH_GLUTCONTEXT "Build GlutContext library" OFF "NOT TARGET_GLES" OFF)
option(WITH_SDL2CONTEXT "Build Sdl2Context library" OFF)

4
modules/FindMagnum.cmake

@ -20,7 +20,7 @@
# Primitives - Library with stock geometric primitives (static)
# SceneGraph - Scene graph library
# Shaders - Library with stock shaders
# EglContext - EGL context (depends on EGL and X11 libraries)
# XEglContext - X/EGL context (depends on EGL and X11 libraries)
# GlutContext - GLUT context (depends on GLUT library)
# Sdl2Context - SDL2 context (depends on SDL2 library)
# Example usage with specifying additional components is:
@ -112,7 +112,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif()
# X/EGL context dependencies
if(${component} STREQUAL EglContext)
if(${component} STREQUAL XEglContext)
find_package(EGL)
find_package(X11)
if(EGL_FOUND AND X11_FOUND)

12
src/Contexts/CMakeLists.txt

@ -26,16 +26,16 @@ if(WITH_SDL2CONTEXT)
endif()
# X/EGL context
if(WITH_EGLCONTEXT)
if(WITH_XEGLCONTEXT)
find_package(EGL)
find_package(X11)
if(EGL_FOUND AND X11_FOUND)
add_library(MagnumEglContext STATIC EglContext.cpp)
add_library(MagnumXEglContext STATIC XEglContext.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)
install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
set_target_properties(MagnumXEglContext PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast")
install(FILES XEglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumXEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
message(FATAL_ERROR "EGL or X11 libraries, required by EglContext, were not found. Set WITH_EGLCONTEXT to OFF to skip building it.")
message(FATAL_ERROR "EGL or X11 libraries, required by XEglContext, were not found. Set WITH_XEGLCONTEXT to OFF to skip building it.")
endif()
endif()

10
src/Contexts/EglContext.cpp → src/Contexts/XEglContext.cpp

@ -13,7 +13,7 @@
GNU Lesser General Public License version 3 for more details.
*/
#include "EglContext.h"
#include "XEglContext.h"
#define None 0L // redef Xlib nonsense
@ -24,7 +24,7 @@ using namespace std;
namespace Magnum { namespace Contexts {
EglContext::EglContext(int&, char**, const string& title, const Math::Vector2<GLsizei>& size): viewportSize(size) {
XEglContext::XEglContext(int&, char**, const string& title, const Math::Vector2<GLsizei>& size): viewportSize(size) {
/* Get default X display and root window, init EGL */
xDisplay = XOpenDisplay(0);
display = eglGetDisplay(xDisplay);
@ -116,13 +116,13 @@ EglContext::EglContext(int&, char**, const string& title, const Math::Vector2<GL
/* Init GLEW */
GLenum err = glewInit();
if(err != GLEW_OK) {
Error() << "EglContext: cannot initialize GLEW:" << glewGetErrorString(err);
Error() << "XEglContext: cannot initialize GLEW:" << glewGetErrorString(err);
exit(1);
}
#endif
}
EglContext::~EglContext() {
XEglContext::~XEglContext() {
/* Shut down EGL */
eglDestroyContext(display, context);
eglDestroySurface(display, surface);
@ -133,7 +133,7 @@ EglContext::~EglContext() {
XCloseDisplay(xDisplay);
}
int EglContext::exec() {
int XEglContext::exec() {
/* Show window */
XMapWindow(xDisplay, xWindow);

20
src/Contexts/EglContext.h → src/Contexts/XEglContext.h

@ -1,5 +1,5 @@
#ifndef Magnum_Contexts_EglContext_h
#define Magnum_Contexts_EglContext_h
#ifndef Magnum_Contexts_XEglContext_h
#define Magnum_Contexts_XEglContext_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
@ -16,7 +16,7 @@
*/
/** @file
* @brief Class Magnum::Contexts::EglContext
* @brief Class Magnum::Contexts::XEglContext
*/
#include "Magnum.h"
@ -40,7 +40,7 @@ namespace Magnum { namespace Contexts {
Supports keyboard and mouse handling.
*/
class EglContext: public AbstractContext {
class XEglContext: public AbstractContext {
public:
/**
* @brief Constructor
@ -51,14 +51,14 @@ class EglContext: public AbstractContext {
*
* Creates window with double-buffered OpenGL ES 2 context.
*/
EglContext(int& argc, char** argv, const std::string& title = "Magnum X/EGL context", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600));
XEglContext(int& argc, char** argv, const std::string& title = "Magnum X/EGL context", const Math::Vector2<GLsizei>& size = Math::Vector2<GLsizei>(800, 600));
/**
* @brief Destructor
*
* Deletes context and destroys the window.
*/
~EglContext();
~XEglContext();
int exec();
@ -218,10 +218,10 @@ class EglContext: public AbstractContext {
Math::Vector2<GLsizei> viewportSize;
};
inline void EglContext::keyPressEvent(EglContext::Key, const Math::Vector2<int>&) {}
inline void EglContext::keyReleaseEvent(EglContext::Key, const Math::Vector2<int>&) {}
inline void EglContext::mousePressEvent(EglContext::MouseButton, const Math::Vector2<int>&) {}
inline void EglContext::mouseReleaseEvent(EglContext::MouseButton, const Math::Vector2<int>&) {}
inline void XEglContext::keyPressEvent(XEglContext::Key, const Math::Vector2<int>&) {}
inline void XEglContext::keyReleaseEvent(XEglContext::Key, const Math::Vector2<int>&) {}
inline void XEglContext::mousePressEvent(XEglContext::MouseButton, const Math::Vector2<int>&) {}
inline void XEglContext::mouseReleaseEvent(XEglContext::MouseButton, const Math::Vector2<int>&) {}
}}
Loading…
Cancel
Save