From 1693c772ada30e7d4cf63a05ec3ad9b32e0b7445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 28 Feb 2013 01:02:23 +0100 Subject: [PATCH] Moved OpenGL includes out from Magnum.h. OpenGL includes are ~35k lines together and it is a waste of compilation time to include them even if they are not needed at all (e.g. whole SceneGraph and Physics libraries). Saves ~10s of compilation time (6:46 before, now 6:35). --- src/AbstractImage.h | 2 +- src/AbstractShaderProgram.cpp | 14 ---------- src/AbstractShaderProgram.h | 2 +- src/Buffer.h | 2 +- src/CMakeLists.txt | 2 ++ src/Context.h | 2 +- src/Magnum.h | 15 +---------- src/OpenGL.cpp | 35 ++++++++++++++++++++++++ src/OpenGL.h | 36 +++++++++++++++++++++++++ src/Platform/ExtensionWrangler.cpp | 1 + src/Platform/GlutApplication.h | 1 + src/Platform/GlxContextHandler.h | 2 +- src/Platform/WindowlessGlxApplication.h | 5 ++-- src/Query.h | 2 +- src/Renderbuffer.h | 2 +- 15 files changed, 86 insertions(+), 37 deletions(-) create mode 100644 src/OpenGL.cpp create mode 100644 src/OpenGL.h diff --git a/src/AbstractImage.h b/src/AbstractImage.h index 2ba2279c7..35e427b56 100644 --- a/src/AbstractImage.h +++ b/src/AbstractImage.h @@ -22,7 +22,7 @@ #include #include "Magnum.h" - +#include "OpenGL.h" #include "magnumVisibility.h" namespace Magnum { diff --git a/src/AbstractShaderProgram.cpp b/src/AbstractShaderProgram.cpp index b5f09a957..88f30d040 100644 --- a/src/AbstractShaderProgram.cpp +++ b/src/AbstractShaderProgram.cpp @@ -28,20 +28,6 @@ namespace Magnum { -#ifndef DOXYGEN_GENERATING_OUTPUT -static_assert(std::is_same::value, "GLubyte is not the same as UnsignedByte"); -static_assert(std::is_same::value, "GLbyte is not the same as Byte"); -static_assert(std::is_same::value, "GLushort is not the same as UnsignedShort"); -static_assert(std::is_same::value, "GLshort is not the same as Short"); -static_assert(std::is_same::value, "GLuint is not the same as UnsignedInt"); -static_assert(std::is_same::value, "GLint is not the same as Int"); -static_assert(std::is_same::value, "GLsizei is not the same as Int"); -static_assert(std::is_same::value, "GLfloat is not the same as Float"); -#ifndef MAGNUM_TARGET_GLES -static_assert(std::is_same::value, "GLdouble is not the same as Double"); -#endif -#endif - AbstractShaderProgram::Uniform1fImplementation AbstractShaderProgram::uniform1fImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform2fvImplementation AbstractShaderProgram::uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform3fvImplementation AbstractShaderProgram::uniform3fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 658281fa6..3aa6a9108 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -23,7 +23,7 @@ #include #include "Magnum.h" - +#include "OpenGL.h" #include "magnumVisibility.h" /** @todo early asserts (no bool returns?) */ diff --git a/src/Buffer.h b/src/Buffer.h index 0f2b30b08..ef2447cb4 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -25,7 +25,7 @@ #include #include "Magnum.h" - +#include "OpenGL.h" #include "magnumVisibility.h" namespace Magnum { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 136a082dc..5565c3d16 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,7 @@ set(Magnum_SRCS Framebuffer.cpp Image.cpp Mesh.cpp + OpenGL.cpp Query.cpp Renderbuffer.cpp Resource.cpp @@ -69,6 +70,7 @@ set(Magnum_HEADERS ImageWrapper.h Magnum.h Mesh.h + OpenGL.h Query.h Renderbuffer.h Renderer.h diff --git a/src/Context.h b/src/Context.h index 86cc209b6..f9b8c18d4 100644 --- a/src/Context.h +++ b/src/Context.h @@ -23,7 +23,7 @@ #include #include "Magnum.h" - +#include "OpenGL.h" #include "magnumVisibility.h" namespace Magnum { diff --git a/src/Magnum.h b/src/Magnum.h index 782d97a0c..efd95f02a 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -16,28 +16,15 @@ */ /** @file - * @brief Basic definitions and forward declarations for Magnum namespace + * @brief Forward declarations for Magnum namespace */ #include #include "Math/Math.h" #include "Types.h" - #include "magnumConfigure.h" -#ifndef MAGNUM_TARGET_GLES -#include -#include -#else -#ifndef MAGNUM_TARGET_GLES2 -#include -#else -#include -#include -#endif -#endif - namespace Corrade { namespace Utility { class Debug; diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp new file mode 100644 index 000000000..ec410cee2 --- /dev/null +++ b/src/OpenGL.cpp @@ -0,0 +1,35 @@ +/* + 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 "OpenGL.h" +#include "Types.h" + +namespace Magnum { + +static_assert(std::is_same::value, "GLubyte is not the same as UnsignedByte"); +static_assert(std::is_same::value, "GLbyte is not the same as Byte"); +static_assert(std::is_same::value, "GLushort is not the same as UnsignedShort"); +static_assert(std::is_same::value, "GLshort is not the same as Short"); +static_assert(std::is_same::value, "GLuint is not the same as UnsignedInt"); +static_assert(std::is_same::value, "GLint is not the same as Int"); +static_assert(std::is_same::value, "GLsizei is not the same as Int"); +static_assert(std::is_same::value, "GLfloat is not the same as Float"); +#ifndef MAGNUM_TARGET_GLES +static_assert(std::is_same::value, "GLdouble is not the same as Double"); +#endif + +} diff --git a/src/OpenGL.h b/src/OpenGL.h new file mode 100644 index 000000000..100b85ca7 --- /dev/null +++ b/src/OpenGL.h @@ -0,0 +1,36 @@ +#ifndef Magnum_OpenGL_h +#define Magnum_OpenGL_h +/* + 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. +*/ + +/** @file + * @brief OpenGL headers + */ + +#include "magnumConfigure.h" + +#ifndef MAGNUM_TARGET_GLES +#include +#include +#else +#ifndef MAGNUM_TARGET_GLES2 +#include +#else +#include +#include +#endif +#endif + +#endif diff --git a/src/Platform/ExtensionWrangler.cpp b/src/Platform/ExtensionWrangler.cpp index 3c58b7da1..b5fdce9f0 100644 --- a/src/Platform/ExtensionWrangler.cpp +++ b/src/Platform/ExtensionWrangler.cpp @@ -19,6 +19,7 @@ #include #include "Magnum.h" +#include "OpenGL.h" namespace Magnum { namespace Platform { diff --git a/src/Platform/GlutApplication.h b/src/Platform/GlutApplication.h index 06c91984f..8d1030eec 100644 --- a/src/Platform/GlutApplication.h +++ b/src/Platform/GlutApplication.h @@ -23,6 +23,7 @@ #include "Math/Vector2.h" #include "Magnum.h" +#include "OpenGL.h" #include diff --git a/src/Platform/GlxContextHandler.h b/src/Platform/GlxContextHandler.h index e78df00ba..fd9e3adcf 100644 --- a/src/Platform/GlxContextHandler.h +++ b/src/Platform/GlxContextHandler.h @@ -19,7 +19,7 @@ * @brief Class Magnum::Platform::GlxContextHandler */ -#include "Magnum.h" +#include "OpenGL.h" #include /* undef Xlib nonsense to avoid conflicts */ #undef Complex diff --git a/src/Platform/WindowlessGlxApplication.h b/src/Platform/WindowlessGlxApplication.h index 541b0a9f4..8e35d4492 100644 --- a/src/Platform/WindowlessGlxApplication.h +++ b/src/Platform/WindowlessGlxApplication.h @@ -19,7 +19,7 @@ * @brief Class Magnum::Platform::WindowlessGlxApplication */ -#include "Magnum.h" +#include "OpenGL.h" #include #include #include @@ -28,7 +28,8 @@ #undef None #undef Always -#include "AbstractContextHandler.h" +#include "Magnum.h" +#include "Platform/AbstractContextHandler.h" namespace Magnum { namespace Platform { diff --git a/src/Query.h b/src/Query.h index 22aace60f..21063f516 100644 --- a/src/Query.h +++ b/src/Query.h @@ -20,7 +20,7 @@ */ #include "Magnum.h" - +#include "OpenGL.h" #include "magnumVisibility.h" namespace Magnum { diff --git a/src/Renderbuffer.h b/src/Renderbuffer.h index 35df11a25..20f53aa6a 100644 --- a/src/Renderbuffer.h +++ b/src/Renderbuffer.h @@ -20,7 +20,7 @@ */ #include "Magnum.h" - +#include "OpenGL.h" #include "magnumVisibility.h" namespace Magnum {