diff --git a/CMakeLists.txt b/CMakeLists.txt index ce5298b43..991605382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,8 @@ cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" OFF "NOT WITH_ cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) cmake_dependent_option(WITH_SHADERS "Build Shaders library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) +cmake_dependent_option(WITH_MAGNUMINFO "Build magnum-info utility" OFF "NOT WITH_EVERYTHING" ON) + option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF) cmake_dependent_option(WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT WITH_MAGNUMINFO" ON) cmake_dependent_option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF "TARGET_GLES" OFF) @@ -56,6 +58,7 @@ if(TARGET_GLES2) endif() # Installation paths +set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(MAGNUM_CMAKE_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules) set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) diff --git a/src/Platform/CMakeLists.txt b/src/Platform/CMakeLists.txt index d3a6c2e7a..0e67226fa 100644 --- a/src/Platform/CMakeLists.txt +++ b/src/Platform/CMakeLists.txt @@ -116,3 +116,14 @@ if(NEED_EGLCONTEXT) set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") install(FILES EglContextHandler.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) endif() + +# Magnum Info +if(WITH_MAGNUMINFO) + if(UNIX) + add_executable(magnum-info magnum-info.cpp) + target_link_libraries(magnum-info Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES}) + install(TARGETS magnum-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) + else() + message(WARNING "magnum-info is currently available only on Unix. Set WITH_MAGNUMINFO to OFF to suppress this warning.") + endif() +endif() diff --git a/src/Platform/magnum-info.cpp b/src/Platform/magnum-info.cpp new file mode 100644 index 000000000..edd30f322 --- /dev/null +++ b/src/Platform/magnum-info.cpp @@ -0,0 +1,109 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + 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. +*/ + +#include + +#include "Context.h" +#include "Platform/WindowlessGlxApplication.h" + +namespace Magnum { + +class MagnumInfo: public Platform::WindowlessGlxApplication { + public: + MagnumInfo(int& argc, char** argv); + + inline int exec() override { return 0; } +}; + +MagnumInfo::MagnumInfo(int& argc, char** argv): WindowlessGlxApplication(argc, argv) { + Context* c = Context::current(); + + Debug() << ""; + Debug() << " +---------------------------------------------------------+"; + Debug() << " | Information about Magnum engine and OpenGL capabilities |"; + Debug() << " +---------------------------------------------------------+"; + Debug() << ""; + + Debug() << "Used application: Platform::WindowlessGlxApplication"; + { + Debug d; + d << "Compilation flags:"; + #ifdef MAGNUM_TARGET_GLES + d << "MAGNUM_TARGET_GLES"; + #endif + #ifdef MAGNUM_TARGET_GLES2 + d << "MAGNUM_TARGET_GLES2"; + #endif + #ifdef MAGNUM_TARGET_NACL + d << "MAGNUM_TARGET_NACL"; + #endif + #ifdef CORRADE_GCC46_COMPATIBILITY + d << "CORRADE_GCC46_COMPATIBILITY"; + #endif + } + Debug() << ""; + + Debug() << "Vendor:" << c->vendorString(); + Debug() << "Renderer:" << c->rendererString(); + Debug() << "OpenGL version:" << c->version() << '(' + c->versionString() + ')'; + Debug() << "GLSL version:" << c->version() << '(' + c->shadingLanguageVersionString() + ')'; + Debug() << ""; + + /* Get first future (not supported) version */ + std::vector versions{ + #ifndef MAGNUM_TARGET_GLES + Version::GL300, + Version::GL310, + Version::GL320, + Version::GL330, + Version::GL400, + Version::GL410, + Version::GL420, + Version::GL430, + #else + Version::GLES200, + Version::GLES300, + #endif + Version::None + }; + std::size_t future = 0; + while(versions[future] != Version::None && c->isVersionSupported(versions[future])) + ++future; + + /* Display supported OpenGL extensions from unsupported versions */ + for(std::size_t i = future; i != versions.size(); ++i) { + if(versions[i] != Version::None) + Debug() << versions[i] << "extension support:"; + else Debug() << "Vendor extension support:"; + + for(const auto& extension: Extension::extensions(versions[i])) { + std::string extensionName = extension.string(); + Debug d; + d << " " << extensionName << std::string(60-extensionName.size(), ' '); + if(c->isExtensionSupported(extension)) + d << "SUPPORTED"; + else if(c->isVersionSupported(extension.requiredVersion())) + d << " - "; + else + d << " --- "; + } + + Debug() << ""; + } +} + +} + +MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(Magnum::MagnumInfo)