Browse Source

Shaders: allow building this library with MAGNUM_TARGET_GL turned off.

So far it contains just the uniform definitions and utilities related
to line drawing, nothing else, but especially the line utilities were
needed to be able to build MeshTools tests on a GL-less build.
pull/674/head
Vladimír Vondruš 1 year ago
parent
commit
1709a4ad2b
  1. 2
      CMakeLists.txt
  2. 6
      doc/building.dox
  3. 3
      doc/changelog.dox
  4. 2
      doc/custom-buildsystems-order.dot
  5. 5
      modules/FindMagnum.cmake
  6. 73
      src/Magnum/Shaders/CMakeLists.txt
  7. 4
      src/Magnum/Shaders/DistanceFieldVector.h
  8. 20
      src/Magnum/Shaders/DistanceFieldVectorGL.h
  9. 4
      src/Magnum/Shaders/Flat.h
  10. 20
      src/Magnum/Shaders/FlatGL.h
  11. 2
      src/Magnum/Shaders/Generic.h
  12. 8
      src/Magnum/Shaders/GenericGL.h
  13. 22
      src/Magnum/Shaders/LineGL.h
  14. 4
      src/Magnum/Shaders/MeshVisualizer.h
  15. 16
      src/Magnum/Shaders/MeshVisualizerGL.h
  16. 4
      src/Magnum/Shaders/Phong.h
  17. 12
      src/Magnum/Shaders/PhongGL.h
  18. 12
      src/Magnum/Shaders/Shaders.h
  19. 19
      src/Magnum/Shaders/Test/CMakeLists.txt
  20. 4
      src/Magnum/Shaders/Vector.h
  21. 20
      src/Magnum/Shaders/VectorGL.h
  22. 8
      src/Magnum/Shaders/VertexColor.h
  23. 20
      src/Magnum/Shaders/VertexColorGL.h

2
CMakeLists.txt

@ -245,7 +245,7 @@ cmake_dependent_option(MAGNUM_WITH_SHADERTOOLS "Build ShaderTools library" ON "N
cmake_dependent_option(MAGNUM_WITH_TEXT "Build Text library" ON "NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_MAGNUMFONT;NOT MAGNUM_WITH_MAGNUMFONTCONVERTER" ON)
cmake_dependent_option(MAGNUM_WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT MAGNUM_WITH_TEXT;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(MAGNUM_WITH_TRADE "Build Trade library" ON "NOT MAGNUM_WITH_MATERIALTOOLS;NOT MAGNUM_WITH_MESHTOOLS;NOT MAGNUM_WITH_PRIMITIVES;NOT MAGNUM_WITH_SCENETOOLS;NOT MAGNUM_WITH_IMAGECONVERTER;NOT MAGNUM_WITH_ANYIMAGEIMPORTER;NOT MAGNUM_WITH_ANYIMAGECONVERTER;NOT MAGNUM_WITH_ANYSCENEIMPORTER;NOT MAGNUM_WITH_OBJIMPORTER;NOT MAGNUM_WITH_TGAIMAGECONVERTER;NOT MAGNUM_WITH_TGAIMPORTER" ON)
cmake_dependent_option(MAGNUM_WITH_GL "Build GL library" ON "NOT MAGNUM_WITH_SHADERS;NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_ANDROIDAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSIOSAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSCGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSGLXAPPLICATION;NOT MAGNUM_WITH_CGLCONTEXT;NOT MAGNUM_WITH_GLXAPPLICATION;NOT MAGNUM_WITH_GLXCONTEXT;NOT MAGNUM_WITH_XEGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSWGLAPPLICATION;NOT MAGNUM_WITH_WGLCONTEXT;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(MAGNUM_WITH_GL "Build GL library" ON "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_ANDROIDAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSIOSAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSCGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSGLXAPPLICATION;NOT MAGNUM_WITH_CGLCONTEXT;NOT MAGNUM_WITH_GLXAPPLICATION;NOT MAGNUM_WITH_GLXCONTEXT;NOT MAGNUM_WITH_XEGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSWGLAPPLICATION;NOT MAGNUM_WITH_WGLCONTEXT;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(MAGNUM_TARGET_GL "Build libraries with OpenGL interoperability" ON "MAGNUM_WITH_GL" OFF)

6
doc/building.dox

@ -563,8 +563,7 @@ can specify which parts will be built and which not:
- `MAGNUM_WITH_AUDIO` --- Build the @ref Audio library. Depends on
[OpenAL](https://www.openal.org/), not enabled by default.
- `MAGNUM_WITH_DEBUGTOOLS` --- Build the @ref DebugTools library.
- `MAGNUM_WITH_GL` --- Build the @ref GL library. Enabled automatically if
`MAGNUM_WITH_SHADERS` is enabled.
- `MAGNUM_WITH_GL` --- Build the @ref GL library
- `MAGNUM_WITH_MATERIALTOOLS` --- Build the @ref MaterialTools library.
Enables also building of the @ref Trade library.
- `MAGNUM_WITH_MESHTOOLS` --- Build the @ref MeshTools library. Enables also
@ -574,8 +573,7 @@ can specify which parts will be built and which not:
- `MAGNUM_WITH_SCENEGRAPH` --- Build the @ref SceneGraph library
- `MAGNUM_WITH_SCENETOOLS` --- Build the @ref SceneTools library. Enables
also building of the @ref Trade library.
- `MAGNUM_WITH_SHADERS` --- Build the @ref Shaders library. Enables also
building of the @ref GL library.
- `MAGNUM_WITH_SHADERS` --- Build the @ref Shaders library
- `MAGNUM_WITH_SHADERTOOLS` --- Build the @ref ShaderTools library
- `MAGNUM_WITH_TEXT` --- Build the @ref Text library. Enables also building
of the @ref TextureTools library.

3
doc/changelog.dox

@ -892,6 +892,9 @@ See also:
@subsubsection changelog-latest-changes-shaders Shaders library
- This library no longer has a hard dependency on OpenGL. If
@ref MAGNUM_TARGET_GL is not enabled, this library will contain just
uniform struct definitions and related utilities.
- In the original implementation of normal mapping in @ref Shaders::PhongGL,
there shader didn't provide a way to supply bitangent direction, forcing
users to patch normal maps. This is now possible using newly added

2
doc/custom-buildsystems-order.dot

@ -92,7 +92,7 @@ digraph "Magnum library dependency order" {
MagnumSceneGraph -> Magnum
MagnumShaders -> MagnumGL
MagnumShaders -> MagnumGL [style=dotted]
MagnumShaderTools -> Magnum
MagnumShaderTools -> CorradePluginManager

5
modules/FindMagnum.cmake

@ -491,7 +491,10 @@ endif()
set(_MAGNUM_SceneGraph_DEPENDENCIES )
set(_MAGNUM_SceneTools_DEPENDENCIES Trade)
set(_MAGNUM_Shaders_DEPENDENCIES GL)
set(_MAGNUM_Shaders_DEPENDENCIES )
if(MAGNUM_TARGET_GL)
list(APPEND _MAGNUM_Shaders_DEPENDENCIES GL)
endif()
set(_MAGNUM_Text_DEPENDENCIES TextureTools)
if(MAGNUM_TARGET_GL)

73
src/Magnum/Shaders/CMakeLists.txt

@ -28,23 +28,40 @@
# property that would have to be set on each target separately.
set(CMAKE_FOLDER "Magnum/Shaders")
if(NOT MAGNUM_WITH_GL)
message(SEND_ERROR "Shaders are available only if MAGNUM_WITH_GL is enabled")
endif()
set(MagnumShaders_SRCS )
set(MagnumShaders_GracefulAssert_SRCS
Line.cpp)
set(MagnumShaders_HEADERS
DistanceFieldVector.h
Flat.h
Generic.h
Line.h
MeshVisualizer.h
Phong.h
Shaders.h
Vector.h
visibility.h)
# Header files to display in project view of IDEs only
set(MagnumShaders_PRIVATE_HEADERS
Implementation/lineMiterLimit.h)
if(MAGNUM_TARGET_GL)
if(MAGNUM_TARGET_GLES2)
corrade_add_resource(MagnumShaders_RESOURCES_GL resources-gles2.conf)
else()
corrade_add_resource(MagnumShaders_RESOURCES_GL resources-gl.conf)
endif()
set(MagnumShaders_SRCS
list(APPEND MagnumShaders_SRCS
${MagnumShaders_RESOURCES_GL})
set(MagnumShaders_GracefulAssert_SRCS
list(APPEND MagnumShaders_GracefulAssert_SRCS
DistanceFieldVectorGL.cpp
FlatGL.cpp
Line.cpp
MeshVisualizerGL.cpp
PhongGL.cpp
VectorGL.cpp
@ -52,29 +69,16 @@ set(MagnumShaders_GracefulAssert_SRCS
glShaderWrapper.cpp)
set(MagnumShaders_HEADERS
DistanceFieldVector.h
list(APPEND MagnumShaders_HEADERS
DistanceFieldVectorGL.h
Flat.h
FlatGL.h
Generic.h
GenericGL.h
Line.h
MeshVisualizer.h
MeshVisualizerGL.h
Phong.h
PhongGL.h
Shaders.h
Vector.h
VectorGL.h
VertexColorGL.h
glShaderWrapper.h
visibility.h)
# Header files to display in project view of IDEs only
set(MagnumShaders_PRIVATE_HEADERS
Implementation/lineMiterLimit.h)
glShaderWrapper.h)
if(NOT MAGNUM_TARGET_GLES2)
list(APPEND MagnumShaders_GracefulAssert_SRCS
@ -88,8 +92,11 @@ if(MAGNUM_BUILD_DEPRECATED)
list(APPEND MagnumShaders_HEADERS
VertexColor.h)
endif()
endif()
# Objects shared between main and test library
# Objects shared between main and test library. On non-GL builds contains
# nothing so it's not even defined.
if(MAGNUM_TARGET_GL)
add_library(MagnumShadersObjects OBJECT
${MagnumShaders_SRCS}
${MagnumShaders_HEADERS}
@ -110,10 +117,14 @@ endif()
if(NOT MAGNUM_BUILD_STATIC OR MAGNUM_BUILD_STATIC_PIC)
set_target_properties(MagnumShadersObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set(MagnumShadersObjects_OBJECTS $<TARGET_OBJECTS:MagnumShadersObjects>)
else()
set(MagnumShadersObjects_OBJECTS )
endif()
# Main Shaders library
add_library(MagnumShaders ${SHARED_OR_STATIC}
$<TARGET_OBJECTS:MagnumShadersObjects>
${MagnumShadersObjects_OBJECTS}
${MagnumShaders_GracefulAssert_SRCS})
set_target_properties(MagnumShaders PROPERTIES DEBUG_POSTFIX "-d")
if(NOT MAGNUM_BUILD_STATIC)
@ -121,9 +132,10 @@ if(NOT MAGNUM_BUILD_STATIC)
elseif(MAGNUM_BUILD_STATIC_PIC)
set_target_properties(MagnumShaders PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_link_libraries(MagnumShaders PUBLIC
Magnum
MagnumGL)
target_link_libraries(MagnumShaders PUBLIC Magnum)
if(MAGNUM_TARGET_GL)
target_link_libraries(MagnumShaders PUBLIC MagnumGL)
endif()
install(TARGETS MagnumShaders
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
@ -134,7 +146,7 @@ install(FILES ${MagnumShaders_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}
if(MAGNUM_BUILD_TESTS)
# Library with graceful assert for testing
add_library(MagnumShadersTestLib ${SHARED_OR_STATIC} ${EXCLUDE_FROM_ALL_IF_TEST_TARGET}
$<TARGET_OBJECTS:MagnumShadersObjects>
${MagnumShadersObjects_OBJECTS}
${MagnumShaders_GracefulAssert_SRCS})
set_target_properties(MagnumShadersTestLib PROPERTIES DEBUG_POSTFIX "-d")
target_compile_definitions(MagnumShadersTestLib PRIVATE
@ -142,9 +154,10 @@ if(MAGNUM_BUILD_TESTS)
if(MAGNUM_BUILD_STATIC_PIC)
set_target_properties(MagnumShadersTestLib PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_link_libraries(MagnumShadersTestLib PUBLIC
Magnum
MagnumGL)
target_link_libraries(MagnumShadersTestLib PUBLIC Magnum)
if(MAGNUM_TARGET_GL)
target_link_libraries(MagnumShadersTestLib PUBLIC MagnumGL)
endif()
add_subdirectory(Test ${EXCLUDE_FROM_ALL_IF_TEST_TARGET})
endif()

4
src/Magnum/Shaders/DistanceFieldVector.h

@ -33,7 +33,7 @@
#include "Magnum/Magnum.h"
#include "Magnum/Math/Color.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/DistanceFieldVectorGL.h"
@ -247,7 +247,7 @@ struct DistanceFieldVectorMaterialUniform {
#endif
};
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
/** @brief @copybrief DistanceFieldVectorGL
* @m_deprecated_since_latest Use @ref DistanceFieldVectorGL instead.
*/

20
src/Magnum/Shaders/DistanceFieldVectorGL.h

@ -27,11 +27,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Class @ref Magnum::Shaders::DistanceFieldVectorGL, typedef @ref Magnum::Shaders::DistanceFieldVectorGL2D, @ref Magnum::Shaders::DistanceFieldVectorGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Utility/Move.h>
#include "Magnum/DimensionTraits.h"
@ -80,6 +85,10 @@ working on the framebuffer, you need to enable
@image html shaders-distancefieldvector.png width=256px
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-DistanceFieldVectorGL-usage Example usage
Common mesh setup:
@ -883,12 +892,20 @@ template<UnsignedInt dimensions> class DistanceFieldVectorGL<dimensions>::Compil
/**
@brief Two-dimensional distance field vector OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef DistanceFieldVectorGL<2> DistanceFieldVectorGL2D;
/**
@brief Three-dimensional distance field vector OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef DistanceFieldVectorGL<3> DistanceFieldVectorGL3D;
@ -906,5 +923,8 @@ namespace Implementation {
#endif
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

4
src/Magnum/Shaders/Flat.h

@ -33,7 +33,7 @@
#include "Magnum/Magnum.h"
#include "Magnum/Math/Color.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/FlatGL.h"
@ -274,7 +274,7 @@ struct FlatMaterialUniform {
#endif
};
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
/** @brief @copybrief FlatGL
* @m_deprecated_since_latest Use @ref FlatGL instead.
*/

20
src/Magnum/Shaders/FlatGL.h

@ -27,11 +27,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Class @ref Magnum::Shaders::FlatGL, typedef @ref Magnum::Shaders::FlatGL2D, @ref Magnum::Shaders::FlatGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Utility/Move.h>
#include "Magnum/DimensionTraits.h"
@ -85,6 +90,10 @@ configure the shader.
@image html shaders-flat.png width=256px
@note This function is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-FlatGL-colored Colored rendering
Common mesh setup:
@ -1590,12 +1599,20 @@ template<UnsignedInt dimensions> class FlatGL<dimensions>::CompileState: public
/**
@brief 2D flat OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef FlatGL<2> FlatGL2D;
/**
@brief 3D flat OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef FlatGL<3> FlatGL3D;
@ -1613,5 +1630,8 @@ namespace Implementation {
#endif
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

2
src/Magnum/Shaders/Generic.h

@ -34,7 +34,7 @@
#include "Magnum/Math/Matrix3.h"
#include "Magnum/Math/Matrix4.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/GenericGL.h"

8
src/Magnum/Shaders/GenericGL.h

@ -27,11 +27,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Struct @ref Magnum::Shaders::GenericGL, typedef @ref Magnum::Shaders::GenericGL2D, @ref Magnum::Shaders::GenericGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include "Magnum/GL/Attribute.h"
#include "Magnum/Shaders/Shaders.h"
@ -632,5 +637,8 @@ typedef CORRADE_DEPRECATED("use GenericGL3D instead") GenericGL3D Generic3D;
#endif
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

22
src/Magnum/Shaders/LineGL.h

@ -26,13 +26,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifndef MAGNUM_TARGET_GLES2
#if defined(MAGNUM_TARGET_GL) && !defined(MAGNUM_TARGET_GLES2)
/** @file
* @brief Class @ref Magnum::Shaders::LineGL, typedef @ref Magnum::Shaders::LineGL2D, @ref Magnum::Shaders::LineGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#if defined(MAGNUM_TARGET_GL) && !defined(MAGNUM_TARGET_GLES2)
#include <Corrade/Utility/Move.h>
#include "Magnum/DimensionTraits.h"
@ -41,7 +44,6 @@
#include "Magnum/Shaders/glShaderWrapper.h"
#include "Magnum/Shaders/visibility.h"
#ifndef MAGNUM_TARGET_GLES2
namespace Magnum { namespace Shaders {
namespace Implementation {
@ -72,6 +74,10 @@ styles, and antialiased independently of MSAA being used or not.
@experimental
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
@requires_gles30 Requires integer support in shaders which is not available in
OpenGL ES 2.0.
@ -1144,12 +1150,20 @@ template<UnsignedInt dimensions> class LineGL<dimensions>::CompileState: public
/**
@brief 2D line OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef LineGL<2> LineGL2D;
/**
@brief 3D LineGL OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef LineGL<3> LineGL3D;
@ -1173,8 +1187,10 @@ namespace Implementation {
#endif
}}
#else
#elif defined(MAGNUM_TARGET_GLES2)
#error this header is not available in the OpenGL ES 2.0 / WebGL 1.0 build
#else
#error this header is available only in the OpenGL build
#endif
#endif

4
src/Magnum/Shaders/MeshVisualizer.h

@ -34,7 +34,7 @@
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Matrix.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/MeshVisualizerGL.h"
@ -598,7 +598,7 @@ struct MeshVisualizerMaterialUniform {
#endif
};
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
/** @brief @copybrief MeshVisualizerGL2D
* @m_deprecated_since_latest Use @ref MeshVisualizerGL2D instead.
*/

16
src/Magnum/Shaders/MeshVisualizerGL.h

@ -27,11 +27,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Class @ref Magnum::Shaders::MeshVisualizerGL2D, @ref Magnum::Shaders::MeshVisualizerGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Utility/Move.h>
#include <Corrade/Utility/Utility.h>
@ -180,6 +185,10 @@ behavior with nothing enabled. The shader is a 2D variant of
@ref MeshVisualizerGL3D with mostly identical workflow. See its documentation
for more information, workflows that differ are shown below.
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-MeshVisualizerGL2D-instancing Instanced rendering
Enabling @ref Flag::InstancedTransformation will turn the shader into an
@ -1421,6 +1430,10 @@ visualization or object/primitive ID visualization by passing an appropriate
@ref Flag to @ref Configuration::setFlags() --- there's no default behavior
with nothing enabled.
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-MeshVisualizerGL3D-wireframe Wireframe visualization
Wireframe visualization is done by enabling @ref Flag::Wireframe. It is done
@ -3420,5 +3433,8 @@ CORRADE_ENUMSET_OPERATORS(MeshVisualizerGL2D::Flags)
CORRADE_ENUMSET_OPERATORS(MeshVisualizerGL3D::Flags)
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

4
src/Magnum/Shaders/Phong.h

@ -35,7 +35,7 @@
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Matrix.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/PhongGL.h"
@ -549,7 +549,7 @@ struct PhongLightUniform {
#endif
};
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
/** @brief @copybrief PhongGL
* @m_deprecated_since_latest Use @ref PhongGL instead.
*/

12
src/Magnum/Shaders/PhongGL.h

@ -28,11 +28,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Class @ref Magnum::Shaders::PhongGL
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <initializer_list>
#include <Corrade/Utility/Move.h>
@ -56,6 +61,10 @@ shader.
@image html shaders-phong.png width=256px
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-PhongGL-colored Colored rendering
Common mesh setup:
@ -2434,5 +2443,8 @@ MAGNUM_SHADERS_EXPORT Debug& operator<<(Debug& debug, PhongGL::Flags value);
CORRADE_ENUMSET_OPERATORS(PhongGL::Flags)
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

12
src/Magnum/Shaders/Shaders.h

@ -32,13 +32,17 @@
#include "Magnum/Types.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT
namespace Magnum { namespace Shaders {
enum class LineCapStyle: UnsignedByte;
enum class LineJoinStyle: UnsignedByte;
#ifdef MAGNUM_TARGET_GL
template<UnsignedInt> class DistanceFieldVectorGL;
typedef DistanceFieldVectorGL<2> DistanceFieldVectorGL2D;
typedef DistanceFieldVectorGL<3> DistanceFieldVectorGL3D;
@ -57,12 +61,9 @@ typedef CORRADE_DEPRECATED("use FlatGL2D instead") FlatGL2D Flat2D;
typedef CORRADE_DEPRECATED("use FlatGL3D instead") FlatGL3D Flat3D;
#endif
/* Generic is used only statically */
/* GenericGL is used only statically */
#ifndef MAGNUM_TARGET_GLES2
enum class LineCapStyle: UnsignedByte;
enum class LineJoinStyle: UnsignedByte;
template<UnsignedInt> class LineGL;
typedef LineGL<2> LineGL2D;
typedef LineGL<3> LineGL3D;
@ -98,6 +99,7 @@ template<UnsignedInt dimensions> using VertexColor CORRADE_DEPRECATED_ALIAS("use
typedef CORRADE_DEPRECATED("use VertexColorGL2D instead") VertexColorGL2D VertexColor2D;
typedef CORRADE_DEPRECATED("use VertexColorGL3D instead") VertexColorGL3D VertexColor3D;
#endif
#endif
}}
#endif

19
src/Magnum/Shaders/Test/CMakeLists.txt

@ -31,13 +31,18 @@ set(CMAKE_FOLDER "Magnum/Shaders/Test")
corrade_add_test(ShadersDistanceFieldVectorTest DistanceFieldVectorTest.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersFlatTest FlatTest.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersGenericTest GenericTest.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersGLShaderWrapperTest GLShaderWrapperTest.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersMeshVisualizerTest MeshVisualizerTest.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersPhongTest PhongTest.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersLineTest LineTest.cpp LIBRARIES MagnumShadersTestLib)
target_compile_definitions(ShadersLineTest PRIVATE "CORRADE_GRACEFUL_ASSERT")
corrade_add_test(ShadersVectorTest VectorTest.cpp LIBRARIES MagnumShaders)
# There's an underscore between GL and Test to disambiguate from GLTest, which
# is a common suffix used to mark tests that need a GL context. Ugly, I know.
if(MAGNUM_TARGET_GL)
corrade_add_test(ShadersGLShaderWrapperTest GLShaderWrapperTest.cpp LIBRARIES MagnumShaders)
# There's an underscore between GL and Test to disambiguate from GLTest,
# which is a common suffix used to mark tests that need a GL context. Ugly,
# I know.
corrade_add_test(ShadersDistanceFieldVectorGL_Test DistanceFieldVectorGL_Test.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersFlatGL_Test FlatGL_Test.cpp LIBRARIES MagnumShadersTestLib)
corrade_add_test(ShadersGenericGL_Test GenericGL_Test.cpp LIBRARIES MagnumShaders)
@ -47,14 +52,12 @@ corrade_add_test(ShadersVectorGL_Test VectorGL_Test.cpp LIBRARIES MagnumShaders)
corrade_add_test(ShadersVertexColorGL_Test VertexColorGL_Test.cpp LIBRARIES MagnumShaders)
if(NOT MAGNUM_TARGET_GLES2)
corrade_add_test(ShadersLineTest LineTest.cpp LIBRARIES MagnumShadersTestLib)
target_compile_definitions(ShadersLineTest PRIVATE "CORRADE_GRACEFUL_ASSERT")
corrade_add_test(ShadersLineGL_Test LineGL_Test.cpp LIBRARIES MagnumShaders)
endif()
if(MAGNUM_BUILD_GL_TESTS)
# Otherwise CMake complains that Corrade::PluginManager is not found, wtf
# Otherwise CMake complains that Corrade::PluginManager is not found,
# wtf
find_package(Corrade REQUIRED PluginManager)
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
@ -522,4 +525,4 @@ if(MAGNUM_BUILD_GL_TESTS)
endif()
endif()
endif()
endif()

4
src/Magnum/Shaders/Vector.h

@ -33,7 +33,7 @@
#include "Magnum/Magnum.h"
#include "Magnum/Math/Color.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/VectorGL.h"
@ -189,7 +189,7 @@ struct VectorMaterialUniform {
#endif
};
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
/** @brief @copybrief Shaders::VectorGL
* @m_deprecated_since_latest Use @ref Shaders::VectorGL "VectorGL" instead.
*/

20
src/Magnum/Shaders/VectorGL.h

@ -27,11 +27,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Class @ref Magnum::Shaders::VectorGL, typedef @ref Magnum::Shaders::VectorGL2D, @ref Magnum::Shaders::VectorGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Utility/Move.h>
#include "Magnum/DimensionTraits.h"
@ -78,6 +83,10 @@ working on the framebuffer, you need to enable
@ref GL::Renderer::Feature::Blending and set up the blending function. See
@ref GL::Renderer::setBlendFunction() for details.
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-VectorGL-usage Example usage
Common mesh setup:
@ -837,12 +846,20 @@ template<UnsignedInt dimensions> class VectorGL<dimensions>::CompileState: publi
/**
@brief Two-dimensional vector OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef VectorGL<2> VectorGL2D;
/**
@brief Three-dimensional vector OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef VectorGL<3> VectorGL3D;
@ -860,5 +877,8 @@ namespace Implementation {
#endif
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

8
src/Magnum/Shaders/VertexColor.h

@ -26,7 +26,7 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
/** @file
* @brief Typedef @ref Magnum::Shaders::VertexColor, alias @ref Magnum::Shaders::VertexColor2D, @ref Magnum::Shaders::VertexColor3D
* @m_deprecated_since_latest Use @ref Magnum/Shaders/VertexColorGL.h, the
@ -37,7 +37,7 @@
#include "Magnum/configure.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#if defined(MAGNUM_TARGET_GL) && defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Macros.h>
#include "Magnum/Shaders/VertexColorGL.h"
@ -64,8 +64,10 @@ typedef CORRADE_DEPRECATED("use VertexColorGL2D instead") VertexColorGL2D Vertex
typedef CORRADE_DEPRECATED("use VertexColorGL3D instead") VertexColorGL3D VertexColor3D;
}}
#else
#elif defined(MAGNUM_TARGET_GL)
#error use Magnum/Shaders/VertexColorGL.h, the VertexColorGL class and related typedefs instead
#else
#error this header is available only in the OpenGL build
#endif
#endif

20
src/Magnum/Shaders/VertexColorGL.h

@ -27,11 +27,16 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_TARGET_GL
/** @file
* @brief Class @ref Magnum::Shaders::VertexColorGL, typedef @ref Magnum::Shaders::VertexColorGL2D, @ref Magnum::Shaders::VertexColorGL3D
* @m_since_latest
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <Corrade/Utility/Move.h>
#include "Magnum/DimensionTraits.h"
@ -77,6 +82,10 @@ working on the framebuffer, you need to enable
@ref GL::Renderer::Feature::Blending and set up the blending function. See
@ref GL::Renderer::setBlendFunction() for details.
@note This class is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
@section Shaders-VertexColorGL-example Example usage
Common mesh setup. The shader accepts either three- or four-component color
@ -558,12 +567,20 @@ template<UnsignedInt dimensions> class VertexColorGL<dimensions>::CompileState:
/**
@brief 2D vertex color OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef VertexColorGL<2> VertexColorGL2D;
/**
@brief 3D vertex color OpenGL shader
@m_since_latest
@note This typedef is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features
for more information.
*/
typedef VertexColorGL<3> VertexColorGL3D;
@ -581,5 +598,8 @@ namespace Implementation {
#endif
}}
#else
#error this header is available only in the OpenGL build
#endif
#endif

Loading…
Cancel
Save