Browse Source

Merge branch 'master' into compatibility

Conflicts:
	src/Magnum/Context.h
	src/Magnum/DebugTools/ForceRenderer.cpp
	src/Magnum/DebugTools/ObjectRenderer.cpp
Vladimír Vondruš 12 years ago
parent
commit
d4fe9f60c8
  1. 7
      doc/cmake.dox
  2. 4
      doc/getting-started.dox
  3. 22
      doc/platform.dox
  4. 5
      modules/FindMagnum.cmake
  5. 16
      src/Magnum/Context.h
  6. 3
      src/Magnum/DebugTools/ForceRenderer.cpp
  7. 2
      src/Magnum/DebugTools/ForceRenderer.h
  8. 3
      src/Magnum/DebugTools/ObjectRenderer.cpp
  9. 2
      src/Magnum/DebugTools/ObjectRenderer.h
  10. 17
      src/Magnum/Magnum.h

7
doc/cmake.dox

@ -156,17 +156,18 @@ variable along with `MAGNUM_PLUGINS_*_DEBUG_DIR` / `MAGNUM_PLUGINS_*_RELEASE_DIR
variables to decide in preprocessing step. variables to decide in preprocessing step.
Features of found %Magnum library are exposed in these CMake variables, they Features of found %Magnum library are exposed in these CMake variables, they
are also available as preprocessor variables if including Magnum.h: are also available as preprocessor variables if including @ref Magnum/Magnum.h:
- `MAGNUM_BUILD_DEPRECATED` -- Defined if compiled with deprecated APIs - `MAGNUM_BUILD_DEPRECATED` -- Defined if compiled with deprecated APIs
included included
- `MAGNUM_BUILD_STATIC` -- Defined if built as static libraries. Default are - `MAGNUM_BUILD_STATIC` -- Defined if compiled as static libraries. Default
shared libraries. are shared libraries.
- `MAGNUM_TARGET_GLES` -- Defined if compiled for OpenGL ES - `MAGNUM_TARGET_GLES` -- Defined if compiled for OpenGL ES
- `MAGNUM_TARGET_GLES2` -- Defined if compiled for OpenGL ES 2.0 - `MAGNUM_TARGET_GLES2` -- Defined if compiled for OpenGL ES 2.0
- `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0 - `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0
- `MAGNUM_TARGET_DESKTOP_GLES` -- Defined if compiled with OpenGL ES - `MAGNUM_TARGET_DESKTOP_GLES` -- Defined if compiled with OpenGL ES
emulation on desktop OpenGL emulation on desktop OpenGL
- `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL
If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable also If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable also
contains path directly to Magnum directory (i.e. for includes without `Magnum/` contains path directly to Magnum directory (i.e. for includes without `Magnum/`

4
doc/getting-started.dox

@ -61,6 +61,10 @@ The code will be slightly different from what is presented below, but the
changes are only minor (two modified lines and one additional file) and the changes are only minor (two modified lines and one additional file) and the
main principles are the same. main principles are the same.
If you are using `compatibility` branch of Magnum and Corrade, replace
`modules/FindCorrade.cmake` with [the one from `compatibility` branch](https://github.com/mosra/corrade/blob/compatibility/modules/FindCorrade.cmake)
so the compatibility mode gets properly detected and used.
@section getting-started-review Review project structure @section getting-started-review Review project structure
The base project consists of just six files in two subfolders. %Magnum uses The base project consists of just six files in two subfolders. %Magnum uses

22
doc/platform.dox

@ -125,15 +125,19 @@ void MyApplication::viewportEvent(const Vector2i& size) {
Windowless applications provide just a context for ofscreen rendering or Windowless applications provide just a context for ofscreen rendering or
performing tasks on GPU. There is not yet any platform-independent toolkit performing tasks on GPU. There is not yet any platform-independent toolkit
which could handle this in portable way, thus you have to use platform-specific which could handle this in portable way, thus you have to use platform-specific
ones. As example we use @ref Platform::WindowlessGlxApplication, you need to ones. %Magnum provides windowless applications for X11-based Unix, OS X and
implement just @ref WindowlessGlxApplication::exec() "exec()" function. The Windows. To make things simple, as an example we will use only
class can be then used directly in `main()`, but again, for convenience and @ref Platform::WindowlessGlxApplication, see link for bootstrap application
portability it's better to use @ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN() below for fully portable example.
macro.
You need to implement just @ref WindowlessGlxApplication::exec() "exec()"
function. The class can be then used directly in `main()`, but again, for
convenience and portability it's better to use
@ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN() macro.
Similarly as with windowed applications, to simplify the porting, the library Similarly as with windowed applications, to simplify the porting, the library
provides `Platform::WindowlessApplication` typedef and `MAGNUM_WINDOWLESSAPPLICATION_MAIN()` provides `Platform::WindowlessApplication` typedef and `MAGNUM_WINDOWLESSAPPLICATION_MAIN()`
macro, but only if only one windowless application header is included. Changing macro, but only if just one windowless application header is included. Changing
the code to use different toolkit is then matter of replacing only the the code to use different toolkit is then matter of replacing only the
<tt>#</tt>`include` statement. Aliases for windowless applications are <tt>#</tt>`include` statement. Aliases for windowless applications are
separated from aliases for windowed applications, because projects commonly separated from aliases for windowed applications, because projects commonly
@ -143,8 +147,10 @@ etc.).
Barebone application which will just print out current OpenGL version and Barebone application which will just print out current OpenGL version and
renderer string and exits is in the following code listing. renderer string and exits is in the following code listing.
@note Fully contained windowless application along with CMake setup is @note Fully contained windowless application using @ref Platform::WindowlessCglApplication
available in `windowless` branch of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) on OS X, @ref Platform::WindowlessGlxApplication on Unix and
@ref Platform::WindowlessWglApplication on Windows along with CMake setup
is available in `windowless` branch of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap)
repository. repository.
@code @code

5
modules/FindMagnum.cmake

@ -92,6 +92,7 @@
# MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0 # MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0
# MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES # MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES
# emulation on desktop OpenGL # emulation on desktop OpenGL
# MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL
# #
# If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable # If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable
# also contains path directly to Magnum directory (i.e. for includes without # also contains path directly to Magnum directory (i.e. for includes without
@ -207,6 +208,10 @@ string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_DESKTOP_GLES" _TARGET_D
if(NOT _TARGET_DESKTOP_GLES EQUAL -1) if(NOT _TARGET_DESKTOP_GLES EQUAL -1)
set(MAGNUM_TARGET_DESKTOP_GLES 1) set(MAGNUM_TARGET_DESKTOP_GLES 1)
endif() endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_WEBGL" _TARGET_WEBGL)
if(NOT _TARGET_WEBGL EQUAL -1)
set(MAGNUM_TARGET_WEBGL 1)
endif()
# Dependent libraries and includes # Dependent libraries and includes
set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR} set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR}

16
src/Magnum/Context.h

@ -134,6 +134,13 @@ class MAGNUM_EXPORT Context {
#endif #endif
}; };
/**
* @brief %Context flags
*
* @see @ref flags()
*/
typedef Containers::EnumSet<Flag, GLint> Flags;
/** /**
* @brief State to reset * @brief State to reset
* *
@ -166,13 +173,6 @@ class MAGNUM_EXPORT Context {
*/ */
typedef Containers::EnumSet<State, UnsignedInt> States; typedef Containers::EnumSet<State, UnsignedInt> States;
/**
* @brief %Context flags
*
* @see @ref flags()
*/
typedef Containers::EnumSet<Flag, GLint> Flags;
/** /**
* @brief Constructor * @brief Constructor
* *
@ -385,6 +385,7 @@ class MAGNUM_EXPORT Context {
* as it does most operations in compile time. * as it does most operations in compile time.
* @see @ref supportedExtensions(), @ref Extension::extensions(), * @see @ref supportedExtensions(), @ref Extension::extensions(),
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() * @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED()
* @todoc Explicit reference when Doxygen can handle const
*/ */
bool isExtensionSupported(const Extension& extension) const { bool isExtensionSupported(const Extension& extension) const {
return isVersionSupported(_extensionRequiredVersion[extension._index]) && extensionStatus[extension._index]; return isVersionSupported(_extensionRequiredVersion[extension._index]) && extensionStatus[extension._index];
@ -418,6 +419,7 @@ class MAGNUM_EXPORT Context {
* Can be used e.g. for listing extensions available on current * Can be used e.g. for listing extensions available on current
* hardware, but for general usage prefer isExtensionDisabled() const, * hardware, but for general usage prefer isExtensionDisabled() const,
* as it does most operations in compile time. * as it does most operations in compile time.
* @todoc Explicit reference when Doxygen can handle const
*/ */
bool isExtensionDisabled(const Extension& extension) const { bool isExtensionDisabled(const Extension& extension) const {
return isVersionSupported(extension._requiredVersion) && extensionStatus[extension._index] && !isVersionSupported(_extensionRequiredVersion[extension._index]); return isVersionSupported(extension._requiredVersion) && extensionStatus[extension._index] && !isVersionSupported(_extensionRequiredVersion[extension._index]);

3
src/Magnum/DebugTools/ForceRenderer.cpp

@ -95,6 +95,9 @@ template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneG
ResourceManager::instance().set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); ResourceManager::instance().set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual);
} }
/* To avoid deleting pointers to incomplete type on destruction of Resource members */
template<UnsignedInt dimensions> ForceRenderer<dimensions>::~ForceRenderer() = default;
template<UnsignedInt dimensions> void ForceRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) { template<UnsignedInt dimensions> void ForceRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) {
shader->setTransformationProjectionMatrix(camera.projectionMatrix()*Implementation::forceRendererTransformation<dimensions>(transformationMatrix.transformPoint(forcePosition), force)*DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->scale()))) shader->setTransformationProjectionMatrix(camera.projectionMatrix()*Implementation::forceRendererTransformation<dimensions>(transformationMatrix.transformPoint(forcePosition), force)*DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->scale())))
.setColor(options->color()); .setColor(options->color());

2
src/Magnum/DebugTools/ForceRenderer.h

@ -125,6 +125,8 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p
*/ */
ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>&, const typename DimensionTraits<dimensions, Float>::VectorType&, typename DimensionTraits<dimensions, Float>::VectorType&&, ResourceKey = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* = nullptr) = delete; ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>&, const typename DimensionTraits<dimensions, Float>::VectorType&, typename DimensionTraits<dimensions, Float>::VectorType&&, ResourceKey = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* = nullptr) = delete;
~ForceRenderer();
private: private:
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) override; void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) override;

3
src/Magnum/DebugTools/ObjectRenderer.cpp

@ -175,6 +175,9 @@ template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(Scen
ResourceManager::instance().set<Mesh>(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); ResourceManager::instance().set<Mesh>(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual);
} }
/* To avoid deleting pointers to incomplete type on destruction of Resource members */
template<UnsignedInt dimensions> ObjectRenderer<dimensions>::~ObjectRenderer() = default;
template<UnsignedInt dimensions> void ObjectRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) { template<UnsignedInt dimensions> void ObjectRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) {
shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix*DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->size()))); shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix*DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->size())));
mesh->draw(*shader); mesh->draw(*shader);

2
src/Magnum/DebugTools/ObjectRenderer.h

@ -97,6 +97,8 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer:
*/ */
explicit ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>& object, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* drawables = nullptr); explicit ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>& object, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* drawables = nullptr);
~ObjectRenderer();
private: private:
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) override; void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>& camera) override;

17
src/Magnum/Magnum.h

@ -75,7 +75,7 @@ using Corrade::Utility::Error;
Defined if the library contains deprecated API (which will be removed in the Defined if the library contains deprecated API (which will be removed in the
future). To preserve backward compatibility, %Magnum is by default built with future). To preserve backward compatibility, %Magnum is by default built with
deprecated API included. deprecated API included.
@see @ref building @see @ref building, @ref cmake
*/ */
#define MAGNUM_BUILD_DEPRECATED #define MAGNUM_BUILD_DEPRECATED
/* (enabled by default) */ /* (enabled by default) */
@ -84,7 +84,7 @@ deprecated API included.
@brief Static library build @brief Static library build
Defined if built as static libraries. Default are shared libraries. Defined if built as static libraries. Default are shared libraries.
@see @ref building @see @ref building, @ref cmake
*/ */
#define MAGNUM_BUILD_STATIC #define MAGNUM_BUILD_STATIC
#undef MAGNUM_BUILD_STATIC #undef MAGNUM_BUILD_STATIC
@ -94,7 +94,7 @@ Defined if built as static libraries. Default are shared libraries.
Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0. Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0.
@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, @see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3,
@ref MAGNUM_TARGET_DESKTOP_GLES, @ref building @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, @ref cmake
*/ */
#define MAGNUM_TARGET_GLES #define MAGNUM_TARGET_GLES
#undef MAGNUM_TARGET_GLES #undef MAGNUM_TARGET_GLES
@ -104,7 +104,8 @@ Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0.
Defined if the engine is built for OpenGL ES 2.0. Implies also Defined if the engine is built for OpenGL ES 2.0. Implies also
@ref MAGNUM_TARGET_GLES. @ref MAGNUM_TARGET_GLES.
@see @ref MAGNUM_TARGET_GLES3, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building @see @ref MAGNUM_TARGET_GLES3, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building,
@ref cmake
*/ */
#define MAGNUM_TARGET_GLES2 #define MAGNUM_TARGET_GLES2
#undef MAGNUM_TARGET_GLES2 #undef MAGNUM_TARGET_GLES2
@ -114,7 +115,8 @@ Defined if the engine is built for OpenGL ES 2.0. Implies also
Defined if the engine is built for OpenGL ES 3.0. Implies also Defined if the engine is built for OpenGL ES 3.0. Implies also
@ref MAGNUM_TARGET_GLES. @ref MAGNUM_TARGET_GLES.
@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building @see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building,
@ref cmake
*/ */
#define MAGNUM_TARGET_GLES3 #define MAGNUM_TARGET_GLES3
#undef MAGNUM_TARGET_GLES3 #undef MAGNUM_TARGET_GLES3
@ -124,7 +126,8 @@ Defined if the engine is built for OpenGL ES 3.0. Implies also
Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0 emulated Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0 emulated
within standard desktop OpenGL. Implies also @ref MAGNUM_TARGET_GLES. within standard desktop OpenGL. Implies also @ref MAGNUM_TARGET_GLES.
@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, @ref building @see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, @ref building,
@ref cmake
*/ */
#define MAGNUM_TARGET_DESKTOP_GLES #define MAGNUM_TARGET_DESKTOP_GLES
#undef MAGNUM_TARGET_DESKTOP_GLES #undef MAGNUM_TARGET_DESKTOP_GLES
@ -138,7 +141,7 @@ differently, but there are some
[specific restrictions and features](http://www.khronos.org/registry/webgl/specs/latest/1.0/#6) [specific restrictions and features](http://www.khronos.org/registry/webgl/specs/latest/1.0/#6)
which you might want to be aware of. Implies also @ref MAGNUM_TARGET_GLES and which you might want to be aware of. Implies also @ref MAGNUM_TARGET_GLES and
@ref MAGNUM_TARGET_GLES2. @ref MAGNUM_TARGET_GLES2.
@see @ref CORRADE_TARGET_EMSCRIPTEN, @ref building @see @ref CORRADE_TARGET_EMSCRIPTEN, @ref building, @ref cmake
*/ */
#define MAGNUM_TARGET_WEBGL #define MAGNUM_TARGET_WEBGL
#undef MAGNUM_TARGET_WEBGL #undef MAGNUM_TARGET_WEBGL

Loading…
Cancel
Save