mirror of https://github.com/mosra/magnum.git
Browse Source
Contexts attached to window are now *WindowContext, pure contexts are just *Context.vectorfields
18 changed files with 290 additions and 290 deletions
@ -1,64 +0,0 @@
|
||||
#ifndef Magnum_Contexts_AbstractGlInterface_h |
||||
#define Magnum_Contexts_AbstractGlInterface_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class Magnum::Contexts::AbstractGlInterface |
||||
*/ |
||||
|
||||
#include "ExtensionWrangler.h" |
||||
|
||||
namespace Magnum { namespace Contexts { |
||||
|
||||
/** @brief Base for OpenGL interfaces */ |
||||
template<class Display, class VisualId, class Window> class AbstractGlInterface { |
||||
public: |
||||
/**
|
||||
* @brief Get visual ID |
||||
* |
||||
* Initializes the interface on given display and returns visual ID. |
||||
*/ |
||||
virtual VisualId getVisualId(Display nativeDisplay) = 0; |
||||
|
||||
/**
|
||||
* @brief Destructor |
||||
* |
||||
* Finalizes and closes the interface. |
||||
*/ |
||||
virtual ~AbstractGlInterface() {} |
||||
|
||||
/** @brief Create context */ |
||||
virtual void createContext(Window nativeWindow) = 0; |
||||
|
||||
/**
|
||||
* @brief Whether to enable experimental extension wrangler features |
||||
* |
||||
* Default is to disable. |
||||
*/ |
||||
virtual inline ExtensionWrangler::ExperimentalFeatures experimentalExtensionWranglerFeatures() const { |
||||
return ExtensionWrangler::ExperimentalFeatures::Disable; |
||||
} |
||||
|
||||
/** @brief Make the context current */ |
||||
virtual void makeCurrent() = 0; |
||||
|
||||
/** @brief Swap buffers */ |
||||
virtual void swapBuffers() = 0; |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,52 @@
|
||||
#ifndef Magnum_Contexts_AbstractWindowContext_h |
||||
#define Magnum_Contexts_AbstractWindowContext_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class Magnum::Contexts::AbstractWindowContext |
||||
*/ |
||||
|
||||
namespace Magnum { namespace Contexts { |
||||
|
||||
/**
|
||||
@brief Base class for context creation |
||||
|
||||
See subclasses documentation for more information. Context classes subclasses |
||||
are meant to be used directly in `main()`, for example: |
||||
@code |
||||
class MyContext: public Magnum::Contexts::GlutWindowContext { |
||||
// implement required methods...
|
||||
}; |
||||
int main(int argc, char** argv) { |
||||
MyContext c(argc, argv); |
||||
return c.exec(); |
||||
} |
||||
@endcode |
||||
*/ |
||||
class AbstractWindowContext { |
||||
public: |
||||
virtual inline ~AbstractWindowContext() {} |
||||
|
||||
/**
|
||||
* @brief Execute main loop |
||||
* @return Value for returning from `main()`. |
||||
*/ |
||||
virtual int exec() = 0; |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -1,66 +0,0 @@
|
||||
#ifndef Magnum_Contexts_EglInterface_h |
||||
#define Magnum_Contexts_EglInterface_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class Magnum::Contexts::GlxInterface |
||||
*/ |
||||
|
||||
#include "Magnum.h" |
||||
#include <GL/glx.h> |
||||
|
||||
#include "AbstractGlInterface.h" |
||||
|
||||
namespace Magnum { namespace Contexts { |
||||
|
||||
/**
|
||||
@brief GLX interface |
||||
|
||||
Creates OpenGL 3.3 core context or OpenGL ES 2.0 context, if targetting |
||||
OpenGL ES. |
||||
|
||||
Used in GlxContext. |
||||
*/ |
||||
class GlxInterface: public AbstractGlInterface<Display*, VisualID, Window> { |
||||
public: |
||||
~GlxInterface(); |
||||
|
||||
VisualID getVisualId(Display* nativeDisplay); |
||||
void createContext(Window nativeWindow); |
||||
|
||||
/* This must be enabled, otherwise (on my NVidia) it crashes when creating VAO. WTF. */ |
||||
inline ExtensionWrangler::ExperimentalFeatures experimentalExtensionWranglerFeatures() const { |
||||
return ExtensionWrangler::ExperimentalFeatures::Enable; |
||||
} |
||||
|
||||
inline void makeCurrent() { |
||||
glXMakeCurrent(display, window, context); |
||||
} |
||||
|
||||
inline void swapBuffers() { |
||||
glXSwapBuffers(display, window); |
||||
} |
||||
|
||||
private: |
||||
Display* display; |
||||
Window window; |
||||
GLXFBConfig* configs; |
||||
GLXContext context; |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,49 @@
|
||||
#ifndef Magnum_Contexts_GlxWindowContext_h |
||||
#define Magnum_Contexts_GlxWindowContext_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class Magnum::Contexts::GlxWindowContext |
||||
*/ |
||||
|
||||
#include "AbstractXWindowContext.h" |
||||
#include "GlxContext.h" |
||||
|
||||
namespace Magnum { namespace Contexts { |
||||
|
||||
/**
|
||||
@brief GLX context |
||||
|
||||
Uses GlxContext. |
||||
*/ |
||||
class GlxWindowContext: public AbstractXWindowContext { |
||||
public: |
||||
/**
|
||||
* @brief Constructor |
||||
* @param argc Count of arguments of `main()` function |
||||
* @param argv Arguments of `main()` function |
||||
* @param title Window title |
||||
* @param size Window size |
||||
* |
||||
* 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<GLsizei>& size = Math::Vector2<GLsizei>(800, 600)): AbstractXWindowContext(new GlxContext, argc, argv, title, size) {} |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue