Browse Source

Platform: added magnum-info utility.

Similar to `glxinfo`, displays information about Magnum engine and
OpenGL capabilities. Currently for Unix/X11 only, as I don't have
windowless application implementation for other platforms.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
14a5f1a864
  1. 3
      CMakeLists.txt
  2. 11
      src/Platform/CMakeLists.txt
  3. 109
      src/Platform/magnum-info.cpp

3
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)

11
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()

109
src/Platform/magnum-info.cpp

@ -0,0 +1,109 @@
/*
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.
*/
#include <Utility/Debug.h>
#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<Version> 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)
Loading…
Cancel
Save