Browse Source

Merge branch 'master' into compatibility

Conflicts:
	src/DefaultFramebuffer.cpp
	src/Framebuffer.cpp
	src/MeshTools/Interleave.h
	src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp
	src/Primitives/Crosshair.cpp
	src/Primitives/Line.cpp
	src/Primitives/Plane.cpp
	src/Primitives/Square.cpp
	src/SceneGraph/AbstractTransformation.h
	src/SceneGraph/Object.hpp
	src/Shaders/DistanceFieldVector.cpp
	src/Shaders/Flat.cpp
	src/Shaders/Vector.cpp
	src/Text/GlyphCache.cpp
	src/TextureTools/Test/AtlasTest.cpp
Vladimír Vondruš 13 years ago
parent
commit
5d47fffc17
  1. 4
      doc/best-practices.dox
  2. 50
      doc/building.dox
  3. 29
      doc/platform.dox
  4. 2
      doc/transformations.dox
  5. 7
      doc/types.dox
  6. 5
      external/OpenGL/CMakeLists.txt
  7. 5
      external/OpenGL/GLES2/CMakeLists.txt
  8. 579
      external/OpenGL/GLES2/gl2.h
  9. 2528
      external/OpenGL/GLES2/gl2ext.h
  10. 2
      external/OpenGL/GLES2/gl2platform.h
  11. 1922
      external/OpenGL/GLES3/gl3.h
  12. 2
      external/OpenGL/GLES3/gl3platform.h
  13. 15
      external/OpenGL/KHR/khrplatform.h
  14. 5
      package/archlinux/PKGBUILD
  15. 54
      package/archlinux/PKGBUILD-clang
  16. 56
      package/archlinux/PKGBUILD-clang-libc++
  17. 0
      package/archlinux/PKGBUILD-emscripten
  18. 9
      package/archlinux/PKGBUILD-es2
  19. 11
      package/archlinux/PKGBUILD-es2desktop
  20. 9
      package/archlinux/PKGBUILD-es3
  21. 0
      package/archlinux/PKGBUILD-gcc46
  22. 0
      package/archlinux/PKGBUILD-gcc47
  23. 54
      package/archlinux/PKGBUILD-gcc49
  24. 0
      package/archlinux/PKGBUILD-mingw32
  25. 0
      package/archlinux/PKGBUILD-nacl-glibc
  26. 0
      package/archlinux/PKGBUILD-nacl-newlib
  27. 12
      package/archlinux/PKGBUILD-release
  28. 114
      package/ci/jenkins-emscripten.xml
  29. 113
      package/ci/jenkins-gltests.xml
  30. 128
      package/ci/jenkins-mingw32.xml
  31. 183
      package/ci/jenkins.xml
  32. 30
      src/AbstractFramebuffer.cpp
  33. 21
      src/AbstractFramebuffer.h
  34. 8
      src/AbstractImage.cpp
  35. 11
      src/AbstractShaderProgram.h
  36. 60
      src/AbstractTexture.cpp
  37. 43
      src/AbstractTexture.h
  38. 52
      src/Audio/Source.cpp
  39. 2
      src/Audio/Source.h
  40. 12
      src/Audio/magnumAudioVisibility.h
  41. 30
      src/Buffer.cpp
  42. 333
      src/Buffer.h
  43. 2
      src/BufferImage.cpp
  44. 2
      src/BufferImage.h
  45. 37
      src/BufferTexture.h
  46. 7
      src/CMakeLists.txt
  47. 171
      src/Color.h
  48. 8
      src/ColorFormat.cpp
  49. 8
      src/ColorFormat.h
  50. 84
      src/Context.h
  51. 40
      src/CubeMapTexture.h
  52. 61
      src/CubeMapTextureArray.h
  53. 4
      src/DebugTools/ForceRenderer.cpp
  54. 8
      src/DebugTools/Implementation/AbstractShapeRenderer.cpp
  55. 4
      src/DebugTools/ObjectRenderer.cpp
  56. 12
      src/DebugTools/magnumDebugToolsVisibility.h
  57. 24
      src/DefaultFramebuffer.cpp
  58. 8
      src/DefaultFramebuffer.h
  59. 19
      src/Extensions.h
  60. 21
      src/Framebuffer.cpp
  61. 6
      src/Framebuffer.h
  62. 4
      src/Implementation/FramebufferState.h
  63. 8
      src/Implementation/RendererState.h
  64. 59
      src/Magnum.h
  65. 1
      src/Math/CMakeLists.txt
  66. 26
      src/Math/Functions.h
  67. 9
      src/Math/Geometry/CMakeLists.txt
  68. 168
      src/Math/Geometry/Rectangle.h
  69. 1
      src/Math/Geometry/Test/CMakeLists.txt
  70. 176
      src/Math/Geometry/Test/RectangleTest.cpp
  71. 12
      src/Math/Math.h
  72. 512
      src/Math/Range.h
  73. 18
      src/Math/RectangularMatrix.h
  74. 1
      src/Math/Test/CMakeLists.txt
  75. 14
      src/Math/Test/FunctionsTest.cpp
  76. 5
      src/Math/Test/Matrix3Test.cpp
  77. 5
      src/Math/Test/Matrix4Test.cpp
  78. 397
      src/Math/Test/RangeTest.cpp
  79. 5
      src/Math/Test/RectangularMatrixTest.cpp
  80. 21
      src/Math/Test/Vector2Test.cpp
  81. 12
      src/Math/Test/Vector3Test.cpp
  82. 12
      src/Math/Test/Vector4Test.cpp
  83. 10
      src/Math/Test/VectorTest.cpp
  84. 22
      src/Math/Vector.h
  85. 17
      src/Math/Vector2.h
  86. 34
      src/Math/Vector3.h
  87. 20
      src/Math/instantiation.cpp
  88. 6
      src/Mesh.cpp
  89. 85
      src/Mesh.h
  90. 22
      src/MeshTools/CompressIndices.cpp
  91. 26
      src/MeshTools/CompressIndices.h
  92. 2
      src/MeshTools/FullScreenTriangle.cpp
  93. 53
      src/MeshTools/Interleave.h
  94. 23
      src/MeshTools/Test/CompressIndicesTest.cpp
  95. 2
      src/MeshTools/Test/GenerateFlatNormalsTest.cpp
  96. 21
      src/MeshTools/Test/InterleaveTest.cpp
  97. 12
      src/MeshTools/magnumMeshToolsVisibility.h
  98. 2
      src/OpenGL.h
  99. 1
      src/Platform/Implementation/GlxContextHandler.cpp
  100. 2
      src/Platform/magnum-info.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

4
doc/best-practices.dox

@ -77,11 +77,11 @@ vertex and index buffers in both Native Client and Emscripten.
@subsection best-practices-powervr PowerVR hardware
- [PowerVR Performance Recommendations](http://www.imgtec.com/powervr/insider/docs/PowerVR.Performance%20Recommendations.1.0.28.External.pdf) [PDF]
- [PowerVR Performance Recommendations](https://github.com/burningsun/pecker_framework/blob/master/参考资料/PowerVR.Performance%20Recommendations.pdf?raw=true) [PDF]
@subsection best-practices-tegra NVidia Tegra hardware
- [Optimize OpenGL ES 2.0 Performance for Tegra](http://docs.nvidia.com/tegra/data/Optimize_OpenGL_ES_2_0_Performance_for_Tegra.html)
- [Optimize OpenGL ES 2.0 Performance for Tegra](http://docs.nvidia.com/tegra/index.html#GLES2_Perf_Main.html)
*/
}

50
doc/building.dox

@ -250,20 +250,16 @@ Integration with various external math and physics libraries is provided by
@subsection building-packages-arch ArchLinux packages
In `package/archlinux` directory is currently one PKGBUILD for Git development
In `package/archlinux` directory is currently one package for Git development
build. The package is also in AUR under the same name.
There are also a few development PKGBUILDs in project root, which allow you to
build and install the package directly from source tree without downloading
anything. The native PKGBUILD also contains `check()` function which will run
all unit tests before packaging.
There are also a few development PKGBUILDs in `package/archlinux`, which allow
you to build and install the package directly from source tree without
downloading anything. The native PKGBUILDs also contain `check()` function
which will run all unit tests before packaging. You need to build them from
project root:
If you want to build with another compiler (e.g. Clang), run makepkg this way:
CXX=clang++ makepkg
Development PKGBUILDs can detect when Clang is used and remove unsupported CXX
flags.
makepkg -p package/archlinux/<file>
@section building-crosscompiling Crosscompiling
@ -385,6 +381,38 @@ depending projects.
If you have Node.js installed, you can also build and run unit tests using
`ctest`. See `BUILD_TESTS` above.
@section building-ci-jenkins Jenkins Continuous Integration
In `package/ci/` there are `jenkins.xml` and `jenkins-gltests.xml` files
containing job configuration, one for build and non-GL tests and the other for
GL tests only. Setup your Jenkins server, enable the **Git** and
**Text-finder** plugin and download the CLI application from here:
http://your-jenkins-server/cli
Then add new jobs or update existing ones (replace `<command>` with `create-job`
or `update-job`).
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum < jenkins.xml
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-GLTests < jenkins-gltests.xml
Build is done using **Ninja** build system and everything possible is enabled,
thus you need also **SDL2**, **GLUT** and **OpenAL** libraries. It expects that
**GCC** >=4.8.2, 4.7, 4.6 and **Clang** are installed and there are **OpenGL**,
**OpenGL ES 2.0** and **OpenGL ES 3.0** librares as it tries to compile the
library with every combination of them. You can add/remove the axes in
`axes/hudson.matrix.TextAxis` or via the web interface later.
Magnum-GLTests depend on active X11 session, thus they should be run from
Jenkins instance running on graphical user session.
There is also MinGW32 and Emscripten configuration, add or update them with the
commands below. See @ref building-crosscompiling for more information about
setting up the crosscompilers and `toolchains/` submodule. For Emscripten you
need also **Node.js** installed to run the tests.
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-MinGW32 < jenkins-mingw32.xml
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-Emscripten < jenkins-emscripten.xml
*/
}

29
doc/platform.dox

@ -190,7 +190,7 @@ constructor. Using method chaining it can be done conveniently like this:
MyApplication::MyApplication(int& argc, char** argv):
Platform::Application(argc, argv, Configuration()
.setTitle("My Application")
.setSize({800, 600})
.setSize({800, 600}))
{
// ...
}
@ -233,6 +233,33 @@ MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc
}
@endcode
@section platform-custom Using custom platform toolkits
In case you want to use some not-yet-supported toolkit or you don't want to use
the wrappers in @ref Platform namespace, you can initialize %Magnum manually.
All you need is to create OpenGL context and then create instance of
@ref Context class, which will take care of proper initialization and feature
detection. The instance must be alive for whole application lifetime. Example
`main()` function with manual initialization:
@code
int main(int argc, char** argv) {
// Create OpenGL context ...
{
// Initialize Magnum
Context context;
// open window, enter main loop...
// Magnum context gets destroyed
}
// delete OpenGL context ...
return 0;
}
@endcode
- Next page: @ref types
*/
}}

2
doc/transformations.dox

@ -154,7 +154,7 @@ auto b = Matrix4::reflection(axis.normalized());
Scaling and reflection is also done relative to origin, you can use method
mentioned above to scale or reflect around arbitrary point.
Sscaling and reflection can be (to some extent) also represented by complex
Scaling and reflection can be (to some extent) also represented by complex
numbers and quaternions, but it has some bad properties and would make some
operations more expensive, so it's not implemented.

7
doc/types.dox

@ -90,9 +90,10 @@ equivalently (e.g. @ref Math::Vector or @ref Color3 instead of @ref Vector3).
Other types, which don't have their GLSL equivalent, are:
- @ref Rectangle, @ref Rectanglei or @ref Rectangled
- @ref Complex or @ref Complexd, @ref DualComplex or @ref DualComplexd
- @ref Quaternion or @ref Quaterniond, @ref DualQuaternion or @ref DualQuaterniond
- @ref Complex or @ref Complexd, @ref DualComplex or @ref DualComplexd
- @ref Quaternion or @ref Quaterniond, @ref DualQuaternion or @ref DualQuaterniond
- @ref Range1D / @ref Range2D / @ref Range3D, @ref Range1Di / @ref Range2Di / @ref Range3Di or
@ref Range1Dd / @ref Range2Dd / @ref Range3Dd
These types can be used in GLSL either by extracting values from their
underlying structure or converting them to types supported by GLSL (e.g.

5
external/OpenGL/CMakeLists.txt vendored

@ -26,9 +26,8 @@ if(NOT TARGET_GLES)
add_subdirectory(GL)
else()
add_subdirectory(KHR)
if(TARGET_GLES2)
add_subdirectory(GLES2)
else()
add_subdirectory(GLES2)
if(NOT TARGET_GLES2)
add_subdirectory(GLES3)
endif()
endif()

5
external/OpenGL/GLES2/CMakeLists.txt vendored

@ -25,8 +25,9 @@
set(MagnumOpenGL_HEADERS
gl2ext.h)
# NaCl has its own gl2.h, this one causes linker issues
if(NOT CORRADE_TARGET_NACL)
# We need gl2ext.h also for ES3 (but not the others). NaCl has its own gl2.h,
# this one causes linker issues
if(TARGET_GLES2 AND NOT CORRADE_TARGET_NACL)
set(MagnumOpenGL_HEADERS ${MagnumOpenGL_HEADERS}
gl2platform.h
gl2.h)

579
external/OpenGL/GLES2/gl2.h vendored

@ -1,56 +1,81 @@
#ifndef __gl2_h_
#define __gl2_h_
/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */
#include <GLES2/gl2platform.h>
#define __gl2_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/*
** This header is generated from the Khronos OpenGL / OpenGL ES XML
** API Registry. The current version of the Registry, generator scripts
** used to make the header, and the header can be found at
** http://www.opengl.org/registry/
**
** Khronos $Revision$ on $Date$
*/
/*-------------------------------------------------------------------------
* Data type definitions
*-----------------------------------------------------------------------*/
#include <GLES2/gl2platform.h>
typedef void GLvoid;
typedef char GLchar;
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef khronos_int8_t GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
/* Generated C header for:
* API: gles2
* Profile: common
* Versions considered: 2\.[0-9]
* Versions emitted: .*
* Default extensions included: None
* Additional extensions included: _nomatch_^
* Extensions removed: _nomatch_^
*/
/* GL types for handling large vertex buffer objects */
#ifndef GL_ES_VERSION_2_0
#define GL_ES_VERSION_2_0 1
#include <KHR/khrplatform.h>
typedef khronos_int8_t GLbyte;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
typedef short GLshort;
typedef unsigned short GLushort;
typedef void GLvoid;
typedef struct __GLsync *GLsync;
typedef khronos_int64_t GLint64;
typedef khronos_uint64_t GLuint64;
typedef unsigned int GLenum;
typedef unsigned int GLuint;
typedef char GLchar;
typedef khronos_float_t GLfloat;
typedef khronos_ssize_t GLsizeiptr;
typedef khronos_intptr_t GLintptr;
typedef khronos_ssize_t GLsizeiptr;
/* OpenGL ES core versions */
#define GL_ES_VERSION_2_0 1
/* ClearBufferMask */
typedef unsigned int GLbitfield;
typedef int GLint;
typedef unsigned char GLboolean;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
@ -58,18 +83,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
/* AlphaFunction (not supported in ES20) */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
@ -78,29 +91,15 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
#define GL_BLEND_EQUATION_RGB 0x8009
#define GL_BLEND_EQUATION_ALPHA 0x883D
/* BlendSubtract */
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
/* Separate Blend Functions */
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
@ -110,38 +109,19 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* EnableCap */
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
@ -152,19 +132,13 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
@ -191,7 +165,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
/* GL_SCISSOR_TEST */
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
@ -206,32 +179,18 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
/* GL_POLYGON_OFFSET_FILL */
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* DataType */
#define GL_GENERATE_MIPMAP_HINT 0x8192
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
@ -240,44 +199,35 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* PixelFormat */
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
/* Shaders */
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
/* StencilFunction */
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
@ -286,9 +236,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
@ -296,35 +243,21 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
/* TextureTarget */
/* GL_TEXTURE_2D */
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
@ -334,8 +267,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
@ -369,13 +300,9 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
/* Uniform Types */
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
@ -391,48 +318,34 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
/* Vertex Arrays */
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
/* Read Format */
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
/* Shader Source */
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
/* Framebuffer Object. */
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX8 0x8D48
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
@ -442,179 +355,169 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_NONE 0
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
/*-------------------------------------------------------------------------
* GL core functions.
*-----------------------------------------------------------------------*/
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode );
GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth);
GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glFinish (void);
GL_APICALL void GL_APIENTRY glFlush (void);
GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL GLenum GL_APIENTRY glGetError (void);
GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode);
GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d);
GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f);
GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glFinish (void);
GL_APICALL void GL_APIENTRY glFlush (void);
GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_APICALL GLenum GL_APIENTRY glGetError (void);
GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name);
GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
#endif /* GL_ES_VERSION_2_0 */
#ifdef __cplusplus
}
#endif
#endif /* __gl2_h_ */
#endif

2528
external/OpenGL/GLES2/gl2ext.h vendored

File diff suppressed because it is too large Load Diff

2
external/OpenGL/GLES2/gl2platform.h vendored

@ -1,7 +1,7 @@
#ifndef __gl2platform_h_
#define __gl2platform_h_
/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
/* $Revision: 23328 $ on $Date:: 2013-10-02 02:28:28 -0700 #$ */
/*
* This document is licensed under the SGI Free Software B License Version

1922
external/OpenGL/GLES3/gl3.h vendored

File diff suppressed because it is too large Load Diff

2
external/OpenGL/GLES3/gl3platform.h vendored

@ -1,7 +1,7 @@
#ifndef __gl3platform_h_
#define __gl3platform_h_
/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */
/* $Revision: 23328 $ on $Date:: 2013-10-02 02:28:28 -0700 #$ */
/*
* This document is licensed under the SGI Free Software B License Version

15
external/OpenGL/KHR/khrplatform.h vendored

@ -26,7 +26,7 @@
/* Khronos platform-specific types and definitions.
*
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
@ -221,10 +221,23 @@ typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef _WIN64
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*

5
PKGBUILD → package/archlinux/PKGBUILD

@ -19,11 +19,6 @@ build() {
newcxxflags=$(echo $CXXFLAGS | sed s/-O.//g | sed s/-D_FORTIFY_SOURCE=.//g)
export CXXFLAGS="$newcxxflags"
if [ "$CXX" = clang++ ] ; then
newcxxflags=$(echo $CXXFLAGS | sed s/--param=ssp-buffer-size=4//g)
export CXXFLAGS="$newcxxflags"
fi
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \

54
package/archlinux/PKGBUILD-clang

@ -0,0 +1,54 @@
# Author: mosra <mosra@centrum.cz>
pkgname=magnum
pkgver=dev.clang
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (built with clang)"
arch=('i686' 'x86_64')
url="https://github.com/mosra/magnum"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2')
makedepends=('cmake' 'clang' 'ninja')
options=(!strip)
provides=('magnum-git')
build() {
if [ ! -d "$startdir/build-clang" ] ; then
mkdir "$startdir/build-clang"
cd "$startdir/build-clang"
cmake .. \
-DCMAKE_CXX_COMPILER=clang++ \
-G Ninja
fi
cd "$startdir/build-clang"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=ON \
-DWITH_FONTCONVERTER=ON \
-DWITH_MAGNUMINFO=ON \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON
ninja
}
check() {
cd "$startdir/build-clang"
ctest --output-on-failure
}
package() {
cd "$startdir/build-clang"
DESTDIR="$pkgdir/" ninja install
}

56
package/archlinux/PKGBUILD-clang-libc++

@ -0,0 +1,56 @@
# Author: mosra <mosra@centrum.cz>
pkgname=magnum
pkgver=dev.clang.libc++
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (built with clang and libc++)"
arch=('i686' 'x86_64')
url="https://github.com/mosra/magnum"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2' 'libc++')
makedepends=('cmake' 'clang' 'ninja')
options=(!strip)
provides=('magnum-git')
build() {
if [ ! -d "$startdir/build-clang-libc++" ] ; then
mkdir "$startdir/build-clang-libc++"
cd "$startdir/build-clang-libc++"
cmake .. \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" \
-DCMAKE_EXE_LINKER_FLAGS=-lc++abi \
-G Ninja
fi
cd "$startdir/build-clang-libc++"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=ON \
-DWITH_FONTCONVERTER=ON \
-DWITH_MAGNUMINFO=ON \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON
ninja
}
check() {
cd "$startdir/build-clang-libc++"
ctest --output-on-failure
}
package() {
cd "$startdir/build-clang-libc++"
DESTDIR="$pkgdir/" ninja install
}

0
PKGBUILD-emscripten → package/archlinux/PKGBUILD-emscripten

9
PKGBUILD-es2 → package/archlinux/PKGBUILD-es2

@ -15,23 +15,18 @@ build() {
mkdir -p "$startdir/build-es2"
cd "$startdir/build-es2"
if [ "$CXX" = clang++ ] ; then
newcxxflags=$(echo $CXXFLAGS | sed s/--param=ssp-buffer-size=4//g)
export CXXFLAGS="$newcxxflags"
fi
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_TESTS=ON \
-DTARGET_GLES=ON \
-DTARGET_GLES2=ON \
-DWITH_MAGNUMINFO=OFF \
-DWITH_AUDIO=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DBUILD_TESTS=ON \
-G Ninja
ninja
}

11
PKGBUILD-es2desktop → package/archlinux/PKGBUILD-es2desktop

@ -15,25 +15,22 @@ build() {
mkdir -p "$startdir/build-es2desktop"
cd "$startdir/build-es2desktop"
if [ "$CXX" = clang++ ] ; then
newcxxflags=$(echo $CXXFLAGS | sed s/--param=ssp-buffer-size=4//g)
export CXXFLAGS="$newcxxflags"
fi
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_TESTS=ON \
-DTARGET_GLES=ON \
-DTARGET_GLES2=ON \
-DTARGET_DESKTOP_GLES=ON \
-DWITH_MAGNUMINFO=ON \
-DWITH_AUDIO=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_MAGNUMINFO=ON \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON \
-G Ninja
ninja
}

9
PKGBUILD-es3 → package/archlinux/PKGBUILD-es3

@ -15,23 +15,18 @@ build() {
mkdir -p "$startdir/build-es3"
cd "$startdir/build-es3"
if [ "$CXX" = clang++ ] ; then
newcxxflags=$(echo $CXXFLAGS | sed s/--param=ssp-buffer-size=4//g)
export CXXFLAGS="$newcxxflags"
fi
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_TESTS=ON \
-DTARGET_GLES=ON \
-DTARGET_GLES2=OFF \
-DWITH_MAGNUMINFO=OFF \
-DWITH_AUDIO=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DBUILD_TESTS=ON \
-G Ninja
ninja
}

0
PKGBUILD-gcc46 → package/archlinux/PKGBUILD-gcc46

0
PKGBUILD-gcc47 → package/archlinux/PKGBUILD-gcc47

54
package/archlinux/PKGBUILD-gcc49

@ -0,0 +1,54 @@
# Author: mosra <mosra@centrum.cz>
pkgname=magnum
pkgver=dev.gcc49
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (built with GCC 4.9)"
arch=('i686' 'x86_64')
url="https://github.com/mosra/magnum"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2')
makedepends=('cmake' 'ninja' 'gcc-git')
options=(!strip)
provides=('magnum-git')
build() {
if [ ! -d "$startdir/build-gcc49" ] ; then
mkdir "$startdir/build-gcc49"
cd "$startdir/build-gcc49"
cmake .. \
-DCMAKE_CXX_COMPILER=g++-4.9 \
-G Ninja
fi
cd "$startdir/build-gcc49"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=ON \
-DWITH_FONTCONVERTER=ON \
-DWITH_MAGNUMINFO=ON \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON
ninja
}
check() {
cd "$startdir/build-gcc49"
ctest --output-on-failure
}
package() {
cd "$startdir/build-gcc49"
DESTDIR="$pkgdir/" ninja install
}

0
PKGBUILD-mingw32 → package/archlinux/PKGBUILD-mingw32

0
PKGBUILD-nacl-glibc → package/archlinux/PKGBUILD-nacl-glibc

0
PKGBUILD-nacl-newlib → package/archlinux/PKGBUILD-nacl-newlib

12
PKGBUILD-release → package/archlinux/PKGBUILD-release

@ -14,14 +14,10 @@ build() {
mkdir -p "$startdir/build"
cd "$startdir/build/"
if [ "$CXX" = clang++ ] ; then
newcxxflags=$(echo $CXXFLAGS | sed s/--param=ssp-buffer-size=4//g)
export CXXFLAGS="$newcxxflags"
fi
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
@ -30,7 +26,11 @@ build() {
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DBUILD_TESTS=TRUE \
-DWITH_DISTANCEFIELDCONVERTER=ON \
-DWITH_FONTCONVERTER=ON \
-DWITH_MAGNUMINFO=ON \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON \
-G Ninja
ninja
}

114
package/ci/jenkins-emscripten.xml

@ -0,0 +1,114 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
git submodule init
git submodule update
if [ "${compatibility}" = "deprecated" ] ; then
deprecated_build_flag=ON
else
deprecated_build_flag=OFF
fi
mkdir -p build-emscripten-${compatibility}
cd build-emscripten-${compatibility}
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_MODULE_PATH="${WORKSPACE}/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \
-DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/emscripten \
-DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/emscripten-${compatibility} \
-DBUILD_TESTS=ON \
-DBUILD_DEPRECATED=${deprecated_build_flag} \
`#-DWITH_AUDIO=ON` \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
`#-DWITH_WAVAUDIOIMPORTER=ON` \
`#-DWITH_MAGNUMINFO=ON` \
-G Ninja
ninja
ctest --output-on-failure || true
ninja install
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>Errors while running CTest</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
compatibility == "deprecated"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>UNSTABLE</name>
<ordinal>1</ordinal>
<color>YELLOW</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

113
package/ci/jenkins-gltests.xml

@ -0,0 +1,113 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>compiler</name>
<values>
<string>g++</string>
<string>g++-4.7</string>
<string>g++-4.6</string>
<string>clang++</string>
<string>clang++-libc++</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>libraries</name>
<values>
<string>static</string>
<string>dynamic</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>gl</name>
<values>
<string>desktop</string>
<string>es2</string>
<string>es2desktop</string>
<string>es3</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
cd build-${compiler}-${libraries}-${compatibility}-${gl}
ninja
ctest --output-on-failure -R GLTest || true
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>Errors while running CTest</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
compiler == "g++" && libraries == "dynamic" && compatibility == "deprecated" && gl == "desktop"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>SUCCESS</name>
<ordinal>0</ordinal>
<color>BLUE</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

128
package/ci/jenkins-mingw32.xml

@ -0,0 +1,128 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>libraries</name>
<values>
<string>static</string>
<string>dynamic</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
git submodule init
git submodule update
if [ ${libraries} = "static" ] ; then
static_build_flag="-DBUILD_STATIC=ON -DBUILD_STATIC_PIC=ON"
fi
if [ "${compatibility}" = "deprecated" ] ; then
deprecated_build_flag=ON
else
deprecated_build_flag=OFF
fi
mkdir -p build-mingw32-${libraries}-${compatibility}
cd build-mingw32-${libraries}-${compatibility}
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/archlinux/basic-mingw32.cmake \
-DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/mingw32-${libraries} \
-DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/mingw32-${libraries}-${compatibility} \
-DBUILD_TESTS=ON \
-DBUILD_DEPRECATED=${deprecated_build_flag} \
${static_build_flag} \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
`#-DWITH_SDL2APPLICATION=ON` \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
`#-DWITH_DISTANCEFIELDCONVERTER=ON` \
`#-DWITH_FONTCONVERTER=ON` \
`#-DWITH_MAGNUMINFO=ON` \
-G Ninja
ninja
ninja install
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>Errors while running CTest</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
libraries == "dynamic" && compatibility == "deprecated"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>UNSTABLE</name>
<ordinal>1</ordinal>
<color>YELLOW</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

183
package/ci/jenkins.xml

@ -0,0 +1,183 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>compiler</name>
<values>
<string>g++</string>
<string>g++-4.7</string>
<string>g++-4.6</string>
<string>clang++</string>
<string>clang++-libc++</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>libraries</name>
<values>
<string>static</string>
<string>dynamic</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>gl</name>
<values>
<string>desktop</string>
<string>es2</string>
<string>es2desktop</string>
<string>es3</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
if [ ${compiler} = "clang++-libc++" ] ; then
compiler_binary=clang++
compiler_flags=(-DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS=-lc++abi)
else
compiler_binary=${compiler}
fi
if [ ${libraries} = "static" ] ; then
static_build_flag="-DBUILD_STATIC=ON -DBUILD_STATIC_PIC=ON"
fi
if [ "${compatibility}" = "deprecated" ] ; then
deprecated_build_flag=ON
else
deprecated_build_flag=OFF
fi
if [ ${gl} = "desktop" ] ; then
desktop_flag=ON
windowless_flag=ON
elif [ ${gl} = "es2" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON"
desktop_flag=OFF
windowless_flag=OFF
elif [ ${gl} = "es2desktop" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON -DTARGET_DESKTOP_GLES=ON"
desktop_flag=OFF
windowless_flag=ON
elif [ ${gl} = "es3" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=OFF"
desktop_flag=OFF
windowless_flag=OFF
fi
mkdir -p build-${compiler}-${libraries}-${compatibility}-${gl}
cd build-${compiler}-${libraries}-${compatibility}-${gl}
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/${compiler}-${libraries} \
-DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/${compiler}-${libraries}-${compatibility}-${gl} \
-DCMAKE_INSTALL_RPATH="${JENKINS_HOME}/filesystem/${compiler}-${libraries}/lib;${JENKINS_HOME}/filesystem/${compiler}-${libraries}-${compatibility}-${gl}/lib" \
-DCMAKE_CXX_COMPILER=${compiler_binary} \
"${compiler_flags[@]}" \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=${windowless_flag} \
-DBUILD_DEPRECATED=${deprecated_build_flag} \
${static_build_flag} \
${gl_flags} \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=${desktop_flag} \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=${desktop_flag} \
-DWITH_FONTCONVERTER=${desktop_flag} \
-DWITH_MAGNUMINFO=${windowless_flag} \
-G Ninja
ninja
ctest --output-on-failure -E GLTest || true
ninja install
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.BuildTrigger>
<childProjects>Magnum-GLTests</childProjects>
<threshold>
<name>SUCCESS</name>
<ordinal>0</ordinal>
<color>BLUE</color>
<completeBuild>true</completeBuild>
</threshold>
</hudson.tasks.BuildTrigger>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>Errors while running CTest</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
compiler == "g++" && libraries == "dynamic" && compatibility == "deprecated" && gl == "desktop"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>UNSTABLE</name>
<ordinal>1</ordinal>
<color>YELLOW</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

30
src/AbstractFramebuffer.cpp

@ -112,7 +112,7 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) {
state->readBinding = state->drawBinding = _id;
} else CORRADE_ASSERT_UNREACHABLE();
glBindFramebuffer(static_cast<GLenum>(target), _id);
glBindFramebuffer(GLenum(target), _id);
}
FramebufferTarget AbstractFramebuffer::bindInternal() {
@ -139,12 +139,12 @@ FramebufferTarget AbstractFramebuffer::bindInternal() {
#endif
}
void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Rectanglei& sourceRectangle, const Rectanglei& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter) {
void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter) {
source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw);
/** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */
#ifndef MAGNUM_TARGET_GLES2
glBlitFramebuffer(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), static_cast<GLbitfield>(mask), static_cast<GLenum>(filter));
glBlitFramebuffer(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
static_cast<void>(sourceRectangle);
static_cast<void>(destinationRectangle);
@ -153,7 +153,7 @@ void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer&
#endif
}
AbstractFramebuffer& AbstractFramebuffer::setViewport(const Rectanglei& rectangle) {
AbstractFramebuffer& AbstractFramebuffer::setViewport(const Range2Di& rectangle) {
_viewport = rectangle;
/* Update the viewport if the framebuffer is currently bound */
@ -174,7 +174,7 @@ void AbstractFramebuffer::setViewportInternal() {
/* Update the state and viewport */
state->viewport = _viewport;
glViewport(_viewport.left(), _viewport.bottom(), _viewport.width(), _viewport.height());
glViewport(_viewport.left(), _viewport.bottom(), _viewport.sizeX(), _viewport.sizeY());
}
void AbstractFramebuffer::clear(FramebufferClearMask mask) {
@ -183,7 +183,7 @@ void AbstractFramebuffer::clear(FramebufferClearMask mask) {
#else
bindInternal(drawTarget);
#endif
glClear(static_cast<GLbitfield>(mask));
glClear(GLbitfield(mask));
}
void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Image2D& image) {
@ -199,7 +199,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Ima
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, Buffer::Usage usage) {
void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, BufferUsage usage) {
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Read);
#else
@ -227,10 +227,10 @@ void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attach
#endif
}
void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments, const Rectanglei& rectangle) {
void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle) {
/** @todo Re-enable when extension wrangler is available for ES2 */
#ifndef MAGNUM_TARGET_GLES2
glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.width(), rectangle.height());
glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY());
#else
//glDiscardSubFramebufferEXT(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.width(), rectangle.height());
static_cast<void>(count);
@ -277,7 +277,6 @@ void AbstractFramebuffer::initializeContextBasedFunctionality(Context& context)
else readTarget = drawTarget = FramebufferTarget::ReadDraw;
#endif
#ifndef MAGNUM_TARGET_GLES3
#ifndef MAGNUM_TARGET_GLES
if(context.isExtensionSupported<Extensions::GL::ARB::robustness>())
#else
@ -295,9 +294,6 @@ void AbstractFramebuffer::initializeContextBasedFunctionality(Context& context)
readImplementation = &AbstractFramebuffer::readImplementationRobustness;
#endif
}
#else
static_cast<void>(context);
#endif
}
GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTarget target) {
@ -377,17 +373,16 @@ void AbstractFramebuffer::readBufferImplementationDSA(GLenum buffer) {
#endif
void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glReadPixels(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
#ifndef MAGNUM_TARGET_GLES3
void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
/** @todo Enable when extension wrangler for ES is available */
#ifndef MAGNUM_TARGET_GLES
glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), dataSize, data);
glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), dataSize, data);
#else
CORRADE_INTERNAL_ASSERT(false);
//glReadnPixelsEXT(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
//glReadnPixelsEXT(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
static_cast<void>(offset);
static_cast<void>(size);
static_cast<void>(format);
@ -396,6 +391,5 @@ void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, c
static_cast<void>(data);
#endif
}
#endif
}

21
src/AbstractFramebuffer.h

@ -30,8 +30,9 @@
#include <Containers/EnumSet.h>
#include "Math/Geometry/Rectangle.h"
#include "Buffer.h"
#include "Math/Range.h"
#include "Magnum.h"
#include "OpenGL.h"
#ifdef CORRADE_GCC45_COMPATIBILITY
#include "ImageFormat.h"
@ -210,7 +211,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
* @es_extension{NV,framebuffer_blit}
*/
static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Rectanglei& sourceRectangle, const Rectanglei& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
/**
* @brief Copy block of pixels
@ -227,7 +228,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
* @es_extension{NV,framebuffer_blit}
*/
static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Rectanglei& rectangle, FramebufferBlitMask mask) {
static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& rectangle, FramebufferBlitMask mask) {
blit(source, destination, rectangle, rectangle, mask, FramebufferBlitFilter::Nearest);
}
@ -245,7 +246,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
void bind(FramebufferTarget target);
/** @brief Viewport rectangle */
Rectanglei viewport() const { return _viewport; }
Range2Di viewport() const { return _viewport; }
/**
* @brief Set viewport
@ -256,7 +257,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* rectangle.
* @see @ref maxViewportSize(), @fn_gl{Viewport}
*/
AbstractFramebuffer& setViewport(const Rectanglei& rectangle);
AbstractFramebuffer& setViewport(const Range2Di& rectangle);
/**
* @brief Clear specified buffers in framebuffer
@ -300,7 +301,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* information.
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0.
*/
void read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, Buffer::Usage usage);
void read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, BufferUsage usage);
#endif
#ifdef DOXYGEN_GENERATING_OUTPUT
@ -333,10 +334,10 @@ class MAGNUM_EXPORT AbstractFramebuffer {
static ReadBufferImplementation readBufferImplementation;
void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments);
void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments, const Rectanglei& rectangle);
void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle);
GLuint _id;
Rectanglei _viewport;
Range2Di _viewport;
private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context& context);
@ -363,9 +364,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ColorFormat, ColorType, std::size_t, GLvoid*);
static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
#ifndef MAGNUM_TARGET_GLES3
static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
#endif
static ReadImplementation MAGNUM_LOCAL readImplementation;
};

8
src/AbstractImage.cpp

@ -61,13 +61,9 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) {
case ColorType::UnsignedShort565Rev:
#endif
case ColorType::UnsignedShort4444:
#ifndef MAGNUM_TARGET_GLES3
case ColorType::UnsignedShort4444Rev:
#endif
case ColorType::UnsignedShort5551:
#ifndef MAGNUM_TARGET_GLES3
case ColorType::UnsignedShort1555Rev:
#endif
return 2;
#ifndef MAGNUM_TARGET_GLES
case ColorType::UnsignedInt8888:
@ -123,9 +119,7 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) {
#ifndef MAGNUM_TARGET_GLES2
case ColorFormat::RGBAInteger:
#endif
#ifndef MAGNUM_TARGET_GLES3
case ColorFormat::BGRA:
#endif
#ifndef MAGNUM_TARGET_GLES
case ColorFormat::BGRAInteger:
#endif
@ -133,9 +127,7 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) {
/* Handled above */
case ColorFormat::DepthComponent:
#ifndef MAGNUM_TARGET_GLES3
case ColorFormat::StencilIndex:
#endif
case ColorFormat::DepthStencil:
CORRADE_ASSERT_UNREACHABLE();
}

11
src/AbstractShaderProgram.h

@ -216,8 +216,9 @@ layout(binding = 1) uniform sampler2D specularTexture;
If you don't have the required extension (or if you want to change the layer
later), declare the uniforms without the `layout()` qualifier and set the
texture layer uniform using @ref setUniform(Int, Int). Note that additional
syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0.
texture layer uniform using @ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)".
Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES
1.0.
@code
uniform sampler2D diffuseTexture;
uniform sampler2D specularTexture;
@ -229,9 +230,11 @@ setUniform(SpecularTextureUniform, SpecularTextureLayer);
@see @ref Shader::maxTextureImageUnits()
@requires_gl42 %Extension @extension{ARB,shading_language_420pack} for explicit
texture layer binding instead of using setUniform(Int, Int).
texture layer binding instead of using
@ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)".
@requires_gl Explicit texture layer binding is not supported in OpenGL ES. Use
setUniform(Int, Int) instead.
@ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)"
instead.
@section AbstractShaderProgram-rendering-workflow Rendering workflow

60
src/AbstractTexture.cpp

@ -24,7 +24,6 @@
#include "AbstractTexture.h"
#include "Buffer.h"
#include "BufferImage.h"
#include "ColorFormat.h"
#include "Context.h"
@ -191,8 +190,7 @@ AbstractTexture& AbstractTexture::setMinificationFilter(Sampler::Filter filter,
CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE || mipmap == Sampler::Mipmap::Base, "AbstractTexture: rectangle textures cannot have mipmaps", *this);
#endif
(this->*parameteriImplementation)(GL_TEXTURE_MIN_FILTER,
static_cast<GLint>(filter)|static_cast<GLint>(mipmap));
(this->*parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap));
return *this;
}
@ -369,9 +367,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RGB5:
#endif
case TextureFormat::RGB565:
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::RGB10:
#endif
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGB12:
#endif
@ -379,9 +375,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::R11FG11FB10F:
case TextureFormat::RGB9E5:
#endif
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::SRGB:
#endif
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::SRGB8:
#endif
@ -424,9 +418,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGBA12:
#endif
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::SRGBAlpha:
#endif
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::SRGB8Alpha8:
#endif
@ -458,9 +450,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::DepthComponent:
case TextureFormat::DepthComponent16:
case TextureFormat::DepthComponent24:
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::DepthComponent32:
#endif
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::DepthComponent32F:
#endif
@ -504,10 +494,8 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::Luminance:
case TextureFormat::LuminanceAlpha:
#endif
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::SRGB:
case TextureFormat::SRGBAlpha:
#endif
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::SRGB8:
case TextureFormat::SRGB8Alpha8:
@ -622,9 +610,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::RGB565:
return ColorType::UnsignedShort565;
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::RGB10:
#endif
case TextureFormat::RGB10A2:
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGB10A2UI:
@ -643,9 +629,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::DepthComponent:
case TextureFormat::DepthComponent24:
#ifndef MAGNUM_TARGET_GLES3
case TextureFormat::DepthComponent32:
#endif
return ColorType::UnsignedInt;
#ifndef MAGNUM_TARGET_GLES2
@ -890,22 +874,22 @@ void AbstractTexture::getImageImplementationRobustness(const GLenum target, cons
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexImage1D(target, level, static_cast<GLint>(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTexImage1D(target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data);
}
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data);
}
#endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
}
#endif
@ -913,7 +897,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex
bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2
glTexImage3D(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTexImage3D(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
#else
static_cast<void>(target);
static_cast<void>(level);
@ -927,29 +911,29 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexSubImage1D(target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTexSubImage1D(target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
#endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
#endif
@ -957,7 +941,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2
glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
#else
static_cast<void>(target);
static_cast<void>(level);
@ -971,7 +955,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
}
#endif
@ -1005,7 +989,7 @@ template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, Image<1>&);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&);
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, Buffer::Usage usage) {
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(this, target, level);
const std::size_t dataSize = size.product()*image.pixelSize();
if(image.size() != size)
@ -1015,9 +999,9 @@ template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLin
(this->*getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr);
}
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, BufferImage<1>&, Buffer::Usage);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>&, Buffer::Usage);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>&, Buffer::Usage);
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, BufferImage<1>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>&, BufferUsage);
#endif
#endif
@ -1128,15 +1112,15 @@ void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const
CORRADE_ASSERT(texture->_target != GL_TEXTURE_RECTANGLE || ((wrapping.x() == Sampler::Wrapping::ClampToEdge || wrapping.x() == Sampler::Wrapping::ClampToBorder) && (wrapping.y() == Sampler::Wrapping::ClampToEdge || wrapping.y() == Sampler::Wrapping::ClampToEdge)), "AbstractTexture: rectangle texture wrapping must either clamp to border or to edge", );
#endif
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast<GLint>(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, static_cast<GLint>(wrapping.y()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
}
void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture* texture, const Array3D<Sampler::Wrapping>& wrapping) {
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast<GLint>(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, static_cast<GLint>(wrapping.y()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y()));
#ifndef MAGNUM_TARGET_GLES
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_R, static_cast<GLint>(wrapping.z()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_R, GLint(wrapping.z()));
#endif
}
#endif

43
src/AbstractTexture.h

@ -25,13 +25,10 @@
*/
/** @file
* @brief Class Magnum::AbstractTexture
* @brief Class @ref Magnum::AbstractTexture
*/
#include "Array.h"
#ifndef MAGNUM_TARGET_GLES2
#include "Buffer.h"
#endif
#include "Color.h"
#include "Sampler.h"
@ -45,8 +42,9 @@ namespace Magnum {
/**
@brief Base for textures
See Texture, CubeMapTexture and CubeMapTextureArray documentation for more
information and usage examples.
Encapsulates one OpenGL texture object. See @ref Texture, @ref CubeMapTexture
and @ref CubeMapTextureArray documentation for more information and usage
examples.
@section AbstractTexture-performance-optimization Performance optimizations and security
@ -57,15 +55,15 @@ affect active bindings in user layers. %Texture limits and
implementation-defined values (such as @ref maxColorSamples()) are cached, so
repeated queries don't result in repeated @fn_gl{Get} calls.
If extension @extension{EXT,direct_state_access} is available, bind() uses DSA
function to avoid unnecessary calls to @fn_gl{ActiveTexture}. Also all texture
configuration and data updating functions use DSA functions to avoid
If extension @extension{EXT,direct_state_access} is available, @ref bind() uses
DSA function to avoid unnecessary calls to @fn_gl{ActiveTexture}. Also all
texture configuration and data updating functions use DSA functions to avoid
unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. See
respective function documentation for more information.
If extension @extension{ARB,robustness} is available, image reading operations
(such as Texture::image()) are protected from buffer overflow. However, if both
@extension{EXT,direct_state_access} and @extension{ARB,robustness} are
(such as @ref Texture::image()) are protected from buffer overflow. However, if
both @extension{EXT,direct_state_access} and @extension{ARB,robustness} are
available, the DSA version is used, because it is better for performance and
there isn't any function combining both features.
@ -84,11 +82,12 @@ OpenGL ES 3.0 or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not
available, the feature is emulated with sequence of @ref Texture::setImage() "setImage()"
calls.
You can use functions invalidateImage() and @ref Texture::invalidateSubImage() "invalidateSubImage()"
if you don't need texture data anymore to avoid unnecessary memory operations
performed by OpenGL in order to preserve the data. If running on OpenGL ES or
extension @extension{ARB,invalidate_subdata} is not available, these functions
do nothing.
You can use functions @ref invalidateImage() and
@ref Texture::invalidateSubImage() "invalidateSubImage()" if you don't need
texture data anymore to avoid unnecessary memory operations performed by OpenGL
in order to preserve the data. If running on OpenGL ES or extension
@extension{ARB,invalidate_subdata} is not available, these functions do
nothing.
@todo all texture [level] parameters, global texture parameters
@todo Add glPixelStore encapsulation
@ -190,8 +189,8 @@ class MAGNUM_EXPORT AbstractTexture {
* @brief Set minification filter
* @param filter Filter
* @param mipmap Mipmap filtering. If set to anything else than
* BaseMipLevel, make sure textures for all mip levels are set or
* call generateMipmap().
* @ref Sampler::Mipmap::Base, make sure textures for all mip
* levels are set or call @ref generateMipmap().
* @return Reference to self (for method chaining)
*
* Sets filter used when the object pixel size is smaller than the
@ -221,11 +220,10 @@ class MAGNUM_EXPORT AbstractTexture {
* with @def_gl{TEXTURE_MAG_FILTER}
*/
AbstractTexture& setMagnificationFilter(Sampler::Filter filter) {
(this->*parameteriImplementation)(GL_TEXTURE_MAG_FILTER, static_cast<GLint>(filter));
(this->*parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter));
return *this;
}
#ifndef MAGNUM_TARGET_GLES3
/**
* @brief Set border color
* @return Reference to self (for method chaining)
@ -267,7 +265,6 @@ class MAGNUM_EXPORT AbstractTexture {
(this->*parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
return *this;
}
#endif
/**
* @brief Invalidate texture image
@ -325,7 +322,7 @@ class MAGNUM_EXPORT AbstractTexture {
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void image(GLenum target, GLint level, Image<dimensions>& image);
template<UnsignedInt dimensions> void image(GLenum target, GLint level, BufferImage<dimensions>& image, Buffer::Usage usage);
template<UnsignedInt dimensions> void image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage);
#endif
GLenum _target;
@ -483,7 +480,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> {
static Math::Vector<1, GLint> imageSize(AbstractTexture* texture, GLenum target, GLint level);
static void setWrapping(AbstractTexture* texture, const Array1D<Sampler::Wrapping>& wrapping) {
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast<GLint>(wrapping.x()));
(texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x()));
}
static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {

52
src/Audio/Source.cpp

@ -24,6 +24,8 @@
#include "Source.h"
#include <Containers/Array.h>
#include "Audio/Buffer.h"
namespace Magnum { namespace Audio {
@ -37,8 +39,8 @@ Source& Source::setBuffer(Buffer* buffer) {
namespace {
const ALuint* sourceIds(const std::initializer_list<Source*>& sources) {
ALuint* const ids = new ALuint[sources.size()];
Containers::Array<ALuint> sourceIds(const std::initializer_list<Source*>& sources) {
Containers::Array<ALuint> ids(sources.size());
for(auto it = sources.begin(); it != sources.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it);
ids[it-sources.begin()] = (*it)->id();
@ -46,8 +48,8 @@ const ALuint* sourceIds(const std::initializer_list<Source*>& sources) {
return ids;
}
const ALuint* sourceIds(const std::vector<Source*>& sources) {
ALuint* const ids = new ALuint[sources.size()];
Containers::Array<ALuint> sourceIds(const std::vector<Source*>& sources) {
Containers::Array<ALuint> ids(sources.size());
for(auto it = sources.begin(); it != sources.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it);
ids[it-sources.begin()] = (*it)->id();
@ -57,54 +59,44 @@ const ALuint* sourceIds(const std::vector<Source*>& sources) {
}
/** @todo Okay, this is too much code copying even for me */
void Source::play(std::initializer_list<Source*> sources) {
const ALuint* const ids = sourceIds(sources);
alSourcePlayv(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourcePlayv(ids.size(), ids);
}
void Source::play(const std::vector<Source*>& sources) {
const ALuint* const ids = sourceIds(sources);
alSourcePlayv(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourcePlayv(ids.size(), ids);
}
void Source::pause(std::initializer_list<Source*> sources) {
const ALuint* const ids = sourceIds(sources);
alSourcePausev(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourcePausev(ids.size(), ids);
}
void Source::pause(const std::vector<Source*>& sources) {
const ALuint* const ids = sourceIds(sources);
alSourcePausev(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourcePausev(ids.size(), ids);
}
void Source::stop(std::initializer_list<Source*> sources) {
const ALuint* const ids = sourceIds(sources);
alSourceStopv(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourceStopv(ids.size(), ids);
}
void Source::stop(const std::vector<Source*>& sources) {
const ALuint* const ids = sourceIds(sources);
alSourceStopv(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourceStopv(ids.size(), ids);
}
void Source::rewind(std::initializer_list<Source*> sources) {
const ALuint* const ids = sourceIds(sources);
alSourceRewindv(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourceRewindv(ids.size(), ids);
}
void Source::rewind(const std::vector<Source*>& sources) {
const ALuint* const ids = sourceIds(sources);
alSourceRewindv(sources.size(), ids);
delete[] ids;
const auto ids = sourceIds(sources);
alSourceRewindv(ids.size(), ids);
}
Debug operator<<(Debug debug, const Source::State value) {

2
src/Audio/Source.h

@ -560,7 +560,7 @@ inline Source& Source::operator=(Source&& other) {
return *this;
}
auto Source::state() const -> State {
inline auto Source::state() const -> State {
ALint state;
alGetSourcei(_id, AL_SOURCE_STATE, &state);
return State(state);

12
src/Audio/magnumAudioVisibility.h

@ -26,10 +26,16 @@
#include <Utility/Visibility.h>
#ifdef MagnumAudio_EXPORTS
#define MAGNUM_AUDIO_EXPORT CORRADE_VISIBILITY_EXPORT
#include "magnumConfigure.h"
#ifndef MAGNUM_BUILD_STATIC
#ifdef MagnumAudio_EXPORTS
#define MAGNUM_AUDIO_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_AUDIO_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_AUDIO_EXPORT CORRADE_VISIBILITY_IMPORT
#define MAGNUM_AUDIO_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#endif

30
src/Buffer.cpp

@ -44,9 +44,7 @@ Buffer::DataImplementation Buffer::dataImplementation = &Buffer::dataImplementat
Buffer::SubDataImplementation Buffer::subDataImplementation = &Buffer::subDataImplementationDefault;
Buffer::InvalidateImplementation Buffer::invalidateImplementation = &Buffer::invalidateImplementationNoOp;
Buffer::InvalidateSubImplementation Buffer::invalidateSubImplementation = &Buffer::invalidateSubImplementationNoOp;
#ifndef MAGNUM_TARGET_GLES3
Buffer::MapImplementation Buffer::mapImplementation = &Buffer::mapImplementationDefault;
#endif
Buffer::MapRangeImplementation Buffer::mapRangeImplementation = &Buffer::mapRangeImplementationDefault;
Buffer::FlushMappedRangeImplementation Buffer::flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDefault;
Buffer::UnmapImplementation Buffer::unmapImplementation = &Buffer::unmapImplementationDefault;
@ -170,7 +168,7 @@ void Buffer::bind(Target target, GLuint id) {
/* Bind the buffer otherwise */
bound = id;
glBindBuffer(static_cast<GLenum>(target), id);
glBindBuffer(GLenum(target), id);
}
Buffer::Target Buffer::bindInternal(Target hint) {
@ -187,7 +185,7 @@ Buffer::Target Buffer::bindInternal(Target hint) {
/* Bind the buffer to hint target otherwise */
hintBinding = _id;
glBindBuffer(static_cast<GLenum>(hint), _id);
glBindBuffer(GLenum(hint), _id);
return hint;
}
@ -206,7 +204,7 @@ void* Buffer::mapSub(const GLintptr offset, const GLsizeiptr length, const MapAc
/** @todo Enable also in Emscripten (?) when extension wrangler is available */
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(!_mappedBuffer, "Buffer::mapSub(): the buffer is already mapped", nullptr);
return _mappedBuffer = glMapBufferSubDataCHROMIUM(static_cast<GLenum>(bindInternal(_targetHint)), offset, length, GLenum(access));
return _mappedBuffer = glMapBufferSubDataCHROMIUM(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access));
#else
CORRADE_INTERNAL_ASSERT(false);
static_cast<void>(offset);
@ -228,7 +226,7 @@ void Buffer::unmapSub() {
#ifndef MAGNUM_TARGET_GLES2
void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) {
glCopyBufferSubData(static_cast<GLenum>(read.bindInternal(Target::CopyRead)), static_cast<GLenum>(write.bindInternal(Target::CopyWrite)), readOffset, writeOffset, size);
glCopyBufferSubData(GLenum(read.bindInternal(Target::CopyRead)), GLenum(write.bindInternal(Target::CopyWrite)), readOffset, writeOffset, size);
}
#ifndef MAGNUM_TARGET_GLES
@ -258,18 +256,18 @@ void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr
}
#endif
void Buffer::dataImplementationDefault(GLsizeiptr size, const GLvoid* data, Buffer::Usage usage) {
glBufferData(static_cast<GLenum>(bindInternal(_targetHint)), size, data, static_cast<GLenum>(usage));
void Buffer::dataImplementationDefault(GLsizeiptr size, const GLvoid* data, BufferUsage usage) {
glBufferData(GLenum(bindInternal(_targetHint)), size, data, GLenum(usage));
}
#ifndef MAGNUM_TARGET_GLES
void Buffer::dataImplementationDSA(GLsizeiptr size, const GLvoid* data, Buffer::Usage usage) {
glNamedBufferDataEXT(_id, size, data, static_cast<GLenum>(usage));
void Buffer::dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUsage usage) {
glNamedBufferDataEXT(_id, size, data, GLenum(usage));
}
#endif
void Buffer::subDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data) {
glBufferSubData(static_cast<GLenum>(bindInternal(_targetHint)), offset, size, data);
glBufferSubData(GLenum(bindInternal(_targetHint)), offset, size, data);
}
#ifndef MAGNUM_TARGET_GLES
@ -294,11 +292,10 @@ void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length)
}
#endif
#ifndef MAGNUM_TARGET_GLES3
void* Buffer::mapImplementationDefault(MapAccess access) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES
return glMapBuffer(static_cast<GLenum>(bindInternal(_targetHint)), GLenum(access));
return glMapBuffer(GLenum(bindInternal(_targetHint)), GLenum(access));
#else
static_cast<void>(access);
return nullptr;
@ -310,12 +307,11 @@ void* Buffer::mapImplementationDSA(MapAccess access) {
return glMapNamedBufferEXT(_id, GLenum(access));
}
#endif
#endif
void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES2
return glMapBufferRange(static_cast<GLenum>(bindInternal(_targetHint)), offset, length, GLenum(access));
return glMapBufferRange(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access));
#else
static_cast<void>(offset);
static_cast<void>(length);
@ -333,7 +329,7 @@ void* Buffer::mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapF
void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glFlushMappedBufferRange(static_cast<GLenum>(bindInternal(_targetHint)), offset, length);
glFlushMappedBufferRange(GLenum(bindInternal(_targetHint)), offset, length);
#else
static_cast<void>(offset);
static_cast<void>(length);
@ -349,7 +345,7 @@ void Buffer::flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr lengt
bool Buffer::unmapImplementationDefault() {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES2
return glUnmapBuffer(static_cast<GLenum>(bindInternal(_targetHint)));
return glUnmapBuffer(GLenum(bindInternal(_targetHint)));
#else
return false;
#endif

333
src/Buffer.h

@ -25,7 +25,7 @@
*/
/** @file /Buffer.h
* @brief Class Magnum::Buffer
* @brief Class @ref Magnum::Buffer, enum @ref Magnum::BufferUsage
*/
#include <cstddef>
@ -41,6 +41,79 @@
namespace Magnum {
/**
@brief %Buffer usage
@see @ref Buffer, @ref Buffer::setData(Containers::ArrayReference<const void>, BufferUsage)
*/
enum class BufferUsage: GLenum {
/** Set once by the application and used infrequently for drawing. */
StreamDraw = GL_STREAM_DRAW,
#ifndef MAGNUM_TARGET_GLES2
/**
* Set once as output from an OpenGL command and used infequently for
* drawing.
* @requires_gles30 Only @ref Magnum::BufferUsage::StreamDraw "BufferUsage::StreamDraw"
* is available in OpenGL ES 2.0.
*/
StreamRead = GL_STREAM_READ,
/**
* Set once as output from an OpenGL command and used infrequently for
* drawing or copying to other buffers.
* @requires_gles30 Only @ref Magnum::BufferUsage::StreamDraw "BufferUsage::StreamDraw"
* is available in OpenGL ES 2.0.
*/
StreamCopy = GL_STREAM_COPY,
#endif
/** Set once by the application and used frequently for drawing. */
StaticDraw = GL_STATIC_DRAW,
#ifndef MAGNUM_TARGET_GLES2
/**
* Set once as output from an OpenGL command and queried many times by the
* application.
* @requires_gles30 Only @ref Magnum::BufferUsage::StaticDraw "BufferUsage::StaticDraw"
* is available in OpenGL ES 2.0.
*/
StaticRead = GL_STATIC_READ,
/**
* Set once as output from an OpenGL command and used frequently for
* drawing or copying to other buffers.
* @requires_gles30 Only @ref Magnum::BufferUsage::StaticDraw "BufferUsage::StaticDraw"
* is available in OpenGL ES 2.0.
*/
StaticCopy = GL_STATIC_COPY,
#endif
/**
* Updated frequently by the application and used frequently for drawing or
* copying to other images.
*/
DynamicDraw = GL_DYNAMIC_DRAW,
#ifndef MAGNUM_TARGET_GLES2
/**
* Updated frequently as output from OpenGL command and queried many times
* from the application.
* @requires_gles30 Only @ref Magnum::BufferUsage::DynamicDraw "BufferUsage::DynamicDraw"
* is available in OpenGL ES 2.0.
*/
DynamicRead = GL_DYNAMIC_READ,
/**
* Updated frequently as output from OpenGL command and used frequently for
* drawing or copying to other images.
* @requires_gles30 Only @ref Magnum::BufferUsage::DynamicDraw "BufferUsage::DynamicDraw"
* is available in OpenGL ES 2.0.
*/
DynamicCopy = GL_DYNAMIC_COPY
#endif
};
/**
@brief %Buffer
@ -49,38 +122,29 @@ data updates.
@section Buffer-data Data updating
Default way to set or update buffer data with setData() or setSubData() is to
explicitly specify data size and pass the pointer to it:
Default way to set or update buffer data with @ref setData() or @ref setSubData()
is to use @ref Corrade::Containers::ArrayReference. See its documentation for
more information about automatic conversions etc.
@code
Buffer buffer;
Vector3* data = new Vector3[200];
buffer.setData(200*sizeof(Vector3), data, Buffer::Usage::StaticDraw);
Containers::ArrayReference<Vector3> data;
buffer.setData(data, BufferUsage::StaticDraw);
@endcode
Howewer, in some cases, you have the data in fixed-size array with size known
at compile time. There is an convenient overload which detects the size of
passed array, so you don't have to repeat it:
@code
Vector3 data[] = {
// ...
};
buffer.setData(data, Buffer::Usage::StaticDraw);
@endcode
There is also overload for array-like containers from STL, such as `std::vector` or
`std::array`:
There is also overload for array-like containers from STL, such as `std::vector`
or `std::array`:
@code
std::vector<Vector3> data;
buffer.setData(data, Buffer::Usage::StaticDraw);
buffer.setData(data, BufferUsage::StaticDraw);
@endcode
@subsection Buffer-data-mapping Memory mapping
%Buffer data can be also updated asynchronously. First you need to allocate
the buffer to desired size by passing `nullptr` to setData(), e.g.:
the buffer to desired size by passing `nullptr` to @ref setData(), e.g.:
@code
buffer.setData(200*sizeof(Vector3)), nullptr, Buffer::Usage::StaticDraw);
buffer.setData({nullptr, 200*sizeof(Vector3)}, BufferUsage::StaticDraw);
@endcode
Then you can map the buffer to client memory and operate with the memory
directly. After you are done with the operation, call unmap() to unmap the
directly. After you are done with the operation, call @ref unmap() to unmap the
buffer again.
@code
Vector3* data = static_cast<Vector3*>(buffer.map(0, 200*sizeof(Vector3), Buffer::MapFlag::Write|Buffer::MapFlag::InvalidateBuffer));
@ -89,8 +153,8 @@ for(std::size_t i = 0; i != 200; ++i)
CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
@endcode
If you are updating only a few discrete portions of the buffer, you can use
@ref MapFlag::FlushExplicit and flushMappedRange() to reduce number of memory
operations performed by OpenGL on unmapping. Example:
@ref MapFlag::FlushExplicit and @ref flushMappedRange() to reduce number of
memory operations performed by OpenGL on unmapping. Example:
@code
Vector3* data = static_cast<Vector3*>(buffer.map(0, 200*sizeof(Vector3), Buffer::MapFlag::Write|Buffer::MapFlag::FlushExplicit));
for(std::size_t i: {7, 27, 56, 128}) {
@ -104,20 +168,21 @@ CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
The engine tracks currently bound buffers to avoid unnecessary calls to
@fn_gl{BindBuffer}. If the buffer is already bound to some target, functions
copy(), setData(), setSubData(), map(), flushMappedRange() and unmap() use
that target instead of binding the buffer to some specific target. You can
also use setTargetHint() to possibly reduce unnecessary rebinding. %Buffer
limits and implementation-defined values (such as @ref maxVertexAttributeBindings())
are cached, so repeated queries don't result in repeated @fn_gl{Get} calls.
@ref copy(), @ref setData(), @ref setSubData(), @ref map(), @ref flushMappedRange()
and @ref unmap() use that target instead of binding the buffer to some specific
target. You can also use @ref setTargetHint() to possibly reduce unnecessary
rebinding. %Buffer limits and implementation-defined values (such as
@ref maxVertexAttributeBindings()) are cached, so repeated queries don't result
in repeated @fn_gl{Get} calls.
If extension @extension{EXT,direct_state_access} is available, functions
copy(), setData(), setSubData(), map(), flushMappedRange() and unmap() use DSA
functions to avoid unnecessary calls to @fn_gl{BindBuffer}. See their
respective documentation for more information.
@ref copy(), @ref setData(), @ref setSubData(), @ref map(), @ref flushMappedRange()
and @ref unmap() use DSA functions to avoid unnecessary calls to
@fn_gl{BindBuffer}. See their respective documentation for more information.
You can use functions invalidateData() and invalidateSubData() if you don't
need buffer data anymore to avoid unnecessary memory operations performed by
OpenGL in order to preserve the data. If running on OpenGL ES or extension
You can use functions @ref invalidateData() and @ref invalidateSubData() if you
don't need buffer data anymore to avoid unnecessary memory operations performed
by OpenGL in order to preserve the data. If running on OpenGL ES or extension
@extension{ARB,invalidate_subdata} is not available, these functions do
nothing.
@ -131,7 +196,7 @@ class MAGNUM_EXPORT Buffer {
/**
* @brief %Buffer target
*
* @see bind(Target), unbind(Target)
* @see @ref bind(Target), @ref unbind(Target)
*/
enum class Target: GLenum {
/** Used for storing vertex attributes. */
@ -148,7 +213,7 @@ class MAGNUM_EXPORT Buffer {
#ifndef MAGNUM_TARGET_GLES2
/**
* Source for copies. See copy().
* Source for copies. See @ref copy().
* @requires_gl31 %Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES
* 2.0.
@ -156,7 +221,7 @@ class MAGNUM_EXPORT Buffer {
CopyRead = GL_COPY_READ_BUFFER,
/**
* Target for copies. See copy().
* Target for copies. See @ref copy().
* @requires_gl31 %Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES
* 2.0.
@ -236,96 +301,22 @@ class MAGNUM_EXPORT Buffer {
#endif
};
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief %Buffer usage
*
* @see setData(GLsizeiptr, const GLvoid*, Usage)
* @copybrief BufferUsage
* @deprecated Use @ref Magnum::BufferUsage "BufferUsage" instead.
*/
enum class Usage: GLenum {
/**
* Set once by the application and used infrequently for drawing.
*/
StreamDraw = GL_STREAM_DRAW,
#ifndef MAGNUM_TARGET_GLES2
/**
* Set once as output from an OpenGL command and used infequently
* for drawing.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StreamDraw"
* is available in OpenGL ES 2.0.
*/
StreamRead = GL_STREAM_READ,
/**
* Set once as output from an OpenGL command and used infrequently
* for drawing or copying to other buffers.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StreamDraw"
* is available in OpenGL ES 2.0.
*/
StreamCopy = GL_STREAM_COPY,
#endif
/**
* Set once by the application and used frequently for drawing.
*/
StaticDraw = GL_STATIC_DRAW,
#ifndef MAGNUM_TARGET_GLES2
/**
* Set once as output from an OpenGL command and queried many
* times by the application.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StaticDraw"
* is available in OpenGL ES 2.0.
*/
StaticRead = GL_STATIC_READ,
/**
* Set once as output from an OpenGL command and used frequently
* for drawing or copying to other buffers.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StaticDraw"
* is available in OpenGL ES 2.0.
*/
StaticCopy = GL_STATIC_COPY,
#endif
/**
* Updated frequently by the application and used frequently
* for drawing or copying to other images.
*/
DynamicDraw = GL_DYNAMIC_DRAW
#ifndef MAGNUM_TARGET_GLES2
,
/**
* Updated frequently as output from OpenGL command and queried
* many times from the application.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::DynamicDraw"
* is available in OpenGL ES 2.0.
*/
DynamicRead = GL_DYNAMIC_READ,
/**
* Updated frequently as output from OpenGL command and used
* frequently for drawing or copying to other images.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::DynamicDraw"
* is available in OpenGL ES 2.0.
*/
DynamicCopy = GL_DYNAMIC_COPY
#endif
};
typedef BufferUsage Usage;
#endif
#ifndef MAGNUM_TARGET_GLES3
/**
* @brief Memory mapping access
*
* @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features.
* @see map(MapAccess), mapSub()
* @see @ref map(MapAccess), @ref mapSub()
* @requires_es_extension %Extension @es_extension{OES,mapbuffer} or
* @es_extension{CHROMIUM,map_sub} in OpenGL ES 2.0, use
* @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* in OpenGL ES 3.0 instead.
* @es_extension{CHROMIUM,map_sub}
*/
enum class MapAccess: GLenum {
#ifndef MAGNUM_TARGET_GLES
@ -337,9 +328,7 @@ class MAGNUM_EXPORT Buffer {
ReadOnly = GL_READ_ONLY,
#endif
/**
* Map buffer for writing only.
*/
/** Map buffer for writing only. */
#ifdef MAGNUM_TARGET_GLES
WriteOnly = GL_WRITE_ONLY_OES
#else
@ -353,12 +342,11 @@ class MAGNUM_EXPORT Buffer {
ReadWrite = GL_READ_WRITE
#endif
};
#endif
/**
* @brief Memory mapping flag
*
* @see MapFlags, map(GLintptr, GLsizeiptr, MapFlags)
* @see @ref MapFlags, @ref map(GLintptr, GLsizeiptr, MapFlags)
* @requires_gl30 %Extension @extension{ARB,map_buffer_range}
* @requires_gles30 %Extension @es_extension{EXT,map_buffer_range}
*/
@ -378,9 +366,9 @@ class MAGNUM_EXPORT Buffer {
#endif
/**
* Previous contents of the entire buffer may be discarded. May
* not be used in combination with @ref MapFlag::Read.
* @see invalidateData()
* Previous contents of the entire buffer may be discarded. May not
* be used in combination with @ref MapFlag::Read.
* @see @ref invalidateData()
*/
#ifndef MAGNUM_TARGET_GLES2
InvalidateBuffer = GL_MAP_INVALIDATE_BUFFER_BIT,
@ -389,9 +377,9 @@ class MAGNUM_EXPORT Buffer {
#endif
/**
* Previous contents of mapped range may be discarded. May not
* be used in combination with @ref MapFlag::Read.
* @see invalidateSubData()
* Previous contents of mapped range may be discarded. May not be
* used in combination with @ref MapFlag::Read.
* @see @ref invalidateSubData()
*/
#ifndef MAGNUM_TARGET_GLES2
InvalidateRange = GL_MAP_INVALIDATE_RANGE_BIT,
@ -401,8 +389,8 @@ class MAGNUM_EXPORT Buffer {
/**
* Only one or more discrete subranges of the mapping will be
* modified. See flushMappedRange() for more information. May only
* be used in conjuction with @ref MapFlag::Write.
* modified. See @ref flushMappedRange() for more information. May
* only be used in conjuction with @ref MapFlag::Write.
*/
#ifndef MAGNUM_TARGET_GLES2
FlushExplicit = GL_MAP_FLUSH_EXPLICIT_BIT,
@ -424,7 +412,7 @@ class MAGNUM_EXPORT Buffer {
/**
* @brief Memory mapping flags
*
* @see map(GLintptr, GLsizeiptr, MapFlags)
* @see @ref map(GLintptr, GLsizeiptr, MapFlags)
* @requires_gl30 %Extension @extension{ARB,map_buffer_range}
* @requires_gles30 %Extension @es_extension{EXT,map_buffer_range}
*/
@ -516,7 +504,7 @@ class MAGNUM_EXPORT Buffer {
*
* If @extension{EXT,direct_state_access} is not available and the
* buffers aren't already bound somewhere, they are bound to
* `Target::CopyRead` and `Target::CopyWrite` before the copy is
* @ref Target::CopyRead and @ref Target::CopyWrite before the copy is
* performed.
* @see @fn_gl{BindBuffer} and @fn_gl{CopyBufferSubData} or
* @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access}
@ -530,10 +518,10 @@ class MAGNUM_EXPORT Buffer {
/**
* @brief Constructor
* @param targetHint Target hint, see setTargetHint() for more
* @param targetHint Target hint, see @ref setTargetHint() for more
* information
*
* Generates new OpenGL buffer.
* Creates new OpenGL buffer.
* @see @fn_gl{GenBuffers}
*/
explicit Buffer(Target targetHint = Target::Array);
@ -570,11 +558,11 @@ class MAGNUM_EXPORT Buffer {
*
* If @extension{EXT,direct_state_access} is not available, the buffer
* must be internally bound to some target before any operation. You
* can specify target which will always be used when binding the
* buffer internally, possibly saving some calls to @fn_gl{BindBuffer}.
* can specify target which will always be used when binding the buffer
* internally, possibly saving some calls to @fn_gl{BindBuffer}.
*
* Default target hint is `Target::Array`.
* @see setData(), setSubData()
* Default target hint is @ref Target::Array.
* @see @ref setData(), @ref setSubData()
* @todo Target::ElementArray cannot be used when no VAO is bound -
* http://www.opengl.org/wiki/Vertex_Specification#Index_buffers
* ... damned GL state
@ -615,7 +603,8 @@ class MAGNUM_EXPORT Buffer {
* Returns data of whole buffer. If @extension{EXT,direct_state_access}
* is not available and the buffer is not already bound somewhere, it
* is bound to hinted target before the operation.
* @see size(), subData(), setData(), @fn_gl{BindBuffer} and @fn_gl{GetBufferParameter} or
* @see @ref size(), @ref subData(), @ref setData(), @fn_gl{BindBuffer}
* and @fn_gl{GetBufferParameter} or
* @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access}
* with @def_gl{BUFFER_SIZE}, @fn_gl{GetBufferSubData} or
* @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}
@ -632,8 +621,9 @@ class MAGNUM_EXPORT Buffer {
* Returns data of given buffer portion. If @extension{EXT,direct_state_access}
* is not available and the buffer is not already bound somewhere, it
* is bound to hinted target before the operation.
* @see size(), data(), setSubData(), @fn_gl{BindBuffer} and @fn_gl{GetBufferSubData}
* or @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}
* @see @ref size(), @ref data(), @ref setSubData(), @fn_gl{BindBuffer}
* and @fn_gl{GetBufferSubData} or
* @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}
* @requires_gl %Buffer data queries are not available in OpenGL ES.
* Use @ref Magnum::Buffer::map() "map()" instead.
*/
@ -649,10 +639,10 @@ class MAGNUM_EXPORT Buffer {
* If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target
* before the operation.
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferData} or
* @fn_gl_extension{NamedBufferData,EXT,direct_state_access}
* @see @ref setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferData}
* or @fn_gl_extension{NamedBufferData,EXT,direct_state_access}
*/
Buffer& setData(Containers::ArrayReference<const void> data, Usage usage) {
Buffer& setData(Containers::ArrayReference<const void> data, BufferUsage usage) {
(this->*dataImplementation)(data.size(), data, usage);
return *this;
}
@ -660,29 +650,22 @@ class MAGNUM_EXPORT Buffer {
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Set buffer data
* @deprecated Use @ref Magnum::Buffer::setData(Containers::ArrayReference<const void>, Usage) "setData(Containers::ArrayReference<const void>, Usage)"
* @deprecated Use @ref Magnum::Buffer::setData(Containers::ArrayReference<const void>, BufferUsage) "setData(Containers::ArrayReference<const void>, BufferUsage)"
* instead.
*/
Buffer& setData(GLsizeiptr size, const GLvoid* data, Usage usage) {
Buffer& setData(GLsizeiptr size, const GLvoid* data, BufferUsage usage) {
return setData({data, std::size_t(size)}, usage);
}
#endif
/**
* @brief Set buffer data
* @param data Vector with data
* @param usage %Buffer usage
* @return Reference to self (for method chaining)
*
* @see setData(GLsizeiptr, const GLvoid*, Usage)
*/
template<class T> Buffer& setData(const std::vector<T>& data, Usage usage) {
/** @overload */
template<class T> Buffer& setData(const std::vector<T>& data, BufferUsage usage) {
setData({data.data(), data.size()}, usage);
return *this;
}
/** @overload */
template<std::size_t size, class T> Buffer& setData(const std::array<T, size>& data, Usage usage) {
template<std::size_t size, class T> Buffer& setData(const std::array<T, size>& data, BufferUsage usage) {
setData({data.data(), data.size()}, usage);
return *this;
}
@ -696,7 +679,7 @@ class MAGNUM_EXPORT Buffer {
* If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target
* before the operation.
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferSubData}
* @see @ref setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferSubData}
* or @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access}
*/
Buffer& setSubData(GLintptr offset, Containers::ArrayReference<const void> data) {
@ -715,14 +698,7 @@ class MAGNUM_EXPORT Buffer {
}
#endif
/**
* @brief Set buffer subdata
* @param offset Offset in the buffer
* @param data Vector with data
* @return Reference to self (for method chaining)
*
* @see setSubData(GLintptr, GLsizeiptr, const GLvoid*)
*/
/** @overload */
template<class T> Buffer& setSubData(GLintptr offset, const std::vector<T>& data) {
setSubData(offset, {data.data(), data.size()});
return *this;
@ -764,7 +740,6 @@ class MAGNUM_EXPORT Buffer {
}
#endif
#ifndef MAGNUM_TARGET_GLES3
/**
* @brief Map buffer to client memory
* @param access Access
@ -785,7 +760,6 @@ class MAGNUM_EXPORT Buffer {
void* map(MapAccess access) {
return (this->*mapImplementation)(access);
}
#endif
#if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT)
/**
@ -799,7 +773,8 @@ class MAGNUM_EXPORT Buffer {
* target before the operation.
* @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features.
* @see unmapSub(), setTargetHint(), @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}
* @see @ref unmapSub(), @ref setTargetHint(),
* @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead.
@ -812,8 +787,8 @@ class MAGNUM_EXPORT Buffer {
* @brief Map buffer to client memory
* @param offset Offset into the buffer
* @param length Length of the mapped memory
* @param flags Flags. At least @ref MapFlag::Read or @ref MapFlag::Write
* must be specified.
* @param flags Flags. At least @ref MapFlag::Read or
* @ref MapFlag::Write must be specified.
* @return Pointer to buffer data
*
* If @extension{EXT,direct_state_access} is not available and the
@ -836,13 +811,13 @@ class MAGNUM_EXPORT Buffer {
* @return Reference to self (for method chaining)
*
* Flushes specified subsection of mapped range. Use only if you called
* map() with @ref MapFlag::FlushExplicit flag. See
* @ref map() with @ref MapFlag::FlushExplicit flag. See
* @ref Buffer-data-mapping "class documentation" for usage example.
*
* If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target
* before the operation.
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{FlushMappedBufferRange}
* @see @ref setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{FlushMappedBufferRange}
* or @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access}
* @requires_gl30 %Extension @extension{ARB,map_buffer_range}
* @requires_gles30 %Extension @es_extension{EXT,map_buffer_range}
@ -858,7 +833,7 @@ class MAGNUM_EXPORT Buffer {
* the buffer was mapped (e.g. after screen was resized), `true`
* otherwise.
*
* Unmaps buffer previously mapped with map(), invalidating the
* Unmaps buffer previously mapped with @ref map(), invalidating the
* pointer returned by these functions. If @extension{EXT,direct_state_access}
* is not available and the buffer is not already bound somewhere, it
* is bound to hinted target before the operation.
@ -874,7 +849,7 @@ class MAGNUM_EXPORT Buffer {
/**
* @brief Unmap portion of buffer
*
* Unmaps portion of buffer previously mapped with mapSub(),
* Unmaps portion of buffer previously mapped with @ref mapSub(),
* invalidating the pointer returned by the function.
* @see @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
@ -914,10 +889,10 @@ class MAGNUM_EXPORT Buffer {
static GetSubDataImplementation getSubDataImplementation;
#endif
typedef void(Buffer::*DataImplementation)(GLsizeiptr, const GLvoid*, Usage);
void MAGNUM_LOCAL dataImplementationDefault(GLsizeiptr size, const GLvoid* data, Usage usage);
typedef void(Buffer::*DataImplementation)(GLsizeiptr, const GLvoid*, BufferUsage);
void MAGNUM_LOCAL dataImplementationDefault(GLsizeiptr size, const GLvoid* data, BufferUsage usage);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL dataImplementationDSA(GLsizeiptr size, const GLvoid* data, Usage usage);
void MAGNUM_LOCAL dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUsage usage);
#endif
static DataImplementation dataImplementation;
@ -942,14 +917,12 @@ class MAGNUM_EXPORT Buffer {
#endif
static InvalidateSubImplementation invalidateSubImplementation;
#ifndef MAGNUM_TARGET_GLES3
typedef void*(Buffer::*MapImplementation)(MapAccess);
void MAGNUM_LOCAL * mapImplementationDefault(MapAccess access);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL * mapImplementationDSA(MapAccess access);
#endif
static MapImplementation mapImplementation;
#endif
typedef void*(Buffer::*MapRangeImplementation)(GLintptr, GLsizeiptr, MapFlags);
void MAGNUM_LOCAL * mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access);

2
src/BufferImage.cpp

@ -27,7 +27,7 @@
namespace Magnum {
#ifndef MAGNUM_TARGET_GLES2
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, Buffer::Usage usage) {
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, BufferUsage usage) {
_format = format;
_type = type;
_size = size;

2
src/BufferImage.h

@ -81,7 +81,7 @@ template<UnsignedInt dimensions> class MAGNUM_EXPORT BufferImage: public Abstrac
*
* @see Buffer::setData()
*/
void setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, Buffer::Usage usage);
void setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, BufferUsage usage);
private:
Math::Vector<Dimensions, Int> _size;

37
src/BufferTexture.h

@ -26,7 +26,7 @@
#ifndef MAGNUM_TARGET_GLES
/** @file
* @brief Class Magnum::BufferTexture, enum Magnum::BufferTextureFormat
* @brief Class @ref Magnum::BufferTexture, enum @ref Magnum::BufferTextureFormat
*/
#endif
@ -38,7 +38,7 @@ namespace Magnum {
/**
@brief Internal buffer texture format
@see BufferTexture
@see @ref BufferTexture
*/
enum class BufferTextureFormat: GLenum {
/** Red component, normalized unsigned byte. */
@ -153,14 +153,14 @@ enum class BufferTextureFormat: GLenum {
/**
@brief %Buffer texture
This texture is, unlike classic textures such as Texture or CubeMapTexture,
used as simple data source, without any unnecessary interpolation and
wrapping methods.
This texture is, unlike classic textures such as @ref Texture or
@ref CubeMapTexture, used as simple data source, without any unnecessary
interpolation and wrapping methods.
@section BufferTexture-usage Usage
%Texture data are stored in buffer and after binding the buffer to the texture
using setBuffer(), you can fill the buffer at any time using data setting
using @ref setBuffer(), you can fill the buffer at any time using data setting
functions in Buffer itself.
Note that the buffer is not managed (e.g. deleted on destruction) by the
@ -177,23 +177,24 @@ texture.setBuffer(BufferTextureFormat::RGB32F, buffer);
constexpr static Vector3 data[] = {
// ...
};
buffer.setData(data, Buffer::Usage::StaticDraw);
buffer.setData(data, BufferUsage::StaticDraw);
@endcode
The texture is bound to layer specified by shader via bind(). In shader, the
texture is used via `samplerBuffer`, `isamplerBuffer` or `usamplerBuffer`.
The texture is bound to layer specified by shader via @ref bind(). In shader,
the texture is used via `samplerBuffer`, `isamplerBuffer` or `usamplerBuffer`.
Unlike in classic textures, coordinates for buffer textures are integer
coordinates passed to `texelFetch()`. See also AbstractShaderProgram
coordinates passed to `texelFetch()`. See also @ref AbstractShaderProgram
documentation for more information.
@section BufferTexture-performance-optimization Performance optimizations
If extension @extension{EXT,direct_state_access} is available, setBuffer()
If extension @extension{EXT,direct_state_access} is available, @ref setBuffer()
functions use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and
@fn_gl{BindTexture}. See @ref AbstractTexture-performance-optimization
"relevant section in AbstractTexture documentation" and respective function
documentation for more information.
@fn_gl{BindTexture}. See
@ref AbstractTexture-performance-optimization "relevant section in AbstractTexture documentation"
and respective function documentation for more information.
@see Texture, CubeMapTexture, CubeMapTextureArray
@see @ref Texture, @ref CubeMapTexture, @ref CubeMapTextureArray
@requires_gl31 %Extension @extension{ARB,texture_buffer_object}
@requires_gl Texture buffers are not available in OpenGL ES.
*/
@ -217,8 +218,8 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture {
* @param buffer %Buffer with data
*
* Binds given buffer to this texture. The buffer itself can be then
* filled with data of proper format at any time using Buffer own data
* setting functions.
* filled with data of proper format at any time using @ref Buffer "Buffer"'s
* own data setting functions.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer}
* or @fn_gl_extension{TextureBuffer,EXT,direct_state_access}
*/
@ -234,7 +235,7 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture {
* @param size Data size
*
* Binds range of given buffer to this texture. The buffer itself can
* be then filled with data of proper format at any time using Buffer
* be then filled with data of proper format at any time using @ref Buffer "Buffer"'s
* own data setting functions.
* @requires_gl43 %Extension @extension{ARB,texture_buffer_range}
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBufferRange}

7
src/CMakeLists.txt

@ -166,8 +166,7 @@ endif()
# Files shared between main library and math unit test library
set(MagnumMath_SRCS
Math/Functions.cpp
Math/instantiation.cpp
Math/Geometry/instantiation.cpp)
Math/instantiation.cpp)
# Set shared library flags for the objects, as they will be part of shared lib
# TODO: fix when CMake sets target_EXPORTS for OBJECT targets as well
@ -185,8 +184,8 @@ if(BUILD_STATIC_PIC)
set_target_properties(Magnum PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
endif()
set(Magnum_LIBS
${CORRADE_UTILITY_LIBRARY}
${CORRADE_PLUGINMANAGER_LIBRARY})
${CORRADE_UTILITY_LIBRARIES}
${CORRADE_PLUGINMANAGER_LIBRARIES})
if(NOT TARGET_GLES OR TARGET_DESKTOP_GLES)
set(Magnum_LIBS ${Magnum_LIBS} ${OPENGL_gl_LIBRARY})
elseif(TARGET_GLES2)

171
src/Color.h

@ -123,11 +123,11 @@ template<class T> inline typename BasicColor3<T>::HSV toHSV(typename std::enable
return toHSV<typename BasicColor3<T>::FloatingPointType>(Math::normalize<BasicColor3<typename BasicColor3<T>::FloatingPointType>>(color));
}
/* Default alpha value */
template<class T> inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type defaultAlpha() {
/* Value for full channel (1.0f for floats, 255 for unsigned byte) */
template<class T> inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type fullChannel() {
return T(1);
}
template<class T> inline constexpr typename std::enable_if<std::is_integral<T>::value, T>::type defaultAlpha() {
template<class T> inline constexpr typename std::enable_if<std::is_integral<T>::value, T>::type fullChannel() {
return std::numeric_limits<T>::max();
}
@ -136,9 +136,16 @@ template<class T> inline constexpr typename std::enable_if<std::is_integral<T>::
/**
@brief Three-component (RGB) color
The class can store both floating-point (normalized) and integral
(denormalized) representation of color. You can convert between these two
representations using fromNormalized() and fromDenormalized().
The class can store either floating-point (normalized) or integral
(denormalized) representation of color. Note that constructor conversion
between different types (like in @ref Math::Vector "Vector" classes) doesn't do
any (de)normalization, you should use @ref Math::normalize() and
@ref Math::denormalize() instead, for example:
@code
typedef BasicColor3<UnsignedByte> Color3ub;
Color3 a(1.0f, 0.5f, 0.75f);
auto b = Math::denormalize<Color3ub>(a); // b == {255, 127, 191}
@endcode
Conversion from and to HSV is done always using floating-point types, so hue
is always in range in range @f$ [0.0, 360.0] @f$, saturation and value in
@ -150,6 +157,72 @@ range @f$ [0.0, 1.0] @f$.
impossible to explicitly instantiate */
template<class T> class BasicColor3: public Math::Vector3<T> {
public:
/**
* @brief Red color
*
* Convenience alternative to e.g. `%Color3(red, 0.0f, 0.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::xAxis().
* @see @ref green(), @ref blue(), @ref cyan()
*/
constexpr static BasicColor3<T> red(T red = Implementation::fullChannel<T>()) {
return Math::Vector3<T>::xAxis(red);
}
/**
* @brief Green color
*
* Convenience alternative to e.g. `%Color3(0.0f, green, 0.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::yAxis().
* @see @ref red(), @ref blue(), @ref magenta()
*/
constexpr static BasicColor3<T> green(T green = Implementation::fullChannel<T>()) {
return Math::Vector3<T>::yAxis(green);
}
/**
* @brief Blue color
*
* Convenience alternative to e.g. `%Color3(0.0f, 0.0f, blue)`. With
* floating-point underlying type equivalent to @ref Vector3::zAxis().
* @see @ref red(), @ref green(), @ref yellow()
*/
constexpr static BasicColor3<T> blue(T blue = Implementation::fullChannel<T>()) {
return Math::Vector3<T>::zAxis(blue);
}
/**
* @brief Cyan color
*
* Convenience alternative to e.g. `%Color3(red, 1.0f, 1.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::xScale().
* @see @ref magenta(), @ref yellow(), @ref red()
*/
constexpr static BasicColor3<T> cyan(T red = T(0)) {
return {red, Implementation::fullChannel<T>(), Implementation::fullChannel<T>()};
}
/**
* @brief Magenta color
*
* Convenience alternative to e.g. `%Color3(0.0f, green, 0.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::yScale().
* @see @ref cyan(), @ref yellow(), @ref green()
*/
constexpr static BasicColor3<T> magenta(T green = T(0)) {
return {Implementation::fullChannel<T>(), green, Implementation::fullChannel<T>()};
}
/**
* @brief Yellow color
*
* Convenience alternative to `%Color3(0.0f, 0.0f, yellow)`. With
* floating-point underlying type equivalent to @ref Vector3::zScale().
* @see @ref cyan(), @ref magenta(), @ref red()
*/
constexpr static BasicColor3<T> yellow(T blue = T(0)) {
return {Implementation::fullChannel<T>(), Implementation::fullChannel<T>(), blue};
}
/** @brief Corresponding floating-point type for HSV computation */
typedef typename Math::TypeTraits<T>::FloatingPointType FloatingPointType;
@ -196,7 +269,13 @@ template<class T> class BasicColor3: public Math::Vector3<T> {
*/
constexpr /*implicit*/ BasicColor3(T r, T g, T b): Math::Vector3<T>(r, g, b) {}
/** @copydoc Math::Vector::Vector(const Vector<size, U>&) */
/**
* @copydoc Math::Vector::Vector(const Vector<size, U>&)
*
* @attention This function doesn't do any (de)normalization, use
* @ref Math::normalize() and @ref Math::denormalize() instead.
* See class documentation for more information.
*/
template<class U> constexpr explicit BasicColor3(const Math::Vector<3, U>& other): Math::Vector3<T>(other) {}
/** @brief Copy constructor */
@ -276,12 +355,72 @@ class BasicColor4: public Math::Vector4<T> {
/** @copydoc BasicColor3::HSV */
typedef typename BasicColor3<T>::HSV HSV;
/**
* @brief Red color
*
* Convenience alternative to e.g. `%Color4(red, 0.0f, 0.0f, alpha)`.
* @see @ref green(), @ref blue(), @ref cyan()
*/
constexpr static BasicColor4<T> red(T red = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) {
return {red, T(0), T(0), alpha};
}
/**
* @brief Green color
*
* Convenience alternative to e.g. `%Color4(0.0f, green, 0.0f, alpha)`.
* @see @ref red(), @ref blue(), @ref magenta()
*/
constexpr static BasicColor4<T> green(T green = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) {
return {T(0), green, T(0), alpha};
}
/**
* @brief Blue color
*
* Convenience alternative to e.g. `%Color4(0.0f, 0.0f, blue, alpha)`.
* @see @ref red(), @ref green(), @ref yellow()
*/
constexpr static BasicColor4<T> blue(T blue = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) {
return {T(0), T(0), blue, alpha};
}
/**
* @brief Cyan color
*
* Convenience alternative to e.g. `%Color4(red, 1.0f, 1.0f, alpha)`.
* @see @ref magenta(), @ref yellow(), @ref red()
*/
constexpr static BasicColor4<T> cyan(T red = T(0), T alpha = Implementation::fullChannel<T>()) {
return {red, Implementation::fullChannel<T>(), Implementation::fullChannel<T>(), alpha};
}
/**
* @brief Magenta color
*
* Convenience alternative to e.g. `%Color4(1.0f, green, 1.0f, alpha)`.
* @see @ref cyan(), @ref yellow(), @ref green()
*/
constexpr static BasicColor4<T> magenta(T green = T(0), T alpha = Implementation::fullChannel<T>()) {
return {Implementation::fullChannel<T>(), green, Implementation::fullChannel<T>(), alpha};
}
/**
* @brief Yellow color
*
* Convenience alternative to e.g. `%Color4(1.0f, 1.0f, blue, alpha)`.
* @see @ref cyan(), @ref magenta(), @ref red()
*/
constexpr static BasicColor4<T> yellow(T blue = T(0), T alpha = Implementation::fullChannel<T>()) {
return {Implementation::fullChannel<T>(), Implementation::fullChannel<T>(), blue, alpha};
}
/**
* @copydoc BasicColor3::fromHSV()
* @param a Alpha value, defaults to 1.0 for floating-point types
* and maximum positive value for integral types.
*/
constexpr static BasicColor4<T> fromHSV(HSV hsv, T a = Implementation::defaultAlpha<T>()) {
constexpr static BasicColor4<T> fromHSV(HSV hsv, T a = Implementation::fullChannel<T>()) {
return BasicColor4<T>(Implementation::fromHSV<T>(hsv), a);
}
/** @overload */
@ -295,14 +434,14 @@ class BasicColor4: public Math::Vector4<T> {
* RGB components are set to zero, A component is set to 1.0 for
* floating-point types and maximum positive value for integral types.
*/
constexpr /*implicit*/ BasicColor4(): Math::Vector4<T>(T(0), T(0), T(0), Implementation::defaultAlpha<T>()) {}
constexpr /*implicit*/ BasicColor4(): Math::Vector4<T>(T(0), T(0), T(0), Implementation::fullChannel<T>()) {}
/**
* @copydoc BasicColor3::BasicColor3(T)
* @param alpha Alpha value, defaults to 1.0 for floating-point types
* and maximum positive value for integral types.
*/
constexpr explicit BasicColor4(T rgb, T alpha = Implementation::defaultAlpha<T>()): Math::Vector4<T>(rgb, rgb, rgb, alpha) {}
constexpr explicit BasicColor4(T rgb, T alpha = Implementation::fullChannel<T>()): Math::Vector4<T>(rgb, rgb, rgb, alpha) {}
/**
* @brief Constructor
@ -312,7 +451,7 @@ class BasicColor4: public Math::Vector4<T> {
* @param a A value, defaults to 1.0 for floating-point types and
* maximum positive value for integral types.
*/
constexpr /*implicit*/ BasicColor4(T r, T g, T b, T a = Implementation::defaultAlpha<T>()): Math::Vector4<T>(r, g, b, a) {}
constexpr /*implicit*/ BasicColor4(T r, T g, T b, T a = Implementation::fullChannel<T>()): Math::Vector4<T>(r, g, b, a) {}
/**
* @brief Constructor
@ -321,9 +460,15 @@ class BasicColor4: public Math::Vector4<T> {
*/
/* Not marked as explicit, because conversion from BasicColor3 to BasicColor4
is fairly common, nearly always with A set to 1 */
constexpr /*implicit*/ BasicColor4(const Math::Vector3<T>& rgb, T a = Implementation::defaultAlpha<T>()): Math::Vector4<T>(rgb[0], rgb[1], rgb[2], a) {}
constexpr /*implicit*/ BasicColor4(const Math::Vector3<T>& rgb, T a = Implementation::fullChannel<T>()): Math::Vector4<T>(rgb[0], rgb[1], rgb[2], a) {}
/** @copydoc Math::Vector::Vector(const Vector<size, U>&) */
/**
* @copydoc Math::Vector::Vector(const Vector<size, U>&)
*
* @attention This function doesn't do any (de)normalization, use
* @ref Math::normalize() and @ref Math::denormalize() instead.
* See @ref BasicColor3 class documentation for more information.
*/
template<class U> constexpr explicit BasicColor4(const Math::Vector<4, U>& other): Math::Vector4<T>(other) {}
/** @brief Copy constructor */

8
src/ColorFormat.cpp

@ -49,9 +49,7 @@ Debug operator<<(Debug debug, const ColorFormat value) {
#ifndef MAGNUM_TARGET_GLES
_c(BGR)
#endif
#ifndef MAGNUM_TARGET_GLES3
_c(BGRA)
#endif
#ifndef MAGNUM_TARGET_GLES2
_c(RedInteger)
#ifndef MAGNUM_TARGET_GLES
@ -67,9 +65,7 @@ Debug operator<<(Debug debug, const ColorFormat value) {
#endif
#endif
_c(DepthComponent)
#ifndef MAGNUM_TARGET_GLES3
_c(StencilIndex)
#endif
_c(DepthStencil)
#undef _c
}
@ -103,13 +99,9 @@ Debug operator<<(Debug debug, const ColorType value) {
_c(UnsignedShort565Rev)
#endif
_c(UnsignedShort4444)
#ifndef MAGNUM_TARGET_GLES3
_c(UnsignedShort4444Rev)
#endif
_c(UnsignedShort5551)
#ifndef MAGNUM_TARGET_GLES3
_c(UnsignedShort1555Rev)
#endif
#ifndef MAGNUM_TARGET_GLES
_c(UnsignedInt8888)
_c(UnsignedInt8888Rev)

8
src/ColorFormat.h

@ -123,7 +123,6 @@ enum class ColorFormat: GLenum {
BGR = GL_BGR,
#endif
#ifndef MAGNUM_TARGET_GLES3
/**
* Floating-point BGRA.
* @requires_es_extension %Extension @es_extension{EXT,read_format_bgra}
@ -135,7 +134,6 @@ enum class ColorFormat: GLenum {
#else
BGRA = GL_BGRA_EXT,
#endif
#endif
#ifndef MAGNUM_TARGET_GLES2
/**
@ -221,7 +219,6 @@ enum class ColorFormat: GLenum {
*/
DepthComponent = GL_DEPTH_COMPONENT,
#ifndef MAGNUM_TARGET_GLES3
/**
* Stencil index.
* @requires_gl44 %Extension @extension{ARB,texture_stencil8} for texture
@ -235,7 +232,6 @@ enum class ColorFormat: GLenum {
#else
StencilIndex = 0x1901,
#endif
#endif
/**
* Depth and stencil.
@ -361,7 +357,6 @@ enum class ColorType: GLenum {
*/
UnsignedShort4444 = GL_UNSIGNED_SHORT_4_4_4_4,
#ifndef MAGNUM_TARGET_GLES3
/**
* ABGR, unsigned short, each component 4bit.
* @requires_es_extension For framebuffer reading only, extension
@ -372,7 +367,6 @@ enum class ColorType: GLenum {
#else
UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT,
#endif
#endif
/**
* RGBA, unsigned short, each RGB component 5bit, alpha component 1bit.
@ -380,7 +374,6 @@ enum class ColorType: GLenum {
*/
UnsignedShort5551 = GL_UNSIGNED_SHORT_5_5_5_1,
#ifndef MAGNUM_TARGET_GLES3
/**
* ABGR, unsigned short, each RGB component 5bit, alpha component 1bit.
* @requires_es_extension For framebuffer reading only, extension
@ -391,7 +384,6 @@ enum class ColorType: GLenum {
#else
UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT,
#endif
#endif
#ifndef MAGNUM_TARGET_GLES
/**

84
src/Context.h

@ -25,9 +25,10 @@
*/
/** @file /Context.h
* @brief Enum Magnum::Version, class Magnum::Context, Magnum::Extension, macro MAGNUM_ASSERT_VERSION_SUPPORTED(), MAGNUM_ASSERT_EXTENSION_SUPPORTED()
* @brief Class @ref Magnum::Context, @ref Magnum::Extension, enum @ref Magnum::Version, macro @ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED()
*/
#include <cstdlib>
#include <bitset>
#include <vector>
#include <Containers/EnumSet.h>
@ -47,7 +48,7 @@ namespace Implementation {
/**
@brief OpenGL version
@see Context, MAGNUM_ASSERT_VERSION_SUPPORTED()
@see @ref Context, @ref MAGNUM_ASSERT_VERSION_SUPPORTED()
*/
enum class Version: Int {
None = 0xFFFF, /**< @brief Unspecified */
@ -109,8 +110,8 @@ Encapsulates runtime information about OpenGL extension, such as name string,
minimal required OpenGL version and version in which the extension was adopted
to core.
See also Extensions namespace, which contain compile-time information about
OpenGL extensions.
See also @ref Extensions namespace, which contain compile-time information
about OpenGL extensions.
*/
class MAGNUM_EXPORT Extension {
friend class Context;
@ -140,12 +141,13 @@ class MAGNUM_EXPORT Extension {
};
/**
@brief OpenGL context
@brief Magnum context
Provides access to version and extension information. Instance available
through Context::current() is automatically created during construction of
*Application classes in Platform namespace so you can safely assume that the
instance is available during whole lifetime of *Application object.
through @ref Context::current() is automatically created during construction of
*Application classes in @ref Platform namespace. You can safely assume that the
instance is available during whole lifetime of *Application object. See
@ref platform documentation for more information about engine setup.
@todo @extension{ATI,meminfo}, @extension{NVX,gpu_memory_info}, GPU temperature?
(here or where?)
*/
@ -159,10 +161,9 @@ class MAGNUM_EXPORT Context {
/**
* @brief Context flag
*
* @see Flags, flags()
* @see @ref Flags, @ref flags()
*/
enum class Flag: GLint {
#ifndef MAGNUM_TARGET_GLES3
/**
* Debug context
* @requires_gl43 %Extension @es_extension{KHR,debug}
@ -173,12 +174,11 @@ class MAGNUM_EXPORT Context {
#else
Debug = GL_CONTEXT_FLAG_DEBUG_BIT_KHR,
#endif
#endif
#ifndef MAGNUM_TARGET_GLES
/**
* Context with robust buffer access
* @requires_extension %Extension @extension{EXT,robustness}
* @requires_extension %Extension @extension{ARB,robustness}
* @requires_es_extension %Extension @es_extension{EXT,robustness}
* @todo In ES available under glGetIntegerv(CONTEXT_ROBUST_ACCESS_EXT),
* how to make it compatible?
@ -190,15 +190,15 @@ class MAGNUM_EXPORT Context {
/**
* @brief Context flags
*
* @see flags()
* @see @ref flags()
*/
typedef Containers::EnumSet<Flag, GLint> Flags;
/**
* @brief Constructor
*
* Constructed automatically, see class documentation for more
* information.
* Does initial setup, detects available features and enables them
* throughout the engine.
* @see @fn_gl{Get} with @def_gl{MAJOR_VERSION}, @def_gl{MINOR_VERSION},
* @def_gl{CONTEXT_FLAGS}, @def_gl{NUM_EXTENSIONS},
* @fn_gl{GetString} with @def_gl{EXTENSIONS}
@ -213,24 +213,24 @@ class MAGNUM_EXPORT Context {
/**
* @brief OpenGL version
*
* @see majorVersion(), minorVersion(), versionString(),
* shadingLanguageVersionString()
* @see @ref majorVersion(), @ref minorVersion(), @ref versionString(),
* @ref shadingLanguageVersionString()
*/
Version version() const { return _version; }
/**
* @brief Major OpenGL version (e.g. `4`)
*
* @see minorVersion(), version(), versionString(),
* shadingLanguageVersionString()
* @see @ref minorVersion(), @ref version(), @ref versionString(),
* @ref shadingLanguageVersionString()
*/
Int majorVersion() const { return _majorVersion; }
/**
* @brief Minor OpenGL version (e.g. `3`)
*
* @see majorVersion(), version(), versionString(),
* shadingLanguageVersionString()
* @see @ref majorVersion(), @ref version(), @ref versionString(),
* @ref shadingLanguageVersionString()
*/
Int minorVersion() const { return _minorVersion; }
@ -239,7 +239,7 @@ class MAGNUM_EXPORT Context {
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls.
* @see rendererString(), @fn_gl{GetString} with @def_gl{VENDOR}
* @see @ref rendererString(), @fn_gl{GetString} with @def_gl{VENDOR}
*/
std::string vendorString() const {
return reinterpret_cast<const char*>(glGetString(GL_VENDOR));
@ -250,7 +250,7 @@ class MAGNUM_EXPORT Context {
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls.
* @see vendorString(), @fn_gl{GetString} with @def_gl{RENDERER}
* @see @ref vendorString(), @fn_gl{GetString} with @def_gl{RENDERER}
*/
std::string rendererString() const {
return reinterpret_cast<const char*>(glGetString(GL_RENDERER));
@ -261,8 +261,8 @@ class MAGNUM_EXPORT Context {
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls.
* @see shadingLanguageVersionString(), version(), @fn_gl{GetString}
* with @def_gl{VERSION}
* @see @ref shadingLanguageVersionString(), @ref version(),
* @fn_gl{GetString} with @def_gl{VERSION}
*/
std::string versionString() const {
return reinterpret_cast<const char*>(glGetString(GL_VERSION));
@ -273,7 +273,7 @@ class MAGNUM_EXPORT Context {
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls.
* @see versionString(), version(), @fn_gl{GetString} with
* @see @ref versionString(), @ref version(), @fn_gl{GetString} with
* @def_gl{SHADING_LANGUAGE_VERSION}
*/
std::string shadingLanguageVersionString() const {
@ -285,8 +285,9 @@ class MAGNUM_EXPORT Context {
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls.
* @see versionString(), version(), @fn_gl{Get} with @def_gl{NUM_SHADING_LANGUAGE_VERSIONS},
* @fn_gl{GetString} with @def_gl{SHADING_LANGUAGE_VERSION}
* @see @ref versionString(), @ref version(), @fn_gl{Get} with
* @def_gl{NUM_SHADING_LANGUAGE_VERSIONS}, @fn_gl{GetString} with
* @def_gl{SHADING_LANGUAGE_VERSION}
*/
std::vector<std::string> shadingLanguageVersionStrings() const;
@ -298,8 +299,7 @@ class MAGNUM_EXPORT Context {
*
* The list contains only extensions from OpenGL versions newer than
* the current.
*
* @see isExtensionSupported(), Extension::extensions()
* @see @ref isExtensionSupported(), @ref Extension::extensions()
*/
const std::vector<Extension>& supportedExtensions() const {
return _supportedExtensions;
@ -308,7 +308,7 @@ class MAGNUM_EXPORT Context {
/**
* @brief Whether given OpenGL version is supported
*
* @see supportedVersion(), MAGNUM_ASSERT_VERSION_SUPPORTED()
* @see @ref supportedVersion(), @ref MAGNUM_ASSERT_VERSION_SUPPORTED()
*/
bool isVersionSupported(Version version) const {
return _version >= version;
@ -318,7 +318,7 @@ class MAGNUM_EXPORT Context {
* @brief Get supported OpenGL version
*
* Returns first supported OpenGL version from passed list. Convenient
* equivalent to subsequent isVersionSupported() calls, e.g.:
* equivalent to subsequent @ref isVersionSupported() calls, e.g.:
* @code
* Version v = isVersionSupported(Version::GL330) ? Version::GL330 : Version::GL210;
* Version v = supportedVersion({Version::GL330, Version::GL210});
@ -334,8 +334,8 @@ class MAGNUM_EXPORT Context {
/**
* @brief Whether given extension is supported
*
* %Extensions usable with this function are listed in Extensions
* namespace in header Extensions.h. Example usage:
* %Extensions usable with this function are listed in @ref Extensions
* namespace in header @ref Extensions.h. Example usage:
* @code
* if(Context::current()->isExtensionSupported<Extensions::GL::ARB::tessellation_shader>()) {
* // draw fancy detailed model
@ -344,8 +344,8 @@ class MAGNUM_EXPORT Context {
* }
* @endcode
*
* @see isExtensionSupported(const Extension&) const,
* MAGNUM_ASSERT_EXTENSION_SUPPORTED()
* @see @ref isExtensionSupported(const Extension&) const,
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED()
*/
template<class T> bool isExtensionSupported() const {
return isVersionSupported(T::coreVersion()) || (isVersionSupported(T::requiredVersion()) && extensionStatus[T::Index]);
@ -377,8 +377,8 @@ class MAGNUM_EXPORT Context {
* hardware, but for general usage prefer isExtensionSupported() const,
* as it does most operations in compile time.
*
* @see supportedExtensions(), Extension::extensions(),
* MAGNUM_ASSERT_EXTENSION_SUPPORTED()
* @see @ref supportedExtensions(), @ref Extension::extensions(),
* @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED()
*/
bool isExtensionSupported(const Extension& extension) const {
return isVersionSupported(extension._coreVersion) || (isVersionSupported(extension._requiredVersion) && extensionStatus[extension._index]);
@ -416,8 +416,8 @@ MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL330);
@endcode
@see @ref Magnum::Context::isVersionSupported() "Context::isVersionSupported()",
MAGNUM_ASSERT_EXTENSION_SUPPORTED(), CORRADE_ASSERT(),
CORRADE_INTERNAL_ASSERT()
@ref MAGNUM_ASSERT_EXTENSION_SUPPORTED(), @ref CORRADE_ASSERT(),
@ref CORRADE_INTERNAL_ASSERT()
*/
#ifdef CORRADE_NO_ASSERT
#define MAGNUM_ASSERT_VERSION_SUPPORTED(version) do {} while(0)
@ -446,8 +446,8 @@ MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4);
@endcode
@see @ref Magnum::Context::isExtensionSupported() "Context::isExtensionSupported()",
MAGNUM_ASSERT_VERSION_SUPPORTED(), CORRADE_ASSERT(),
CORRADE_INTERNAL_ASSERT()
@ref MAGNUM_ASSERT_VERSION_SUPPORTED(), @ref CORRADE_ASSERT(),
@ref CORRADE_INTERNAL_ASSERT()
*/
#ifdef CORRADE_NO_ASSERT
#define MAGNUM_ASSERT_EXTENSION_SUPPORTED(extension) do {} while(0)

40
src/CubeMapTexture.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::CubeMapTexture
* @brief Class @ref Magnum::CubeMapTexture
*/
#include "AbstractTexture.h"
@ -49,12 +49,12 @@ turned upside down (+Y is top):
@section CubeMapTexture-usage Basic usage
See Texture documentation for introduction.
See @ref Texture documentation for introduction.
Common usage is to fully configure all texture parameters and then set the
data from e.g. set of Image objects:
@code
Image2D positiveX({256, 256}, ColorFormat::RGBA, ColorType::UnsignedByte, dataPositiveX);
Image2D positiveX(ColorFormat::RGBA, ColorType::UnsignedByte, {256, 256}, data);
// ...
CubeMapTexture texture;
@ -66,11 +66,11 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
// ...
@endcode
The texture is bound to layer specified by shader via bind(). In shader, the
texture is used via `samplerCube`, `samplerCubeShadow`, `isamplerCube` or
The texture is bound to layer specified by shader via @ref bind(). In shader,
the texture is used via `samplerCube`, `samplerCubeShadow`, `isamplerCube` or
`usamplerCube`. Unlike in classic textures, coordinates for cube map textures
is signed three-part vector from the center of the cube, which intersects one
of the six sides of the cube map. See also AbstractShaderProgram for more
of the six sides of the cube map. See also @ref AbstractShaderProgram for more
information about usage in shaders.
@see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTextureArray,
@ -99,7 +99,7 @@ class CubeMapTexture: public AbstractTexture {
/**
* @brief Set wrapping
*
* See Texture::setWrapping() for more information.
* See @ref Texture::setWrapping() for more information.
*/
CubeMapTexture& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping);
@ -112,18 +112,18 @@ class CubeMapTexture: public AbstractTexture {
* @param coordinate Coordinate
* @param level Mip level
*
* See Texture::imageSize() for more information.
* See @ref Texture::imageSize() for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
Vector2i imageSize(Coordinate coordinate, Int level) {
return DataHelper<2>::imageSize(this, static_cast<GLenum>(coordinate), level);
return DataHelper<2>::imageSize(this, GLenum(coordinate), level);
}
#endif
/**
* @brief Set storage
*
* See Texture::setStorage() for more information.
* See @ref Texture::setStorage() for more information.
*/
CubeMapTexture& setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) {
DataHelper<2>::setStorage(this, _target, levels, internalFormat, size);
@ -137,7 +137,7 @@ class CubeMapTexture: public AbstractTexture {
* @param level Mip level
* @param image %Image where to put the data
*
* See Texture::image(Int, Image&) for more information.
* See @ref Texture::image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, Image2D& image) {
@ -151,11 +151,11 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Buffer image where to put the data
* @param usage %Buffer usage
*
* See Texture::image(Int, BufferImage&, Buffer::Usage) for more
* See @ref Texture::image(Int, BufferImage&, BufferUsage) for more
* information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, BufferImage2D& image, Buffer::Usage usage) {
void image(Coordinate coordinate, Int level, BufferImage2D& image, BufferUsage usage) {
AbstractTexture::image<2>(GLenum(coordinate), level, image, usage);
}
#endif
@ -168,17 +168,17 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Image
* @return Reference to self (for method chaining)
*
* See Texture::setImage() for more information.
* See @ref Texture::setImage() for more information.
*/
CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) {
DataHelper<2>::setImage(this, static_cast<GLenum>(coordinate), level, internalFormat, image);
DataHelper<2>::setImage(this, GLenum(coordinate), level, internalFormat, image);
return *this;
}
#ifndef MAGNUM_TARGET_GLES2
/** @overload */
CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D& image) {
DataHelper<2>::setImage(this, static_cast<GLenum>(coordinate), level, internalFormat, image);
DataHelper<2>::setImage(this, GLenum(coordinate), level, internalFormat, image);
return *this;
}
#endif
@ -191,17 +191,17 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Image
* @return Reference to self (for method chaining)
*
* See Texture::setSubImage() for more information.
* See @ref Texture::setSubImage() for more information.
*/
CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageReference2D& image) {
DataHelper<2>::setSubImage(this, static_cast<GLenum>(coordinate), level, offset, image);
DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image);
return *this;
}
#ifndef MAGNUM_TARGET_GLES2
/** @overload */
CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D& image) {
DataHelper<2>::setSubImage(this, static_cast<GLenum>(coordinate), level, offset, image);
DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image);
return *this;
}
#endif
@ -232,7 +232,6 @@ class CubeMapTexture: public AbstractTexture {
AbstractTexture::setMagnificationFilter(filter);
return *this;
}
#ifndef MAGNUM_TARGET_GLES3
CubeMapTexture& setBorderColor(const Color4& color) {
AbstractTexture::setBorderColor(color);
return *this;
@ -241,7 +240,6 @@ class CubeMapTexture: public AbstractTexture {
AbstractTexture::setMaxAnisotropy(anisotropy);
return *this;
}
#endif
CubeMapTexture& generateMipmap() {
AbstractTexture::generateMipmap();
return *this;

61
src/CubeMapTextureArray.h

@ -26,7 +26,7 @@
#ifndef MAGNUM_TARGET_GLES
/** @file
* @brief Class Magnum::CubeMapTextureArray
* @brief Class @ref Magnum::CubeMapTextureArray
*/
#endif
@ -38,26 +38,23 @@ namespace Magnum {
/**
@brief Cube map texture array
See CubeMapTexture documentation for introduction.
See @ref CubeMapTexture documentation for introduction.
@section CubeMapTextureArray-usage Usage
Common usage is to specify each layer and face separately using setSubImage().
Common usage is to specify each layer and face separately using @ref setSubImage().
You have to allocate the memory for all layers and faces first either by
calling setStorage() or by passing properly sized empty Image to setImage().
Example: array with 16 layers of cube map faces, each face consisting of six
64x64 images:
calling @ref setStorage() or by passing properly sized empty image to
@ref setImage(). Example: array with 16 layers of cube map faces, each face
consisting of six 64x64 images:
@code
Image3D dummy({64, 64, 16*6}, ColorFormat::RGBA, ColorType::UnsignedByte, nullptr);
CubeMapTextureArray texture;
texture.setMagnificationFilter(Sampler::Filter::Linear)
// ...
.setStorage(Math::log2(64)+1, TextureFormat::RGBA8, {64, 64, 16});
for(std::size_t i = 0; i != 16; ++i) {
void* dataPositiveX = ...;
Image2D imagePositiveX({64, 64}, ColorFormat::RGBA, ColorType::UnsignedByte, imagePositiveX);
Image2D imagePositiveX(ColorFormat::RGBA, ColorType::UnsignedByte, {64, 64}, data);
// ...
texture.setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX);
texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX);
@ -67,13 +64,13 @@ for(std::size_t i = 0; i != 16; ++i) {
// ...
@endcode
The texture is bound to layer specified by shader via bind(). In shader, the
texture is used via `samplerCubeArray`, `samplerCubeArrayShadow`,
The texture is bound to layer specified by shader via @ref bind(). In shader,
the texture is used via `samplerCubeArray`, `samplerCubeArrayShadow`,
`isamplerCubeArray` or `usamplerCubeArray`. Unlike in classic textures,
coordinates for cube map texture arrays is signed four-part vector. First three
parts define vector from the center of the cube which intersects with one of
the six sides of the cube map, fourth part is layer in the array. See also
AbstractShaderProgram for more information about usage in shaders.
@ref AbstractShaderProgram for more information about usage in shaders.
@see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTexture,
@ref Texture, @ref BufferTexture
@ -103,7 +100,7 @@ class CubeMapTextureArray: public AbstractTexture {
/**
* @brief Set wrapping
*
* See Texture::setWrapping() for more information.
* See @ref Texture::setWrapping() for more information.
*/
CubeMapTextureArray& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping);
@ -115,16 +112,16 @@ class CubeMapTextureArray: public AbstractTexture {
* @param coordinate Coordinate
* @param level Mip level
*
* See Texture::imageSize() for more information.
* See @ref Texture::imageSize() for more information.
*/
Vector3i imageSize(Coordinate coordinate, Int level) {
return DataHelper<3>::imageSize(this, GL_TEXTURE_CUBE_MAP_POSITIVE_X + static_cast<GLenum>(coordinate), level);
return DataHelper<3>::imageSize(this, GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level);
}
/**
* @brief Set storage
*
* See Texture::setStorage() for more information.
* See @ref Texture::setStorage() for more information.
*/
CubeMapTextureArray& setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) {
DataHelper<3>::setStorage(this, _target, levels, internalFormat, size);
@ -138,7 +135,7 @@ class CubeMapTextureArray: public AbstractTexture {
* @param level Mip level
* @param image %Image where to put the data
*
* See Texture::image(Int, Image&) for more information.
* See @ref Texture::image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, Image3D& image) {
@ -152,11 +149,11 @@ class CubeMapTextureArray: public AbstractTexture {
* @param image %Buffer image where to put the data
* @param usage %Buffer usage
*
* See Texture::image(Int, BufferImage&, Buffer::Usage) for more
* See @ref Texture::image(Int, BufferImage&, BufferUsage) for more
* information.
* @requires_gl %Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, BufferImage3D& image, Buffer::Usage usage) {
void image(Coordinate coordinate, Int level, BufferImage3D& image, BufferUsage usage) {
AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image, usage);
}
#endif
@ -165,15 +162,15 @@ class CubeMapTextureArray: public AbstractTexture {
* @brief Set image data
* @param level Mip level
* @param internalFormat Internal format
* @param image Image, ImageReference, BufferImage or
* Trade::ImageData of the same dimension count
* @param image @ref Image, @ref ImageReference, @ref BufferImage
* or @ref Trade::ImageData of the same dimension count
* @return Reference to self (for method chaining)
*
* Sets texture image data from three-dimensional image for all cube
* faces for all layers. Each group of 6 2D images is one cube map
* layer. The images are ordered the same way as Coordinate enum.
*
* See Texture::setImage() for more information.
* See @ref Texture::setImage() for more information.
*/
CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) {
DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image);
@ -190,8 +187,8 @@ class CubeMapTextureArray: public AbstractTexture {
* @brief Set texture image 3D subdata
* @param level Mip level
* @param offset Offset where to put data in the texture
* @param image Image3D, ImageReference3D, BufferImage3D or
* Trade::ImageData3D
* @param image @ref Image3D, @ref ImageReference3D, @ref BufferImage3D
* or @ref Trade::ImageData3D
* @return Reference to self (for method chaining)
*
* Sets texture image subdata for more than one level/face at once.
@ -199,11 +196,9 @@ class CubeMapTextureArray: public AbstractTexture {
* Z coordinate of @p offset specifies layer and cube map face. If
* you want to start at given face in layer *n*, you have to specify
* Z coordinate as @f$ 6n + i @f$, where i is face index as specified
* in Coordinate enum.
*
* See Texture::setSubImage() for more information.
* in @ref Coordinate enum.
*
* @see setSubImage(Int, Coordinate, Int, const Math::Vector<2, Int>&, const Image*)
* See @ref Texture::setSubImage() for more information.
*/
CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image) {
DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image);
@ -223,10 +218,10 @@ class CubeMapTextureArray: public AbstractTexture {
* @param size Size of invalidated data
*
* Z coordinate is equivalent to layer * 6 + number of texture face,
* i.e. @ref Coordinate "Coordinate::PositiveX" is `0` and so on, in
* the same order as in the enum.
* i.e. @ref Coordinate::PositiveX is `0` and so on, in the same order
* as in the enum.
*
* See Texture::invalidateSubImage() for more information.
* See @ref Texture::invalidateSubImage() for more information.
*/
void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) {
DataHelper<3>::invalidateSubImage(this, level, offset, size);
@ -242,7 +237,6 @@ class CubeMapTextureArray: public AbstractTexture {
AbstractTexture::setMagnificationFilter(filter);
return *this;
}
#ifndef MAGNUM_TARGET_GLES3
CubeMapTextureArray& setBorderColor(const Color4& color) {
AbstractTexture::setBorderColor(color);
return *this;
@ -251,7 +245,6 @@ class CubeMapTextureArray: public AbstractTexture {
AbstractTexture::setMaxAnisotropy(anisotropy);
return *this;
}
#endif
CubeMapTextureArray& generateMipmap() {
AbstractTexture::generateMipmap();
return *this;

4
src/DebugTools/ForceRenderer.cpp

@ -79,10 +79,10 @@ template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneG
Buffer* vertexBuffer = new Buffer(Buffer::Target::Array);
Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray);
vertexBuffer->setData(positions, Buffer::Usage::StaticDraw);
vertexBuffer->setData(positions, BufferUsage::StaticDraw);
ResourceManager::instance().set(this->vertexBuffer.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
indexBuffer->setData(indices, Buffer::Usage::StaticDraw);
indexBuffer->setData(indices, BufferUsage::StaticDraw);
ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
Mesh* mesh = new Mesh;

8
src/DebugTools/Implementation/AbstractShapeRenderer.cpp

@ -46,7 +46,7 @@ template<UnsignedInt dimensions> void create(typename MeshData<dimensions>::Type
template<> void create<2>(Trade::MeshData2D& data, Resource<Mesh>& meshResource, Resource<Buffer>& vertexBufferResource, Resource<Buffer>& indexBufferResource) {
/* Vertex buffer */
Buffer* buffer = new Buffer(Buffer::Target::Array);
buffer->setData(data.positions(0), Buffer::Usage::StaticDraw);
buffer->setData(data.positions(0), BufferUsage::StaticDraw);
ResourceManager::instance().set(vertexBufferResource.key(), buffer, ResourceDataState::Final, ResourcePolicy::Manual);
/* Mesh configuration */
@ -60,7 +60,7 @@ template<> void create<2>(Trade::MeshData2D& data, Resource<Mesh>& meshResource,
if(data.isIndexed()) {
CORRADE_INTERNAL_ASSERT(indexBufferResource.key() != ResourceKey());
Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray);
MeshTools::compressIndices(*mesh, *indexBuffer, Buffer::Usage::StaticDraw, data.indices());
MeshTools::compressIndices(*mesh, *indexBuffer, BufferUsage::StaticDraw, data.indices());
ResourceManager::instance().set(indexBufferResource.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
}
}
@ -68,7 +68,7 @@ template<> void create<2>(Trade::MeshData2D& data, Resource<Mesh>& meshResource,
template<> void create<3>(Trade::MeshData3D& data, Resource<Mesh>& meshResource, Resource<Buffer>& vertexBufferResource, Resource<Buffer>& indexBufferResource) {
/* Vertex buffer */
Buffer* vertexBuffer = new Buffer(Buffer::Target::Array);
vertexBuffer->setData(data.positions(0), Buffer::Usage::StaticDraw);
vertexBuffer->setData(data.positions(0), BufferUsage::StaticDraw);
ResourceManager::instance().set(vertexBufferResource.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
/* Mesh configuration */
@ -82,7 +82,7 @@ template<> void create<3>(Trade::MeshData3D& data, Resource<Mesh>& meshResource,
if(data.isIndexed()) {
CORRADE_INTERNAL_ASSERT(indexBufferResource.key() != ResourceKey());
Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray);
MeshTools::compressIndices(*mesh, *indexBuffer, Buffer::Usage::StaticDraw, data.indices());
MeshTools::compressIndices(*mesh, *indexBuffer, BufferUsage::StaticDraw, data.indices());
ResourceManager::instance().set(indexBufferResource.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
}
}

4
src/DebugTools/ObjectRenderer.cpp

@ -158,10 +158,10 @@ template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(Scen
Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray);
Mesh* mesh = new Mesh;
MeshTools::interleave(*mesh, *vertexBuffer, Buffer::Usage::StaticDraw, Renderer<dimensions>::positions, Renderer<dimensions>::colors);
MeshTools::interleave(*mesh, *vertexBuffer, BufferUsage::StaticDraw, Renderer<dimensions>::positions, Renderer<dimensions>::colors);
ResourceManager::instance().set(this->vertexBuffer.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
indexBuffer->setData(Renderer<dimensions>::indices, Buffer::Usage::StaticDraw);
indexBuffer->setData(Renderer<dimensions>::indices, BufferUsage::StaticDraw);
ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
mesh->setPrimitive(Mesh::Primitive::Lines)

12
src/DebugTools/magnumDebugToolsVisibility.h

@ -26,10 +26,16 @@
#include <Utility/Visibility.h>
#ifdef MagnumDebugTools_EXPORTS
#define MAGNUM_DEBUGTOOLS_EXPORT CORRADE_VISIBILITY_EXPORT
#include "magnumConfigure.h"
#ifndef MAGNUM_BUILD_STATIC
#ifdef MagnumDebugTools_EXPORTS
#define MAGNUM_DEBUGTOOLS_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_DEBUGTOOLS_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_DEBUGTOOLS_EXPORT CORRADE_VISIBILITY_IMPORT
#define MAGNUM_DEBUGTOOLS_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#endif

24
src/DefaultFramebuffer.cpp

@ -24,11 +24,12 @@
#include "DefaultFramebuffer.h"
#include "Context.h"
#include <Containers/Array.h>
#include "Context.h"
#include "Extensions.h"
#include "Implementation/State.h"
#include "Implementation/FramebufferState.h"
#include "Extensions.h"
namespace Magnum {
@ -45,37 +46,32 @@ DefaultFramebuffer& DefaultFramebuffer::mapForDraw(std::initializer_list<std::pa
/* Create linear array from associative */
/** @todo C++14: use VLA to avoid heap allocation */
GLenum* _attachments = new GLenum[max+1];
std::fill_n(_attachments, max, GL_NONE);
static_assert(GL_NONE == 0, "Expecting zero GL_NONE for zero-initialization");
auto _attachments = Containers::Array<GLenum>::zeroInitialized(max+1);
for(auto it = attachments.begin(); it != attachments.end(); ++it)
_attachments[it->first] = static_cast<GLenum>(it->second);
_attachments[it->first] = GLenum(it->second);
(this->*drawBuffersImplementation)(max+1, _attachments);
delete[] _attachments;
return *this;
}
#endif
void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments) {
/** @todo C++14: use VLA to avoid heap allocation */
GLenum* _attachments = new GLenum[attachments.size()];
Containers::Array<GLenum> _attachments(attachments.size());
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments);
delete[] _attachments;
}
void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Rectanglei& rectangle) {
void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle) {
/** @todo C++14: use VLA to avoid heap allocation */
GLenum* _attachments = new GLenum[attachments.size()];
Containers::Array<GLenum> _attachments(attachments.size());
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments, rectangle);
delete[] _attachments;
}
void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) {
@ -84,7 +80,7 @@ void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) {
/* Initial framebuffer size */
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
defaultFramebuffer._viewport = state->viewport = Rectanglei::fromSize({viewport[0], viewport[1]}, {viewport[2], viewport[3]});
defaultFramebuffer._viewport = state->viewport = Range2Di::fromSize({viewport[0], viewport[1]}, {viewport[2], viewport[3]});
/* Fake initial glViewport() call for ApiTrace */
#ifndef MAGNUM_TARGET_GLES

8
src/DefaultFramebuffer.h

@ -349,7 +349,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
* available only in OpenGL ES 3.0.
*/
DefaultFramebuffer& mapForDraw(DrawAttachment attachment) {
(this->*drawBufferImplementation)(static_cast<GLenum>(attachment));
(this->*drawBufferImplementation)(GLenum(attachment));
return *this;
}
#endif
@ -367,7 +367,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
* @requires_gles30 %Extension @es_extension2{NV,read_buffer,GL_NV_read_buffer}
*/
DefaultFramebuffer& mapForRead(ReadAttachment attachment) {
(this->*readBufferImplementation)(static_cast<GLenum>(attachment));
(this->*readBufferImplementation)(GLenum(attachment));
return *this;
}
@ -400,11 +400,11 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
* @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer}.
* Use clear() instead where the extension is not supported.
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Rectanglei& rectangle);
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle);
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
DefaultFramebuffer& setViewport(const Rectanglei& rectangle) {
DefaultFramebuffer& setViewport(const Range2Di& rectangle) {
AbstractFramebuffer::setViewport(rectangle);
return *this;
}

19
src/Extensions.h

@ -100,7 +100,7 @@ namespace GL {
_extension(GL,ARB,texture_query_lod, GL210, GL400) // #73
_extension(GL,ARB,texture_compression_bptc, GL310, GL420) // #77
_extension(GL,ARB,blend_func_extended, GL210, GL330) // #78
_extension(GL,ARB,explicit_attrib_location, /*!*/ GL310, GL330) // #79
_extension(GL,ARB,explicit_attrib_location, /*!*/ GL320, GL330) // #79
_extension(GL,ARB,occlusion_query2, GL210, GL330) // #80
_extension(GL,ARB,sampler_objects, GL210, GL330) // #81
_extension(GL,ARB,shader_bit_encoding, /*?*/ GL210, GL330) // #82
@ -124,7 +124,7 @@ namespace GL {
_extension(GL,ARB,viewport_array, GL210, GL410) // #100
_extension(GL,ARB,robustness, GL210, None) // #105
_extension(GL,ARB,base_instance, GL210, GL420) // #107
_extension(GL,ARB,shading_language_420pack, /*!*/ GL310, GL420) // #108
_extension(GL,ARB,shading_language_420pack, /*!*/ GL320, GL420) // #108
_extension(GL,ARB,transform_feedback_instanced, GL210, GL420) // #109
_extension(GL,ARB,compressed_texture_pixel_storage, GL210, GL420) // #110
_extension(GL,ARB,conservative_depth, GL300, GL420) // #111
@ -141,7 +141,7 @@ namespace GL {
_extension(GL,ARB,texture_view, GL210, GL430) // #124
_extension(GL,ARB,vertex_attrib_binding, GL210, GL430) // #125
_extension(GL,ARB,ES3_compatibility, GL330, GL430) // #127
_extension(GL,ARB,explicit_uniform_location, /*!*/ GL310, GL430) // #128
_extension(GL,ARB,explicit_uniform_location, /*!*/ GL320, GL430) // #128
_extension(GL,ARB,fragment_layer_viewport, GL300, GL430) // #129
_extension(GL,ARB,framebuffer_no_attachments, GL210, GL430) // #130
_extension(GL,ARB,internalformat_query2, GL210, GL430) // #131
@ -268,14 +268,15 @@ namespace GL {
Notes (marked with ! above)
ARB_explicit_attrib_location, ARB_explicit_uniform_location don't work
with GLSL 1.20 (compiler error related to layout qualifier on Mesa) or 1.30
(compiler error related to layout qualifier on NVidia), bumping minimal
required version to GL 3.1 even if both have *2.1* as minimal.
with GLSL 1.20 (compiler error related to layout qualifier on Mesa), 1.30
(compiler error related to layout qualifier on NVidia) or 1.40 (compiler
error on Mac OS X), bumping minimal required version to GL 3.2 even if both
have *2.1* as minimal.
ARB_shading_language_420pack (particularly sampler bindings) doesn't work
with GLSL 1.30 (compiler error related to layout qualifier, similar to the
above), bumping minimal required version to GL 3.1 even if it has *3.0* as
minimal.
with GLSL 1.40 (compiler error related to layout qualifier, similar to the
above), bumping minimal required version to GL 3.2 even that it has *3.0*
as minimal.
*/
}

21
src/Framebuffer.cpp

@ -71,7 +71,7 @@ Int Framebuffer::maxColorAttachments() {
return value;
}
Framebuffer::Framebuffer(const Rectanglei& viewport) {
Framebuffer::Framebuffer(const Range2Di& viewport) {
_viewport = viewport;
glGenFramebuffers(1, &_id);
@ -94,36 +94,31 @@ Framebuffer& Framebuffer::mapForDraw(std::initializer_list<std::pair<UnsignedInt
/* Create linear array from associative */
/** @todo C++14: use VLA to avoid heap allocation */
GLenum* _attachments = new GLenum[max+1];
std::fill_n(_attachments, max, GL_NONE);
static_assert(GL_NONE == 0, "Expecting zero GL_NONE for zero-initialization");
auto _attachments = Containers::Array<GLenum>::zeroInitialized(max+1);
for(auto it = attachments.begin(); it != attachments.end(); ++it)
_attachments[it->first] = GLenum(it->second);
(this->*drawBuffersImplementation)(max+1, _attachments);
delete[] _attachments;
return *this;
}
void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments) {
/** @todo C++14: use VLA to avoid heap allocation */
GLenum* _attachments = new GLenum[attachments.size()];
Containers::Array<GLenum> _attachments(attachments.size());
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments);
delete[] _attachments;
}
void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Rectanglei& rectangle) {
void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle) {
/** @todo C++14: use VLA to avoid heap allocation */
GLenum* _attachments = new GLenum[attachments.size()];
Containers::Array<GLenum> _attachments(attachments.size());
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments, rectangle);
delete[] _attachments;
}
Framebuffer& Framebuffer::attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int mipLevel) {
@ -157,7 +152,7 @@ void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Ren
}
void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) {
glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), static_cast<GLenum>(texture.target()), texture.id(), mipLevel);
glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel);
}
void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) {
@ -179,7 +174,7 @@ void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Te
/** @todo Check for texture target compatibility */
/** @todo Get some extension wrangler for glFramebufferTexture3D() (extension only) */
#ifndef MAGNUM_TARGET_GLES
glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), static_cast<GLenum>(texture.target()), texture.id(), mipLevel, layer);
glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer);
#else
static_cast<void>(attachment);
static_cast<void>(texture);

6
src/Framebuffer.h

@ -306,7 +306,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
* Generates new OpenGL framebuffer.
* @see setViewport(), @fn_gl{GenFramebuffers}
*/
explicit Framebuffer(const Rectanglei& viewport);
explicit Framebuffer(const Range2Di& viewport);
/**
* @brief Destructor
@ -405,7 +405,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
* @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer}.
* Use clear() instead where the extension is not supported.
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Rectanglei& rectangle);
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle);
/**
* @brief Map given color attachment for reading
@ -519,7 +519,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer {
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
Framebuffer& setViewport(const Rectanglei& rectangle) {
Framebuffer& setViewport(const Range2Di& rectangle) {
AbstractFramebuffer::setViewport(rectangle);
return *this;
}

4
src/Implementation/FramebufferState.h

@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Math/Geometry/Rectangle.h"
#include "Math/Range.h"
#include "Magnum.h"
#include "OpenGL.h"
@ -42,7 +42,7 @@ struct FramebufferState {
#ifndef MAGNUM_TARGET_GLES
GLint maxDualSourceDrawBuffers;
#endif
Rectanglei viewport;
Range2Di viewport;
Vector2i maxViewportSize;
};

8
src/Implementation/RendererState.h

@ -29,15 +29,9 @@
namespace Magnum { namespace Implementation {
struct RendererState {
constexpr RendererState()
#ifndef MAGNUM_TARGET_GLES3
: resetNotificationStrategy()
#endif
{}
constexpr RendererState(): resetNotificationStrategy() {}
#ifndef MAGNUM_TARGET_GLES3
Renderer::ResetNotificationStrategy resetNotificationStrategy;
#endif
};
}}

59
src/Magnum.h

@ -301,11 +301,45 @@ typedef Math::Deg<Float> Deg;
/** @brief Angle in float radians */
typedef Math::Rad<Float> Rad;
/** @brief Float rectangle */
/** @brief Float 1D range */
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef Math::Range1D<Float> Range1D;
#else
typedef Math::Range<1, Float> Range1D;
#endif
/** @brief Float 2D range */
typedef Math::Range2D<Float> Range2D;
/** @brief Float 3D range */
typedef Math::Range3D<Float> Range3D;
/** @brief Signed integer 1D range */
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef Math::Range1D<Int> Range1Di;
#else
typedef Math::Range<1, Int> Range1Di;
#endif
/** @brief Signed integer 2D range */
typedef Math::Range2D<Int> Range2Di;
/** @brief Signed integer 3D range */
typedef Math::Range3D<Int> Range3Di;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
@copybrief Range2D
@deprecated Use @ref Magnum::Range2D instead.
*/
typedef Math::Geometry::Rectangle<Float> Rectangle;
/** @brief Signed integer rectangle */
/**
@copybrief Range2Di
@deprecated Use @ref Magnum::Range2Di instead.
*/
typedef Math::Geometry::Rectangle<Int> Rectanglei;
#endif
/*@}*/
@ -444,8 +478,26 @@ typedef Math::Deg<Double> Degd;
/** @brief Angle in double radians */
typedef Math::Rad<Double> Radd;
/** @brief Double rectangle */
/** @brief Double 1D range */
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef Math::Range1D<Double> Range1Dd;
#else
typedef Math::Range<1, Double> Range1Dd;
#endif
/** @brief Double 2D range */
typedef Math::Range2D<Double> Range2Dd;
/** @brief Double 3D range */
typedef Math::Range3D<Double> Range3Dd;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
@copybrief Range2Dd
@deprecated Use @ref Magnum::Range2Dd instead.
*/
typedef Math::Geometry::Rectangle<Double> Rectangled;
#endif
/*@}*/
#endif
@ -475,6 +527,7 @@ template<class T> class Array1D;
template<class T> class Array2D;
template<class T> class Array3D;
enum class BufferUsage: GLenum;
class Buffer;
#ifndef MAGNUM_TARGET_GLES2

1
src/Math/CMakeLists.txt

@ -37,6 +37,7 @@ set(MagnumMath_HEADERS
Matrix3.h
Matrix4.h
Quaternion.h
Range.h
RectangularMatrix.h
Swizzle.h
Unit.h

26
src/Math/Functions.h

@ -25,8 +25,9 @@
*/
#include <cmath>
#include <type_traits>
#include <limits>
#include <type_traits>
#include <utility>
#include "Math/Vector.h"
@ -124,7 +125,7 @@ perform the operations component-wise.
/**
@brief Minimum
@see min(), clamp(), Vector::min()
@see @ref max(), @ref minmax(), @ref clamp(), @ref Vector::min()
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> inline T min(T a, T b);
@ -151,7 +152,7 @@ template<class T> inline T min(std::initializer_list<T> list) {
/**
@brief Maximum
@see max(), clamp(), Vector::max()
@see @ref min(), @ref minmax(), @ref clamp(), @ref Vector::max()
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> inline T max(const T& a, const T& b);
@ -175,6 +176,25 @@ template<class T> inline T max(std::initializer_list<T> list) {
return out;
}
/**
@brief Minimum and maximum of two values
@see @ref min(), @ref max(), @ref clamp(), @ref Vector2::minmax()
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> inline std::pair<T, T> minmax(const T& a, const T& b);
#else
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, std::pair<T, T>>::type minmax(T a, T b) {
return a < b ? std::make_pair(a, b) : std::make_pair(b, a);
}
template<std::size_t size, class T> std::pair<Vector<size, T>, Vector<size, T>> minmax(const Vector<size, T>& a, const Vector<size, T>& b) {
std::pair<Vector<size, T>, Vector<size, T>> out{a, b};
for(std::size_t i = 0; i != size; ++i)
if(out.first[i] > out.second[i]) std::swap(out.first[i], out.second[i]);
return out;
}
#endif
/**
@brief Sign

9
src/Math/Geometry/CMakeLists.txt

@ -24,11 +24,16 @@
set(MagnumMathGeometry_HEADERS
Distance.h
Intersection.h
Rectangle.h)
Intersection.h)
install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry)
# Deprecated headers
if(BUILD_DEPRECATED)
set(MagnumMathGeometry_HEADERS ${MagnumMathGeometry_HEADERS}
Rectangle.h)
endif()
if(BUILD_TESTS)
add_subdirectory(Test)
endif()

168
src/Math/Geometry/Rectangle.h

@ -25,162 +25,48 @@
*/
/** @file
* @brief Class Magnum::Math::Geometry::Rectangle
* @brief Class @ref Magnum::Math::Geometry::Rectangle
* @deprecated Use @ref Math/Range.h instead.
*/
#include "Math/Vector2.h"
#include "Math/Range.h"
#ifdef MAGNUM_BUILD_DEPRECATED
namespace Magnum { namespace Math { namespace Geometry {
/**
@brief %Rectangle
Helper class for storing axis-aligned rectangles consisting of bottom left and
top right corner positions with origin in bottom left. Bottom/left positions
are inclusive, while top/right positions are exclusive.
@see Magnum::Rectangle, Magnum::Rectanglei, Magnum::Rectangled
@todo rename to Range, make it generic for one, two and three dimensions, add translated(), padded()...
@todo move outside Math?
@copybrief Math::Range2D
@deprecated Use @ref Magnum::Math::Range2D instead.
*/
template<class T> class Rectangle {
template<class> friend class Rectangle;
template<class T> class Rectangle: public Range2D<T> {
public:
/**
* Create rectangle from position and size
* @param bottomLeft Bottom left rectangle corner
* @param size %Rectangle size
*/
static Rectangle<T> fromSize(const Vector2<T>& bottomLeft, const Vector2<T>& size) {
return {bottomLeft, bottomLeft+size};
}
/**
* @brief Construct zero rectangle
*
* Construct zero-area rectangle positioned at origin.
*/
constexpr Rectangle() {}
/** @brief Construct rectangle from two corners */
constexpr Rectangle(const Vector2<T>& bottomLeft, const Vector2<T>& topRight): _bottomLeft(bottomLeft), _topRight(topRight) {}
/**
* @brief Construct rectangle from another of different type
*
* Performs only default casting on the values, no rounding or
* anything else. Example usage:
* @code
* Rectangle<Float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f});
* Rectangle<Byte> integral(floatingPoint); // {{1, 2}, {-15, 7}}
* @endcode
*/
template<class U> constexpr explicit Rectangle(const Rectangle<U>& other): _bottomLeft(other._bottomLeft), _topRight(other._topRight) {}
/** @brief Copy constructor */
constexpr Rectangle(const Rectangle<T>&) = default;
/** @brief Assignment operator */
Rectangle<T>& operator=(const Rectangle<T>&) = default;
/** @brief Equality operator */
constexpr bool operator==(const Rectangle<T>& other) const {
return _bottomLeft == other._bottomLeft && _topRight == other._topRight;
}
/** @brief Non-equality operator */
constexpr bool operator!=(const Rectangle<T>& other) const {
return !operator==(other);
}
/** @brief Bottom left corner */
Vector2<T>& bottomLeft() { return _bottomLeft; }
constexpr Vector2<T> bottomLeft() const { return _bottomLeft; } /**< @overload */
/** @brief Bottom right corner */
constexpr Vector2<T> bottomRight() const { return {_topRight.x(), _bottomLeft.y()}; } /**< @overload */
/** @brief Top left corner */
constexpr Vector2<T> topLeft() const { return {_bottomLeft.x(), _topRight.y()}; } /**< @overload */
/** @brief Top right corner */
Vector2<T>& topRight() { return _topRight; }
constexpr Vector2<T> topRight() const { return _topRight; } /**< @overload */
/** @brief Bottom edge */
T& bottom() { return _bottomLeft.y(); }
constexpr T bottom() const { return _bottomLeft.y(); } /**< @overload */
/** @brief Top edge */
T& top() { return _topRight.y(); }
constexpr T top() const { return _topRight.y(); } /**< @overload */
/** @brief Left edge */
T& left() { return _bottomLeft.x(); }
constexpr T left() const { return _bottomLeft.x(); } /**< @overload */
/** @brief Right edge */
T& right() { return _topRight.x(); }
constexpr T right() const { return _topRight.x(); } /**< @overload */
/** @brief %Rectangle size */
constexpr Vector2<T> size() const { return _topRight-_bottomLeft; }
/** @brief %Rectangle width */
constexpr T width() const { return _topRight.x() - _bottomLeft.x(); }
/** @brief %Rectangle height */
constexpr T height() const { return _topRight.y() - _bottomLeft.y(); }
/** @brief Translated rectangle */
Rectangle<T> translated(const Vector2<T>& vec) {
return {_bottomLeft + vec, _topRight + vec};
};
private:
Vector2<T> _bottomLeft;
Vector2<T> _topRight;
};
/** @copydoc Range2D() */
constexpr Rectangle() = default;
/** @debugoperator{Magnum::Math::Geometry::Rectangle} */
template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Rectangle<T>& value) {
debug << "Rectangle({";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false);
debug << value.left() << ", " << value.bottom() << "}, {" << value.right() << ", " << value.top() << "})";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true);
return debug;
}
/** @copydoc Range2D(const VectorType&, const VectorType&) */
constexpr Rectangle(const Vector2<T>& min, const Vector2<T>& max): Range2D<T>(min, max) {}
}}}
/** @copydoc Range2D(const Range&) */
constexpr Rectangle(const Range<2, T>& other): Range2D<T>(other) {}
namespace Corrade { namespace Utility {
/** @copydoc Range2D(const Range<dimensions, U>&) */
template<class U> constexpr explicit Rectangle(const Range2D<U>& other): Range2D<T>(other) {}
/** @copydoc Range2D::sizeX() */
T width() const { return Range2D<T>::sizeX(); }
/** @configurationvalue{Magnum::Math::Geometry::Rectangle} */
template<class T> struct ConfigurationValue<Magnum::Math::Geometry::Rectangle<T>> {
ConfigurationValue() = delete;
/** @brief Writes elements separated with spaces */
static std::string toString(const Magnum::Math::Geometry::Rectangle<T>& value, const ConfigurationValueFlags flags) {
return ConfigurationValue<Magnum::Math::Vector<4, T>>::toString(
reinterpret_cast<const Magnum::Math::Vector<4, T>&>(value), flags);
}
/** @brief Reads elements separated with whitespace */
static Magnum::Math::Geometry::Rectangle<T> fromString(const std::string& stringValue, const ConfigurationValueFlags flags) {
const auto vec = ConfigurationValue<Magnum::Math::Vector<4, T>>::fromString(stringValue, flags);
return {{vec[0], vec[1]}, {vec[2], vec[3]}};
}
/** @copydoc Range2D::sizeY() */
T height() const { return Range2D<T>::sizeY(); }
};
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Geometry::Rectangle<Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Geometry::Rectangle<Magnum::Int>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Geometry::Rectangle<Magnum::UnsignedInt>>;
#ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Geometry::Rectangle<Magnum::Double>>;
#endif
#endif
}}}
namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Math::Geometry::Rectangle} */
template<class T> struct ConfigurationValue<Magnum::Math::Geometry::Rectangle<T>>: public ConfigurationValue<Magnum::Math::Range2D<T>> {};
}}
#else
#error
#endif
#endif

1
src/Math/Geometry/Test/CMakeLists.txt

@ -24,4 +24,3 @@
corrade_add_test(MathGeometryDistanceTest DistanceTest.cpp)
corrade_add_test(MathGeometryIntersectionTest IntersectionTest.cpp LIBRARIES MagnumMathTestLib)
corrade_add_test(MathGeometryRectangleTest RectangleTest.cpp LIBRARIES MagnumMathTestLib)

176
src/Math/Geometry/Test/RectangleTest.cpp

@ -1,176 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <TestSuite/Tester.h>
#include <Utility/Configuration.h>
#include "Math/Geometry/Rectangle.h"
namespace Magnum { namespace Math { namespace Geometry { namespace Test {
class RectangleTest: public Corrade::TestSuite::Tester {
public:
RectangleTest();
void construct();
void constructDefault();
void constructFromSize();
void constructConversion();
void constructCopy();
void access();
void compare();
void size();
void translated();
void debug();
void configuration();
};
typedef Geometry::Rectangle<Float> Rectangle;
typedef Geometry::Rectangle<Int> Rectanglei;
typedef Vector2<Int> Vector2i;
RectangleTest::RectangleTest() {
addTests({&RectangleTest::construct,
&RectangleTest::constructDefault,
&RectangleTest::constructFromSize,
&RectangleTest::constructConversion,
&RectangleTest::constructCopy,
&RectangleTest::access,
&RectangleTest::compare,
&RectangleTest::size,
&RectangleTest::translated,
&RectangleTest::debug,
&RectangleTest::configuration});
}
void RectangleTest::construct() {
constexpr Rectanglei a({3, 5}, {23, 78});
CORRADE_COMPARE(a, Rectanglei({3, 5}, {23, 78}));
}
void RectangleTest::constructDefault() {
constexpr Rectanglei a;
CORRADE_COMPARE(a, Rectanglei({0, 0}, {0, 0}));
}
void RectangleTest::constructFromSize() {
CORRADE_COMPARE(Rectanglei::fromSize({3, 5}, {23, 78}), Rectanglei({3, 5}, {26, 83}));
}
void RectangleTest::constructConversion() {
constexpr Rectangle a({1.3f, 2.7f}, {-15.0f, 7.0f});
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Rectanglei b(a);
CORRADE_COMPARE(b, Rectanglei({1, 2}, {-15, 7}));
/* Implicit conversion is not allowed */
CORRADE_VERIFY(!(std::is_convertible<Rectangle, Rectanglei>::value));
}
void RectangleTest::constructCopy() {
constexpr Rectanglei a({3, 5}, {23, 78});
constexpr Rectanglei b(a);
CORRADE_COMPARE(b, Rectanglei({3, 5}, {23, 78}));
}
void RectangleTest::access() {
Rectanglei rect({34, 23}, {47, 30});
constexpr Rectanglei crect({34, 23}, {47, 30});
CORRADE_COMPARE(rect.bottomLeft(), Vector2i(34, 23));
CORRADE_COMPARE(rect.topRight(), Vector2i(47, 30));
CORRADE_COMPARE(rect.bottom(), 23);
CORRADE_COMPARE(rect.top(), 30);
CORRADE_COMPARE(rect.left(), 34);
CORRADE_COMPARE(rect.right(), 47);
CORRADE_COMPARE(rect.bottomLeft(), Vector2i(34, 23));
CORRADE_COMPARE(rect.topRight(), Vector2i(47, 30));
constexpr Int bottom = crect.bottom();
constexpr Int top = crect.top();
constexpr Int left = crect.left();
constexpr Int right = crect.right();
CORRADE_COMPARE(bottom, 23);
CORRADE_COMPARE(top, 30);
CORRADE_COMPARE(left, 34);
CORRADE_COMPARE(right, 47);
constexpr Vector2i bottomLeft = crect.bottomLeft();
constexpr Vector2i topRight = crect.topRight();
CORRADE_COMPARE(bottomLeft, Vector2i(34, 23));
CORRADE_COMPARE(topRight, Vector2i(47, 30));
CORRADE_COMPARE(rect.topLeft(), Vector2i(34, 30));
CORRADE_COMPARE(rect.bottomRight(), Vector2i(47, 23));
}
void RectangleTest::compare() {
CORRADE_VERIFY(Rectanglei({34, 23}, {47, 30}) == Rectanglei({34, 23}, {47, 30}));
CORRADE_VERIFY(Rectanglei({34, 23}, {47, 30}) != Rectanglei({34, 23}, {48, 30}));
CORRADE_VERIFY(Rectanglei({34, 23}, {47, 30}) != Rectanglei({35, 23}, {47, 30}));
}
void RectangleTest::size() {
Rectanglei rect({34, 23}, {47, 30});
CORRADE_COMPARE(rect.size(), Vector2i(13, 7));
CORRADE_COMPARE(rect.width(), 13);
CORRADE_COMPARE(rect.height(), 7);
}
void RectangleTest::translated() {
CORRADE_COMPARE(Rectanglei({34, 23}, {47, 30}).translated({-17, 40}),
Rectanglei({17, 63}, {30, 70}));
}
void RectangleTest::debug() {
std::ostringstream o;
Debug(&o) << Rectanglei({34, 23}, {47, 30});
CORRADE_COMPARE(o.str(), "Rectangle({34, 23}, {47, 30})\n");
}
void RectangleTest::configuration() {
Corrade::Utility::Configuration c;
Rectangle rect({3.0f, 3.125f}, {9.0f, 9.55f});
std::string value("3 3.125 9 9.55");
c.setValue("rectangle", rect);
CORRADE_COMPARE(c.value("rectangle"), value);
CORRADE_COMPARE(c.value<Rectangle>("rectangle"), rect);
}
}}}}
CORRADE_TEST_MAIN(Magnum::Math::Geometry::Test::RectangleTest)

12
src/Math/Math.h

@ -29,8 +29,9 @@
*/
#include <cstddef>
#include <corradeConfigure.h>
#include "corradeConfigure.h"
#include "Types.h"
namespace Magnum { namespace Math {
@ -74,9 +75,18 @@ template<class> class Vector2;
template<class> class Vector3;
template<class> class Vector4;
template<UnsignedInt, class> class Range;
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class T> using Range1D = Range<1, T>;
#endif
template<class> class Range2D;
template<class> class Range3D;
#ifdef MAGNUM_BUILD_DEPRECATED
namespace Geometry {
template<class> class Rectangle;
}
#endif
}}

512
src/Math/Range.h

@ -0,0 +1,512 @@
#ifndef Magnum_Math_Range_h
#define Magnum_Math_Range_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::Math::Range, @ref Magnum::Math::Range2D, @ref Magnum::Math::Range3D, alias @ref Magnum::Math::Range1D
*/
#include "Math/Vector3.h"
namespace Magnum { namespace Math {
namespace Implementation {
template<UnsignedInt, class> struct RangeTraits;
template<class T> struct RangeTraits<1, T> { typedef Vector<1, T> Type; };
template<class T> struct RangeTraits<2, T> { typedef Vector2<T> Type; };
template<class T> struct RangeTraits<3, T> { typedef Vector3<T> Type; };
}
/**
@brief N-dimensional range
Axis-aligned line (in 1D), rectangle (in 2D) or cube (in 3D). Minimal
coordinate is inclusive, maximal exclusive. See @ref Range1D, @ref Range2D and
@ref Range3D specializations for given dimension count.
*/
template<UnsignedInt dimensions, class T> class Range {
template<UnsignedInt, class> friend class Range;
public:
/**
* @brief Underlying vector type
*
* `T` in 1D, @ref Vector2<T> in 2D, @ref Vector3<T> in 3D.
*/
typedef typename Implementation::RangeTraits<dimensions, T>::Type VectorType;
/**
* Create range from minimal coordinates and size
* @param min Minimal coordinates
* @param size Range size
*/
static Range<dimensions, T> fromSize(const VectorType& min, const VectorType& size) {
return {min, min+size};
}
/**
* @brief Construct zero range
*
* Construct zero-size range positioned at origin.
*/
constexpr Range(): _min{}, _max{} {}
/** @brief Construct range from minimal and maximal coordinates */
constexpr Range(const VectorType& min, const VectorType& max): _min(min), _max(max) {}
/** @brief Copy constructor */
constexpr Range(const Range<dimensions, T>&) = default;
/**
* @brief Construct range from another of different type
*
* Performs only default casting on the values, no rounding or
* anything else. Example usage:
* @code
* Range2D<Float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f});
* Range2D<Byte> integral(floatingPoint); // {{1, 2}, {-15, 7}}
* @endcode
*/
template<class U> constexpr explicit Range(const Range<dimensions, U>& other): _min(other._min), _max(other._max) {}
/** @brief Equality comparison */
constexpr bool operator==(const Range<dimensions, T>& other) const {
return _min == other._min && _max == other._max;
}
/** @brief Non-equality comparison */
constexpr bool operator!=(const Range<dimensions, T>& other) const {
return !operator==(other);
}
/**
* @brief Minimal coordinates (inclusive)
*
* @see @ref size(), @ref Range2D::bottomLeft(),
* @ref Range3D::backBottomLeft()
*/
VectorType& min() { return _min; }
constexpr const VectorType min() const { return _min; } /**< @overload */
/**
* @brief Maximal coordinates (exclusive)
*
* @see @ref size(), @ref Range2D::topRight(),
* @ref Range3D::frontTopRight()
*/
VectorType& max() { return _max; }
constexpr const VectorType max() const { return _max; } /**< @overload */
/**
* @brief Range size
*
* @see @ref min(), @ref max(), @ref Range2D::sizeX(),
* @ref Range2D::sizeY(), @ref Range3D::sizeX(),
* @ref Range3D::sizeY(), @ref Range3D::sizeZ(), @ref center()
*/
VectorType size() const { return _max - _min; }
/**
* @brief Range center
*
* @see @ref Range2D::centerX(), @ref Range2D::centerY(),
* @ref Range3D::centerX(), @ref Range3D::centerY(),
* @ref Range3D::centerZ(), @ref size()
*/
VectorType center() const { return (_min + _max)/T(2); }
/**
* @brief Translated range
*
* Translates the minimal and maximal coordinates by given amount. Size
* remains the same.
* @see @ref padded()
*/
Range<dimensions, T> translated(const VectorType& vector) const;
/**
* @brief Padded rage
*
* Translates the minimal and maximal coordinates by given amount.
* Center remains the same.
* @see @ref translated()
*/
Range<dimensions, T> padded(const VectorType& padding) const;
/**
* @brief Scaled range
*
* Multiplies the minimal and maximal coordinates by given amount.
* @see @ref padded()
*/
Range<dimensions, T> scaled(const VectorType& scaling) const;
private:
VectorType _min, _max;
};
#ifndef DOXYGEN_GENERATING_OUTPUT
#define MAGNUM_RANGE_SUBCLASS_IMPLEMENTATION(dimensions, Type, VectorType) \
static Type<T> fromSize(const VectorType<T>& min, const VectorType<T>& size) { \
return Range<dimensions, T>::fromSize(min, size); \
} \
Type<T> translated(const VectorType<T>& vector) const { \
return Range<dimensions, T>::translated(vector); \
} \
Type<T> padded(const VectorType<T>& padding) const { \
return Range<dimensions, T>::padded(padding); \
} \
Type<T> scaled(const VectorType<T>& scaling) const { \
return Range<dimensions, T>::scaled(scaling); \
}
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief One-dimensional range
Convenience alternative to <tt>%Range<1, T></tt>. See @ref Range for more
information.
@note Not available on GCC < 4.7. Use <tt>%Range<1, T></tt> instead.
*/
template<class T> using Range1D = Range<1, T>;
#endif
/**
@brief Two-dimensional range
See @ref Range for more information.
@see @ref Range1D, @ref Range3D
*/
template<class T> class Range2D: public Range<2, T> {
public:
/** @copydoc Range() */
constexpr /*implicit*/ Range2D() {}
/** @copydoc Range(const VectorType&, const VectorType&) */
constexpr /*implicit*/ Range2D(const Vector2<T>& min, const Vector2<T>& max): Range<2, T>(min, max) {}
/** @copydoc Range(const Range&) */
constexpr /*implicit*/ Range2D(const Range<2, T>& other): Range<2, T>(other) {}
/** @copydoc Range(const Range<dimensions, U>&) */
template<class U> constexpr explicit Range2D(const Range2D<U>& other): Range<2, T>(other) {}
/**
* @brief Bottom left corner
*
* Equivalent to @ref min().
*/
Vector2<T>& bottomLeft() { return Range<2, T>::min(); }
constexpr Vector2<T> bottomLeft() const { return Range<2, T>::min(); } /**< @overload */
/** @brief Bottom right corner */
constexpr Vector2<T> bottomRight() const {
return {Range<2, T>::max().x(), Range<2, T>::min().y()};
}
/** @brief Top left corner */
constexpr Vector2<T> topLeft() const {
return {Range<2, T>::min().x(), Range<2, T>::max().y()};
}
/**
* @brief Top right corner
*
* Equivalent to @ref max().
*/
Vector2<T>& topRight() { return Range<2, T>::max(); }
constexpr Vector2<T> topRight() const { return Range<2, T>::max(); } /**< @overload */
/** @brief Left edge */
T& left() { return Range<2, T>::min().x(); }
constexpr T left() const { return Range<2, T>::min().x(); } /**< @overload */
/** @brief Right edge */
T& right() { return Range<2, T>::max().x(); }
constexpr T right() const { return Range<2, T>::max().x(); } /**< @overload */
/** @brief Bottom edge */
T& bottom() { return Range<2, T>::min().y(); }
constexpr T bottom() const { return Range<2, T>::min().y(); } /**< @overload */
/** @brief Top edge */
T& top() { return Range<2, T>::max().y(); }
constexpr T top() const { return Range<2, T>::max().y(); } /**< @overload */
/**
* @brief %Range width
*
* @see @ref size()
*/
T sizeX() const {
return Range<2, T>::max().x() - Range<2, T>::min().x();
}
/**
* @brief %Range height
*
* @see @ref size()
*/
T sizeY() const {
return Range<2, T>::max().y() - Range<2, T>::min().y();
}
/**
* @brief %Range center on X axis
*
* @see @ref center()
*/
T centerX() const {
return (Range<2, T>::min().x() + Range<2, T>::max().x())/T(2);
}
/**
* @brief %Range center on Y axis
*
* @see @ref center()
*/
T centerY() const {
return (Range<2, T>::min().y() + Range<2, T>::max().y())/T(2);
}
MAGNUM_RANGE_SUBCLASS_IMPLEMENTATION(2, Range2D, Vector2)
};
/**
@brief Two-dimensional range
See @ref Range for more information.
@see @ref Range1D, @ref Range2D
*/
template<class T> class Range3D: public Range<3, T> {
public:
/** @copydoc Range() */
constexpr /*implicit*/ Range3D() {}
/** @copydoc Range(const VectorType&, const VectorType&) */
constexpr /*implicit*/ Range3D(const Vector3<T>& min, const Vector3<T>& max): Range<3, T>(min, max) {}
/** @copydoc Range(const Range&) */
constexpr /*implicit*/ Range3D(const Range<3, T>& other): Range<3, T>(other) {}
/** @copydoc Range(const Range<dimensions, U>&) */
template<class U> constexpr explicit Range3D(const Range3D<U>& other): Range<3, T>(other) {}
/**
* @brief Back bottom left corner
*
* Equivalent to @ref min().
*/
Vector3<T>& backBottomLeft() { return Range<3, T>::min(); }
constexpr Vector3<T> backBottomLeft() const { return Range<3, T>::min(); } /**< @overload */
/** @brief Back bottom right corner */
constexpr Vector3<T> backBottomRight() const {
return {Range<3, T>::max().x(), Range<3, T>::min().y(), Range<3, T>::min().z()};
}
/** @brief Back top right corner */
constexpr Vector3<T> backTopLeft() const {
return {Range<3, T>::min().x(), Range<3, T>::max().y(), Range<3, T>::min().z()};
}
/** @brief Back top right corner */
constexpr Vector3<T> backTopRight() const {
return {Range<3, T>::max().x(), Range<3, T>::max().y(), Range<3, T>::min().z()};
}
/**
* @brief Front top right corner
*
* Equivalent to @ref max().
*/
Vector3<T>& frontTopRight() { return Range<3, T>::max(); }
constexpr Vector3<T> frontTopRight() const { return Range<3, T>::max(); } /**< @overload */
/** @brief Front top left corner */
constexpr Vector3<T> frontTopLeft() const {
return {Range<3, T>::min().x(), Range<3, T>::max().y(), Range<3, T>::max().z()};
}
/** @brief Front bottom right corner */
constexpr Vector3<T> frontBottomRight() const {
return {Range<3, T>::max().x(), Range<3, T>::min().y(), Range<3, T>::max().z()};
}
/** @brief Front bottom left corner */
constexpr Vector3<T> frontBottomLeft() const {
return {Range<3, T>::min().x(), Range<3, T>::min().y(), Range<3, T>::max().z()};
}
/** @brief Left edge */
T& left() { return Range<3, T>::min().x(); }
constexpr T left() const { return Range<3, T>::min().x(); } /**< @overload */
/** @brief Right edge */
T& right() { return Range<3, T>::max().x(); }
constexpr T right() const { return Range<3, T>::max().x(); } /**< @overload */
/** @brief Bottom edge */
T& bottom() { return Range<3, T>::min().y(); }
constexpr T bottom() const { return Range<3, T>::min().y(); } /**< @overload */
/** @brief Top edge */
T& top() { return Range<3, T>::max().y(); }
constexpr T top() const { return Range<3, T>::max().y(); } /**< @overload */
/** @brief Back edge */
T& back() { return Range<3, T>::min().z(); }
constexpr T back() const { return Range<3, T>::min().z(); } /**< @overload */
/** @brief Front edge */
T& front() { return Range<3, T>::max().z(); }
constexpr T front() const { return Range<3, T>::max().z(); } /**< @overload */
/**
* @brief %Range width
*
* @see @ref size()
*/
T sizeX() const {
return Range<3, T>::max().x() - Range<3, T>::min().x();
}
/**
* @brief %Range height
*
* @see @ref size()
*/
T sizeY() const {
return Range<3, T>::max().y() - Range<3, T>::min().y();
}
/**
* @brief %Range depth
*
* @see @ref size()
*/
T sizeZ() const {
return Range<3, T>::max().z() - Range<3, T>::min().z();
}
/**
*
* @brief %Range center on X axis
*
* @see @ref center()
*/
T centerX() const {
return (Range<3, T>::min().x() + Range<3, T>::max().x())/T(2);
}
/**
* @brief %Range center on Y axis
*
* @see @ref center()
*/
T centerY() const {
return (Range<3, T>::min().y() + Range<3, T>::max().y())/T(2);
}
/**
* @brief %Range center on Z axis
*
* @see @ref center()
*/
T centerZ() const {
return (Range<3, T>::min().z() + Range<3, T>::max().z())/T(2);
}
MAGNUM_RANGE_SUBCLASS_IMPLEMENTATION(3, Range3D, Vector3)
};
/** @debugoperator{Magnum::Math::Range} */
template<UnsignedInt dimensions, class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Range<dimensions, T>& value) {
debug << "Range({";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false);
debug << value.min()[0];
for(UnsignedInt i = 1; i != dimensions; ++i) debug << ", " << value.min()[i];
debug << "}, {" << value.max()[0];
for(UnsignedInt i = 1; i != dimensions; ++i) debug << ", " << value.max()[i];
debug << "})";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true);
return debug;
}
template<UnsignedInt dimensions, class T> Range<dimensions, T> Range<dimensions, T>::translated(const VectorType& vector) const {
return {_min + vector, _max + vector};
}
template<UnsignedInt dimensions, class T> Range<dimensions, T> Range<dimensions, T>::padded(const VectorType& padding) const {
return {_min - padding, _max + padding};
}
template<UnsignedInt dimensions, class T> Range<dimensions, T> Range<dimensions, T>::scaled(const VectorType& scaling) const {
return {_min*scaling, _max*scaling};
}
}}
namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Math::Range} */
template<Magnum::UnsignedInt dimensions, class T> struct ConfigurationValue<Magnum::Math::Range<dimensions, T>> {
ConfigurationValue() = delete;
/** @brief Writes elements separated with spaces */
static std::string toString(const Magnum::Math::Range<dimensions, T>& value, const ConfigurationValueFlags flags) {
return ConfigurationValue<Magnum::Math::Vector<dimensions*2, T>>::toString(
reinterpret_cast<const Magnum::Math::Vector<dimensions*2, T>&>(value), flags);
}
/** @brief Reads elements separated with whitespace */
static Magnum::Math::Range<dimensions, T> fromString(const std::string& stringValue, const ConfigurationValueFlags flags) {
const auto vec = ConfigurationValue<Magnum::Math::Vector<dimensions*2, T>>::fromString(stringValue, flags);
return *reinterpret_cast<const Magnum::Math::Range<dimensions, T>*>(vec.data());
}
};
/** @configurationvalue{Magnum::Math::Range2D} */
template<class T> struct ConfigurationValue<Magnum::Math::Range2D<T>>: public ConfigurationValue<Magnum::Math::Range<2, T>> {};
/** @configurationvalue{Magnum::Math::Range3D} */
template<class T> struct ConfigurationValue<Magnum::Math::Range3D<T>>: public ConfigurationValue<Magnum::Math::Range<3, T>> {};
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<2, Magnum::Int>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<3, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<3, Magnum::Int>>;
#ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<3, Magnum::Double>>;
#endif
#endif
}}
#endif

18
src/Math/RectangularMatrix.h

@ -174,13 +174,25 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
/**
* @brief Raw data
* @return One-dimensional array of `size*size` length in column-major
* @return One-dimensional array of `cols*rows` length in column-major
* order.
*
* @see operator[]
*/
T* data() { return _data[0].data(); }
constexpr const T* data() const { return _data[0].data(); } /**< @overload */
T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data[0].data(); }
/** @overload */
constexpr const T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
const &
#else
const
#endif
{ return _data[0].data(); }
/**
* @brief %Matrix column

1
src/Math/Test/CMakeLists.txt

@ -40,6 +40,7 @@ corrade_add_test(MathMatrix4Test Matrix4Test.cpp LIBRARIES MagnumMathTestLib)
corrade_add_test(MathSwizzleTest SwizzleTest.cpp LIBRARIES MagnumMathTestLib)
corrade_add_test(MathUnitTest UnitTest.cpp)
corrade_add_test(MathAngleTest AngleTest.cpp LIBRARIES MagnumMathTestLib)
corrade_add_test(MathRangeTest RangeTest.cpp LIBRARIES MagnumMathTestLib)
corrade_add_test(MathDualTest DualTest.cpp)
corrade_add_test(MathComplexTest ComplexTest.cpp LIBRARIES MagnumMathTestLib)

14
src/Math/Test/FunctionsTest.cpp

@ -37,6 +37,7 @@ class FunctionsTest: public Corrade::TestSuite::Tester {
void minList();
void max();
void maxList();
void minmax();
void sign();
void abs();
@ -79,6 +80,7 @@ FunctionsTest::FunctionsTest() {
&FunctionsTest::minList,
&FunctionsTest::max,
&FunctionsTest::maxList,
&FunctionsTest::minmax,
&FunctionsTest::sign,
&FunctionsTest::abs,
@ -132,6 +134,18 @@ void FunctionsTest::maxList() {
Vector3i(9, -5, 18)}), Vector3i(9, 14, 18));
}
void FunctionsTest::minmax() {
const auto expectedScalar = std::make_pair(-5.0f, 4.0f);
CORRADE_COMPARE(Math::minmax(-5.0f, 4.0f), expectedScalar);
CORRADE_COMPARE(Math::minmax(4.0f, -5.0f), expectedScalar);
const Vector3 a(5.0f, -4.0f, 1.0f);
const Vector3 b(7.0f, -3.0f, 1.0f);
const std::pair<Vector3, Vector3> expectedVector{{5.0f, -4.0f, 1.0f}, {7.0f, -3.0f, 1.0f}};
CORRADE_COMPARE_AS(Math::minmax(a, b), expectedVector, std::pair<Vector3, Vector3>);
CORRADE_COMPARE_AS(Math::minmax(b, a), expectedVector, std::pair<Vector3, Vector3>);
}
void FunctionsTest::sign() {
CORRADE_COMPARE(Math::sign(3516), 1);
CORRADE_COMPARE(Math::sign(0.0f), 0.0f);

5
src/Math/Test/Matrix3Test.cpp

@ -162,10 +162,9 @@ void Matrix3Test::constructConversion() {
{4.5f, 4.0f, 7.0f},
{7.9f, -1.0f, 8.0f});
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Matrix3i b(a);
#else
Matrix3i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Matrix3i b(a);
CORRADE_COMPARE(b, Matrix3i({3, 5, 8},
{4, 4, 7},
{7, -1, 8}));

5
src/Math/Test/Matrix4Test.cpp

@ -181,10 +181,9 @@ void Matrix4Test::constructConversion() {
{1.0f, 2.0f, 3.0f, -1.0f},
{7.9f, -1.0f, 8.0f, -1.5f});
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Matrix4i b(a);
#else
Matrix4i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Matrix4i b(a);
CORRADE_COMPARE(b, Matrix4i({3, 5, 8, -3},
{4, 4, 7, 2},
{1, 2, 3, -1},

397
src/Math/Test/RangeTest.cpp

@ -0,0 +1,397 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <TestSuite/Tester.h>
#include <Utility/Configuration.h>
#include "Math/Range.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include "Math/Geometry/Rectangle.h"
#endif
namespace Magnum { namespace Math { namespace Test {
class RangeTest: public Corrade::TestSuite::Tester {
public:
RangeTest();
void construct();
void constructDefault();
void constructFromSize();
void constructConversion();
void constructCopy();
void access();
void compare();
void size();
void center();
void translated();
void padded();
void scaled();
void subclassTypes();
void subclass();
#ifdef MAGNUM_BUILD_DEPRECATED
void deprecated();
#endif
void debug();
void configuration();
};
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef Math::Range1D<Float> Range1D;
#else
typedef Math::Range<1, Float> Range1D;
#endif
typedef Math::Range2D<Float> Range2D;
typedef Math::Range3D<Float> Range3D;
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef Math::Range1D<Int> Range1Di;
#else
typedef Math::Range<1, Int> Range1Di;
#endif
typedef Math::Range2D<Int> Range2Di;
typedef Math::Range3D<Int> Range3Di;
typedef Vector2<Int> Vector2i;
typedef Vector3<Int> Vector3i;
RangeTest::RangeTest() {
addTests({&RangeTest::construct,
&RangeTest::constructDefault,
&RangeTest::constructFromSize,
&RangeTest::constructConversion,
&RangeTest::constructCopy,
&RangeTest::access,
&RangeTest::compare,
&RangeTest::size,
&RangeTest::center,
&RangeTest::translated,
&RangeTest::padded,
&RangeTest::scaled,
&RangeTest::subclassTypes,
&RangeTest::subclass,
#ifdef MAGNUM_BUILD_DEPRECATED
&RangeTest::deprecated,
#endif
&RangeTest::debug,
&RangeTest::configuration});
}
void RangeTest::construct() {
constexpr Range1Di a(3, 23);
constexpr Range2Di b({3, 5}, {23, 78});
constexpr Range3Di c({3, 5, -7}, {23, 78, 2});
CORRADE_COMPARE(a, (Range<1, Int>(3, 23)));
CORRADE_COMPARE(b, (Range<2, Int>({3, 5}, {23, 78})));
CORRADE_COMPARE(c, (Range<3, Int>({3, 5, -7}, {23, 78, 2})));
}
void RangeTest::constructDefault() {
constexpr Range1Di a;
constexpr Range2Di b;
constexpr Range3Di c;
CORRADE_COMPARE(a, Range1Di(0, 0));
CORRADE_COMPARE(b, Range2Di({0, 0}, {0, 0}));
CORRADE_COMPARE(c, Range3Di({0, 0, 0}, {0, 0, 0}));
}
void RangeTest::constructFromSize() {
CORRADE_COMPARE(Range1Di::fromSize(3, 23), Range1Di(3, 26));
CORRADE_COMPARE(Range2Di::fromSize({3, 5}, {23, 78}), Range2Di({3, 5}, {26, 83}));
CORRADE_COMPARE(Range3Di::fromSize({3, 5, -7}, {23, 78, 9}), Range3Di({3, 5, -7}, {26, 83, 2}));
}
void RangeTest::constructConversion() {
constexpr Range1D a(1.3f, -15.0f);
constexpr Range2D b({1.3f, 2.7f}, {-15.0f, 7.0f});
constexpr Range3D c({1.3f, 2.7f, -1.5f}, {-15.0f, 7.0f, 0.3f});
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Range1Di d(a);
CORRADE_COMPARE(d, Range1Di(1, -15));
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Range2Di e(b);
CORRADE_COMPARE(e, Range2Di({1, 2}, {-15, 7}));
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Range3Di f(c);
CORRADE_COMPARE(f, Range3Di({1, 2, -1}, {-15, 7, 0}));
/* Implicit conversion is not allowed */
CORRADE_VERIFY(!(std::is_convertible<Range<2, Float>, Range<2, Int>>::value));
CORRADE_VERIFY(!(std::is_convertible<Range1D, Range1Di>::value));
CORRADE_VERIFY(!(std::is_convertible<Range2D, Range2Di>::value));
CORRADE_VERIFY(!(std::is_convertible<Range3D, Range3Di>::value));
}
void RangeTest::constructCopy() {
constexpr Range1Di a(3, 23);
constexpr Range2Di b({3, 5}, {23, 78});
constexpr Range3Di c({3, 5, -7}, {23, 78, 2});
constexpr Range1Di d(a);
constexpr Range2Di e(b);
constexpr Range3Di f(c);
CORRADE_COMPARE(d, Range1Di(3, 23));
CORRADE_COMPARE(e, Range2Di({3, 5}, {23, 78}));
CORRADE_COMPARE(f, Range3Di({3, 5, -7}, {23, 78, 2}));
}
void RangeTest::access() {
Range1Di line(34, 47);
Range2Di rect({34, 23}, {47, 30});
Range3Di cube({34, 23, -17}, {47, 30, 12});
constexpr Range1Di cline(34, 47);
constexpr Range2Di crect({34, 23}, {47, 30});
constexpr Range3Di ccube({34, 23, -17}, {47, 30, 12});
CORRADE_COMPARE(line.min(), 34);
CORRADE_COMPARE(cline.min(), 34);
CORRADE_COMPARE(line.max(), 47);
CORRADE_COMPARE(cline.max(), 47);
CORRADE_COMPARE(rect.bottomLeft(), Vector2i(34, 23));
CORRADE_COMPARE(rect.topRight(), Vector2i(47, 30));
constexpr Vector2i bottomLeft = crect.bottomLeft();
constexpr Vector2i topRight = crect.topRight();
CORRADE_COMPARE(bottomLeft, Vector2i(34, 23));
CORRADE_COMPARE(topRight, Vector2i(47, 30));
CORRADE_COMPARE(rect.left(), 34);
CORRADE_COMPARE(rect.right(), 47);
CORRADE_COMPARE(rect.bottom(), 23);
CORRADE_COMPARE(rect.top(), 30);
constexpr Int left2 = crect.left();
constexpr Int right2 = crect.right();
constexpr Int bottom2 = crect.bottom();
constexpr Int top2 = crect.top();
CORRADE_COMPARE(left2, 34);
CORRADE_COMPARE(right2, 47);
CORRADE_COMPARE(bottom2, 23);
CORRADE_COMPARE(top2, 30);
CORRADE_COMPARE(cube.backBottomLeft(), Vector3i(34, 23, -17));
CORRADE_COMPARE(cube.frontTopRight(), Vector3i(47, 30, 12));
constexpr Vector3i backBottomLeft = ccube.backBottomLeft();
constexpr Vector3i frontTopRight = ccube.frontTopRight();
CORRADE_COMPARE(backBottomLeft, Vector3i(34, 23, -17));
CORRADE_COMPARE(frontTopRight, Vector3i(47, 30, 12));
CORRADE_COMPARE(cube.left(), 34);
CORRADE_COMPARE(cube.right(), 47);
CORRADE_COMPARE(cube.bottom(), 23);
CORRADE_COMPARE(cube.top(), 30);
CORRADE_COMPARE(cube.back(), -17);
CORRADE_COMPARE(cube.front(), 12);
constexpr Int left3 = ccube.left();
constexpr Int right3 = ccube.right();
constexpr Int bottom3 = ccube.bottom();
constexpr Int top3 = ccube.top();
constexpr Int back3 = ccube.back();
constexpr Int front3 = ccube.front();
CORRADE_COMPARE(left3, 34);
CORRADE_COMPARE(right3, 47);
CORRADE_COMPARE(bottom3, 23);
CORRADE_COMPARE(top3, 30);
CORRADE_COMPARE(back3, -17);
CORRADE_COMPARE(front3, 12);
CORRADE_COMPARE(rect.bottomRight(), Vector2i(47, 23));
CORRADE_COMPARE(rect.topLeft(), Vector2i(34, 30));
CORRADE_COMPARE(cube.backBottomRight(), Vector3i(47, 23, -17));
CORRADE_COMPARE(cube.backTopLeft(), Vector3i(34, 30, -17));
CORRADE_COMPARE(cube.backTopRight(), Vector3i(47, 30, -17));
CORRADE_COMPARE(cube.frontBottomLeft(), Vector3i(34, 23, 12));
CORRADE_COMPARE(cube.frontBottomRight(), Vector3i(47, 23, 12));
CORRADE_COMPARE(cube.frontTopLeft(), Vector3i(34, 30, 12));
}
void RangeTest::compare() {
CORRADE_VERIFY(Range2Di({34, 23}, {47, 30}) == Range2Di({34, 23}, {47, 30}));
CORRADE_VERIFY(Range2Di({34, 23}, {47, 30}) != Range2Di({34, 23}, {48, 30}));
CORRADE_VERIFY(Range2Di({34, 23}, {47, 30}) != Range2Di({35, 23}, {47, 30}));
CORRADE_VERIFY(Range1D(1.0f, 1.0f) != Range1D(1.0f + TypeTraits<Float>::epsilon()*2, 1.0f));
CORRADE_VERIFY(Range1D(1.0f, 1.0f) != Range1D(1.0f, 1.0f + TypeTraits<Float>::epsilon()*2));
CORRADE_VERIFY(Range1D(1.0f, 1.0f) == Range1D(1.0f + TypeTraits<Float>::epsilon()/2.0f,
1.0f + TypeTraits<Float>::epsilon()/2.0f));
}
void RangeTest::size() {
const Range1Di line(34, 47);
const Range2Di rect({34, 23}, {47, 30});
const Range3Di cube({34, 23, -17}, {47, 30, 12});
CORRADE_COMPARE(line.size(), 13);
CORRADE_COMPARE(rect.size(), Vector2i(13, 7));
CORRADE_COMPARE(cube.size(), Vector3i(13, 7, 29));
CORRADE_COMPARE(rect.sizeX(), 13);
CORRADE_COMPARE(rect.sizeY(), 7);
CORRADE_COMPARE(cube.sizeX(), 13);
CORRADE_COMPARE(cube.sizeY(), 7);
CORRADE_COMPARE(cube.sizeZ(), 29);
}
void RangeTest::center() {
const Range1Di line(34, 47);
const Range2Di rect({34, 23}, {47, 30});
const Range3Di cube({34, 23, -17}, {47, 30, 12});
CORRADE_COMPARE(line.center(), 40);
CORRADE_COMPARE(rect.center(), Vector2i(40, 26));
CORRADE_COMPARE(cube.center(), Vector3i(40, 26, -2));
CORRADE_COMPARE(rect.centerX(), 40);
CORRADE_COMPARE(rect.centerY(), 26);
CORRADE_COMPARE(cube.centerX(), 40);
CORRADE_COMPARE(cube.centerY(), 26);
CORRADE_COMPARE(cube.centerZ(), -2);
}
void RangeTest::translated() {
Range2Di a({34, 23}, {47, 30});
Range2Di b({17, 63}, {30, 70});
CORRADE_COMPARE(a.translated({-17, 40}), b);
CORRADE_COMPARE(a.size(), b.size());
}
void RangeTest::padded() {
Range2Di a({34, 23}, {47, 30});
Range2Di b({31, 28}, {50, 25});
CORRADE_COMPARE(a.padded({3, -5}), b);
CORRADE_COMPARE(a.center(), b.center());
}
void RangeTest::scaled() {
Range2Di a({34, 23}, {47, 30});
Range2Di b({68, -69}, {94, -90});
CORRADE_COMPARE(a.scaled({2, -3}), b);
}
template<class T> class BasicRect: public Math::Range<2, T> {
public:
template<class ...U> BasicRect(U&&... args): Math::Range<2, T>{std::forward<U>(args)...} {}
MAGNUM_RANGE_SUBCLASS_IMPLEMENTATION(2, BasicRect, Vector2)
};
typedef BasicRect<Int> Recti;
void RangeTest::subclassTypes() {
const Vector2i a;
CORRADE_VERIFY((std::is_same<decltype(Recti::fromSize(a, a)), Recti>::value));
const Recti r;
CORRADE_VERIFY((std::is_same<decltype(r.translated(a)), Recti>::value));
CORRADE_VERIFY((std::is_same<decltype(r.padded(a)), Recti>::value));
CORRADE_VERIFY((std::is_same<decltype(r.scaled(a)), Recti>::value));
}
void RangeTest::subclass() {
CORRADE_COMPARE(Recti::fromSize({3, 5}, {23, 78}),
Recti(Vector2i{3, 5}, Vector2i{26, 83}));
CORRADE_COMPARE(Recti(Vector2i{34, 23}, Vector2i{47, 30}).translated({-17, 40}),
Recti(Vector2i{17, 63}, Vector2i{30, 70}));
CORRADE_COMPARE(Recti(Vector2i{34, 23}, Vector2i{47, 30}).padded({3, -5}),
Recti(Vector2i{31, 28}, Vector2i{50, 25}));
CORRADE_COMPARE(Recti(Vector2i{34, 23}, Vector2i{47, 30}).scaled({2, -3}),
Recti(Vector2i{68, -69}, Vector2i{94, -90}));
}
void RangeTest::debug() {
std::ostringstream o;
Debug(&o) << Range2Di({34, 23}, {47, 30});
CORRADE_COMPARE(o.str(), "Range({34, 23}, {47, 30})\n");
}
#ifdef MAGNUM_BUILD_DEPRECATED
void RangeTest::deprecated() {
typedef Geometry::Rectangle<Float> Rectangle;
typedef Geometry::Rectangle<Int> Rectanglei;
Rectanglei a({45, 23}, {-17, 35});
CORRADE_COMPARE(Rectanglei(), Range2Di({0, 0}, {0, 0}));
CORRADE_COMPARE(a, Range2Di({45, 23}, {-17, 35}));
CORRADE_COMPARE(Rectanglei(a), Range2Di({45, 23}, {-17, 35}));
CORRADE_COMPARE(Rectangle(a), Range2D({45.0f, 23.0f}, {-17.0f, 35.0f}));
CORRADE_COMPARE(a.width(), -62);
CORRADE_COMPARE(a.height(), 12);
CORRADE_VERIFY(!(std::is_convertible<Rectangle, Rectanglei>::value));
Corrade::Utility::Configuration c;
Rectangle rect({3.0f, 3.125f}, {9.0f, 9.55f});
std::string value("3 3.125 9 9.55");
c.setValue("rectangle", rect);
CORRADE_COMPARE(c.value("rectangle"), value);
CORRADE_COMPARE(c.value<Rectangle>("rectangle"), rect);
}
#endif
void RangeTest::configuration() {
Corrade::Utility::Configuration c;
Range2D rect({3.0f, 3.125f}, {9.0f, 9.55f});
std::string value("3 3.125 9 9.55");
c.setValue("rectangle", rect);
CORRADE_COMPARE(c.value("rectangle"), value);
CORRADE_COMPARE(c.value<Range2D>("rectangle"), rect);
}
}}}
CORRADE_TEST_MAIN(Magnum::Math::Test::RangeTest)

5
src/Math/Test/RectangularMatrixTest.cpp

@ -155,10 +155,9 @@ void RectangularMatrixTest::constructConversion() {
constexpr Matrix2x2 a(Vector2( 1.3f, 2.7f),
Vector2(-15.0f, 7.0f));
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Matrix2x2i b(a);
#else
Matrix2x2i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Matrix2x2i b(a);
CORRADE_COMPARE(b, Matrix2x2i(Vector2i( 1, 2),
Vector2i(-15, 7)));

21
src/Math/Test/Vector2Test.cpp

@ -68,6 +68,7 @@ class Vector2Test: public Corrade::TestSuite::Tester {
void scales();
void perpendicular();
void aspectRatio();
void minmax();
void swizzleType();
void debug();
@ -93,6 +94,7 @@ Vector2Test::Vector2Test() {
&Vector2Test::scales,
&Vector2Test::perpendicular,
&Vector2Test::aspectRatio,
&Vector2Test::minmax,
&Vector2Test::swizzleType,
&Vector2Test::debug,
@ -115,10 +117,9 @@ void Vector2Test::constructDefault() {
void Vector2Test::constructOneValue() {
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector2 a(3.0f);
#else
Vector2 a(3.0f); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector2 a(3.0f);
CORRADE_COMPARE(a, Vector2(3.0f, 3.0f));
/* Implicit conversion is not allowed */
@ -128,10 +129,9 @@ void Vector2Test::constructOneValue() {
void Vector2Test::constructConversion() {
constexpr Vector2 a(1.5f, 2.5f);
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector2i b(a);
#else
Vector2i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector2i b(a);
CORRADE_COMPARE(b, Vector2i(1, 2));
/* Implicit conversion is not allowed */
@ -210,8 +210,13 @@ void Vector2Test::perpendicular() {
}
void Vector2Test::aspectRatio() {
const Vector2 a(3.0f, 4.0f);
CORRADE_COMPARE(a.aspectRatio(), 0.75f);
CORRADE_COMPARE(Vector2(3.0f, 4.0f).aspectRatio(), 0.75f);
}
void Vector2Test::minmax() {
const auto expected = std::make_pair(-5.0f, 4.0f);
CORRADE_COMPARE(Vector2(-5.0f, 4.0f).minmax(), expected);
CORRADE_COMPARE(Vector2(4.0f, -5.0f).minmax(), expected);
}
void Vector2Test::swizzleType() {

12
src/Math/Test/Vector3Test.cpp

@ -115,10 +115,9 @@ void Vector3Test::constructDefault() {
void Vector3Test::constructOneValue() {
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector3 a(-3.0f);
#else
Vector3 a(-3.0f); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector3 a(-3.0f);
CORRADE_COMPARE(a, Vector3(-3.0f, -3.0f, -3.0f));
/* Implicit conversion is not allowed */
@ -127,17 +126,16 @@ void Vector3Test::constructOneValue() {
void Vector3Test::constructParts() {
constexpr Vector2 a(1.0f, 2.0f);
constexpr Vector3 b(a, 3.0f);
constexpr Vector3 b = {a, 3.0f};
CORRADE_COMPARE(b, Vector3(1.0f, 2.0f, 3.0f));
}
void Vector3Test::constructConversion() {
constexpr Vector3 a(1.0f, 2.5f, -3.0f);
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector3i b(a);
#else
Vector3i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector3i b(a);
CORRADE_COMPARE(b, Vector3i(1, 2, -3));
/* Implicit conversion is not allowed */

12
src/Math/Test/Vector4Test.cpp

@ -112,10 +112,9 @@ void Vector4Test::constructDefault() {
void Vector4Test::constructOneValue() {
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector4 a(4.3f);
#else
Vector4 a(4.3f); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector4 a(4.3f);
CORRADE_COMPARE(a, Vector4(4.3f, 4.3f, 4.3f, 4.3f));
/* Implicit conversion is not allowed */
@ -124,17 +123,16 @@ void Vector4Test::constructOneValue() {
void Vector4Test::constructParts() {
constexpr Vector3 a(1.0f, 2.0f, 3.0f);
constexpr Vector4 b(a, 4.0f);
constexpr Vector4 b = {a, 4.0f};
CORRADE_COMPARE(b, Vector4(1.0f, 2.0f, 3.0f, 4.0f));
}
void Vector4Test::constructConversion() {
constexpr Vector4 a(1.0f, -2.5f, 3.0f, 4.1f);
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector4i b(a);
#else
Vector4i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector4i b(a);
CORRADE_COMPARE(b, Vector4i(1, -2, 3, 4));
/* Implicit conversion is not allowed */

10
src/Math/Test/VectorTest.cpp

@ -175,10 +175,9 @@ void VectorTest::constructDefault() {
void VectorTest::constructOneValue() {
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector4 a(7.25f);
#else
Vector4 a(7.25f); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector4 a(7.25f);
CORRADE_COMPARE(a, Vector4(7.25f, 7.25f, 7.25f, 7.25f));
@ -197,10 +196,9 @@ void VectorTest::constructOneComponent() {
void VectorTest::constructConversion() {
constexpr Vector4 a(1.3f, 2.7f, -15.0f, 7.0f);
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector4i b(a);
#else
Vector4i b(a); /* Not constexpr under GCC < 4.7 */
constexpr /* Not constexpr under GCC < 4.7 */
#endif
Vector4i b(a);
CORRADE_COMPARE(b, Vector4i(1, 2, -15, 7));

22
src/Math/Vector.h

@ -190,12 +190,24 @@ template<std::size_t size, class T> class Vector {
/**
* @brief Raw data
* @return One-dimensional array of `size*size` length.
* @return One-dimensional array of `size` length.
*
* @see operator[]()
*/
T* data() { return _data; }
constexpr const T* data() const { return _data; } /**< @overload */
T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data; }
/** @overload */
constexpr const T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
const &
#else
const
#endif
{ return _data; }
/**
* @brief Value at given position
@ -512,14 +524,14 @@ template<std::size_t size, class T> class Vector {
/**
* @brief Minimal value in the vector
*
* @see Math::min()
* @see @ref Math::min(), @ref Vector2::minmax()
*/
T min() const;
/**
* @brief Maximal value in the vector
*
* @see Math::max()
* @see @ref Math::max(), @ref Vector2::minmax()
*/
T max() const;

17
src/Math/Vector2.h

@ -51,7 +51,7 @@ template<class T> class Vector2: public Vector<2, T> {
* @endcode
* @see yAxis(), xScale(), Matrix3::right()
*/
constexpr static Vector2<T> xAxis(T length = T(1)) { return Vector2<T>(length, T()); }
constexpr static Vector2<T> xAxis(T length = T(1)) { return {length, T(0)}; }
/**
* @brief %Vector in direction of Y axis (up)
@ -59,7 +59,7 @@ template<class T> class Vector2: public Vector<2, T> {
* See xAxis() for more information.
* @see yScale(), Matrix3::up()
*/
constexpr static Vector2<T> yAxis(T length = T(1)) { return Vector2<T>(T(), length); }
constexpr static Vector2<T> yAxis(T length = T(1)) { return {T(0), length}; }
/**
* @brief Scaling vector in direction of X axis (width)
@ -70,7 +70,7 @@ template<class T> class Vector2: public Vector<2, T> {
* @endcode
* @see yScale(), xAxis()
*/
constexpr static Vector2<T> xScale(T scale) { return Vector2<T>(scale, T(1)); }
constexpr static Vector2<T> xScale(T scale) { return {scale, T(1)}; }
/**
* @brief Scaling vector in direction of Y axis (height)
@ -78,7 +78,7 @@ template<class T> class Vector2: public Vector<2, T> {
* See xScale() for more information.
* @see yAxis()
*/
constexpr static Vector2<T> yScale(T scale) { return Vector2<T>(T(1), scale); }
constexpr static Vector2<T> yScale(T scale) { return {T(1), scale}; }
/**
* @brief 2D cross product
@ -147,6 +147,15 @@ template<class T> class Vector2: public Vector<2, T> {
*/
T aspectRatio() const { return x()/y(); }
/**
* @brief Minimum and maximum value
*
* @see @ref min(), @ref max(), @ref Math::minmax()
*/
std::pair<T, T> minmax() const {
return x() < y() ? std::make_pair(x(), y()) : std::make_pair(y(), x());
}
MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(2, Vector2)
};

34
src/Math/Vector3.h

@ -51,25 +51,26 @@ template<class T> class Vector3: public Vector<3, T> {
* Matrix4::translation(Vector3::xAxis(5.0f)); // same as Matrix4::translation({5.0f, 0.0f, 0.0f});
* Matrix4::rotation(30.0_degf, Vector3::xAxis()); // same as Matrix::rotation(30.0_degf, {1.0f, 0.0f, 0.0f});
* @endcode
* @see yAxis(), zAxis(), xScale(), Matrix4::right()
* @see @ref yAxis(), @ref zAxis(), @ref xScale(), @ref Color3::red(),
* @ref Matrix4::right()
*/
constexpr static Vector3<T> xAxis(T length = T(1)) { return Vector3<T>(length, T(), T()); }
constexpr static Vector3<T> xAxis(T length = T(1)) { return {length, T(0), T(0)}; }
/**
* @brief %Vector in direction of Y axis (up)
*
* See xAxis() for more information.
* @see yScale(), Matrix4::up()
* See @ref xAxis() for more information.
* @see @ref yScale(), @ref Color3::green(), @ref Matrix4::up()
*/
constexpr static Vector3<T> yAxis(T length = T(1)) { return Vector3<T>(T(), length, T()); }
constexpr static Vector3<T> yAxis(T length = T(1)) { return {T(0), length, T(0)}; }
/**
* @brief %Vector in direction of Z axis (backward)
*
* See xAxis() for more information.
* @see zScale(), Matrix4::backward()
* See @ref xAxis() for more information.
* @see @ref zScale(), @ref Color3::blue(), @ref Matrix4::backward()
*/
constexpr static Vector3<T> zAxis(T length = T(1)) { return Vector3<T>(T(), T(), length); }
constexpr static Vector3<T> zAxis(T length = T(1)) { return {T(0), T(0), length}; }
/**
* @brief Scaling vector in direction of X axis (width)
@ -78,25 +79,25 @@ template<class T> class Vector3: public Vector<3, T> {
* @code
* Matrix4::scaling(Vector3::xScale(-2.0f)); // same as Matrix4::scaling({-2.0f, 1.0f, 1.0f});
* @endcode
* @see yScale(), zScale(), xAxis()
* @see @ref yScale(), @ref zScale(), @ref Color3::cyan(), @ref xAxis()
*/
constexpr static Vector3<T> xScale(T scale) { return Vector3<T>(scale, T(1), T(1)); }
constexpr static Vector3<T> xScale(T scale) { return {scale, T(1), T(1)}; }
/**
* @brief Scaling vector in direction of Y axis (height)
*
* See xScale() for more information.
* @see yAxis()
* See @ref xScale() for more information.
* @see @ref yAxis(), @ref Color3::magenta()
*/
constexpr static Vector3<T> yScale(T scale) { return Vector3<T>(T(1), scale, T(1)); }
constexpr static Vector3<T> yScale(T scale) { return {T(1), scale, T(1)}; }
/**
* @brief Scaling vector in direction of Z axis (depth)
*
* See xScale() for more information.
* @see zAxis()
* See @ref xScale() for more information.
* @see @ref zAxis(), @ref Color3::yellow()
*/
constexpr static Vector3<T> zScale(T scale) { return Vector3<T>(T(1), T(1), scale); }
constexpr static Vector3<T> zScale(T scale) { return {T(1), T(1), scale}; }
/**
* @brief Cross product
@ -149,7 +150,6 @@ template<class T> class Vector3: public Vector<3, T> {
/** @brief Copy constructor */
constexpr Vector3(const Vector<3, T>& other): Vector<3, T>(other) {}
/**
* @brief X component
*

20
src/Math/instantiation.cpp

@ -24,6 +24,7 @@
#include "Math/DualComplex.h"
#include "Math/DualQuaternion.h"
#include "Math/Range.h"
namespace Corrade { namespace Utility {
@ -52,31 +53,28 @@ template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum:
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Double>>;
#endif
/* For some reason mingw's GCC instantiates ConfigurationValue<Magnum::Math::Geometry::Rectangle<...>>
(which depends on ConfigurationValue<Magnum::Math::Vector<4, ...>) before
these and then loudly complains about multiple definitions. WTF. */
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Float>>;
#ifndef __MINGW32__
template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Float>>;
#endif
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Int>>;
#ifndef __MINGW32__
template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Int>>;
#endif
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::UnsignedInt>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::UnsignedInt>>;
#ifndef __MINGW32__
template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::UnsignedInt>>;
#endif
#ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Double>>;
#ifndef __MINGW32__
template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Double>>;
#endif
template struct ConfigurationValue<Magnum::Math::Range<2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Range<2, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Range<3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Range<3, Magnum::Int>>;
#ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::Range<2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Range<3, Magnum::Double>>;
#endif
#endif

6
src/Mesh.cpp

@ -169,17 +169,17 @@ void Mesh::drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset,
/* Non-indexed mesh */
if(!indexCount)
glDrawArrays(static_cast<GLenum>(_primitive), firstVertex, vertexCount);
glDrawArrays(GLenum(_primitive), firstVertex, vertexCount);
#ifndef MAGNUM_TARGET_GLES2
/* Indexed mesh with specified range */
else if(indexEnd)
glDrawRangeElements(static_cast<GLenum>(_primitive), indexStart, indexEnd, indexCount, static_cast<GLenum>(_indexType), reinterpret_cast<GLvoid*>(indexOffset));
glDrawRangeElements(GLenum(_primitive), indexStart, indexEnd, indexCount, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset));
#endif
/* Indexed mesh without specified range */
else
glDrawElements(static_cast<GLenum>(_primitive), indexCount, static_cast<GLenum>(_indexType), reinterpret_cast<GLvoid*>(indexOffset));
glDrawElements(GLenum(_primitive), indexCount, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset));
(this->*unbindImplementation)();
}

85
src/Mesh.h

@ -83,7 +83,7 @@ Mesh mesh;
static constexpr Vector3 positions[30] = {
// ...
};
vertexBuffer.setData(positions, Buffer::Usage::StaticDraw);
vertexBuffer.setData(positions, BufferUsage::StaticDraw);
// Set primitive and vertex count, add the buffer and specify its layout
mesh.setPrimitive(Mesh::Primitive::Triangles)
@ -100,7 +100,7 @@ Buffer vertexBuffer;
Mesh mesh;
// Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw,
MeshTools::interleave(mesh, buffer, BufferUsage::StaticDraw,
plane.positions(0), plane.normals(0));
// Set primitive and specify layout of interleaved vertex buffer, vertex count
@ -126,13 +126,13 @@ Mesh mesh;
static constexpr Vector3 positions[300] = {
// ...
};
vertexBuffer.setData(positions, Buffer::Usage::StaticDraw);
vertexBuffer.setData(positions, BufferUsage::StaticDraw);
// Fill index buffer with index data
static constexpr GLubyte indices[75] = {
// ...
};
indexBuffer.setData(indices, Buffer::Usage::StaticDraw);
indexBuffer.setData(indices, BufferUsage::StaticDraw);
// Set primitive, index count, specify the buffers
mesh.setPrimitive(Mesh::Primitive::Triangles)
@ -148,11 +148,11 @@ Buffer vertexBuffer, indexBuffer;
Mesh mesh;
// Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw,
MeshTools::interleave(mesh, vertexBuffer, BufferUsage::StaticDraw,
cube.positions(0), cube.normals(0));
// Fill index buffer with compressed index data
MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw,
MeshTools::compressIndices(mesh, indexBuffer, BufferUsage::StaticDraw,
cube.indices());
// Set primitive and specify layout of interleaved vertex buffer. Index count
@ -192,7 +192,7 @@ Buffer colorBuffer;
GLubyte colors[4*30] = {
// ...
};
colorBuffer.setData(colors, Buffer::Usage::StaticDraw);
colorBuffer.setData(colors, BufferUsage::StaticDraw);
// Specify layout of color buffer -- BGRA, each component unsigned byte and we
// want to normalize them from [0, 255] to [0.0f, 1.0f]
@ -241,7 +241,7 @@ class MAGNUM_EXPORT Mesh {
/**
* @brief Primitive type
*
* @see primitive(), setPrimitive()
* @see @ref primitive(), @ref setPrimitive()
*/
enum class Primitive: GLenum {
/** Single points. */
@ -315,7 +315,7 @@ class MAGNUM_EXPORT Mesh {
/**
* @brief Index type
*
* @see setIndexBuffer(), indexSize()
* @see @ref setIndexBuffer(), @ref indexSize()
*/
enum class IndexType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE, /**< Unsigned byte */
@ -365,7 +365,7 @@ class MAGNUM_EXPORT Mesh {
/**
* @brief Size of given index type
*
* @see indexSize() const
* @see @ref indexSize() const
*/
static std::size_t indexSize(IndexType type);
@ -374,8 +374,8 @@ class MAGNUM_EXPORT Mesh {
* @param primitive Primitive type
*
* Creates mesh with no vertex buffers and zero vertex count.
* @see setPrimitive(), setVertexCount(), @fn_gl{GenVertexArrays} (if
* @extension{APPLE,vertex_array_object} is available)
* @see @ref setPrimitive(), @ref setVertexCount(), @fn_gl{GenVertexArrays}
* (if @extension{APPLE,vertex_array_object} is available)
*/
explicit Mesh(Primitive primitive = Primitive::Triangles);
@ -402,7 +402,7 @@ class MAGNUM_EXPORT Mesh {
/**
* @brief Index size
*
* @see indexSize(IndexType)
* @see @ref indexSize(IndexType)
*/
std::size_t indexSize() const { return indexSize(_indexType); }
@ -429,7 +429,8 @@ class MAGNUM_EXPORT Mesh {
* @return Reference to self (for method chaining)
*
* Default is zero.
* @see setPrimitive(), addVertexBuffer(), MeshTools::interleave()
* @see @ref setPrimitive(), @ref addVertexBuffer(),
* @ref MeshTools::interleave()
*/
Mesh& setVertexCount(Int vertexCount) {
_vertexCount = vertexCount;
@ -444,7 +445,7 @@ class MAGNUM_EXPORT Mesh {
* @return Reference to self (for method chaining)
*
* Default is zero.
* @see setIndexBuffer(), MeshTools::compressIndices()
* @see @ref setIndexBuffer(), @ref MeshTools::compressIndices()
*/
Mesh& setIndexCount(Int count) {
_indexCount = count;
@ -469,34 +470,34 @@ class MAGNUM_EXPORT Mesh {
* position and normal, so you have to skip weight and texture
* coordinate in each vertex:
* @code
Buffer buffer;
Mesh mesh;
mesh.addVertexBuffer(buffer, 76, // initial array offset
4, // skip vertex weight (Float)
Shaders::Phong::Position(), // vertex position
8, // skip texture coordinates (Vector2)
Shaders::Phong::Normal()); // vertex normal
@endcode
* Buffer buffer;
* Mesh mesh;
* mesh.addVertexBuffer(buffer, 76, // initial array offset
* 4, // skip vertex weight (Float)
* Shaders::Phong::Position(), // vertex position
* 8, // skip texture coordinates (Vector2)
* Shaders::Phong::Normal()); // vertex normal
* @endcode
*
* You can also achieve the same effect by calling @ref addVertexBuffer()
* more times with explicitly specified gaps before and after the
* attributes. This can be used for e.g. runtime-dependent
* configuration, as it isn't dependent on the variadic template:
@code
mesh.addVertexBuffer(buffer, 76, 4, Shaders::Phong::Position(), 20)
.addVertexBuffer(buffer, 76, 24, Shaders::Phong::Normal(), 0);
@endcode
* @code
* mesh.addVertexBuffer(buffer, 76, 4, Shaders::Phong::Position(), 20)
* .addVertexBuffer(buffer, 76, 24, Shaders::Phong::Normal(), 0);
* @endcode
*
* If specifying more than one attribute, the function assumes that
* the array is interleaved. Adding non-interleaved vertex buffer can
* be done by specifying one attribute at a time with specific offset.
* Above example with weight, position, texture coordinate and normal
* arrays one after another (non-interleaved):
@code
Int vertexCount = 352;
mesh.addVertexBuffer(buffer, 76 + 4*vertexCount, Shaders::Phong::Position())
.addVertexBuffer(buffer, 76 + 24*vertexCount, Shaders::Phong::Normal());
@endcode
* @code
* Int vertexCount = 352;
* mesh.addVertexBuffer(buffer, 76 + 4*vertexCount, Shaders::Phong::Position())
* .addVertexBuffer(buffer, 76 + 24*vertexCount, Shaders::Phong::Normal());
* @endcode
*
* @attention The buffer passed as parameter is not managed by the
* mesh, you must ensure it will exist for whole lifetime of the
@ -528,10 +529,10 @@ class MAGNUM_EXPORT Mesh {
* The smaller range is specified with @p start and @p end the less
* memory operations are needed (and possibly some optimizations),
* improving draw performance. Specifying `0` for both parameters
* behaves the same as setIndexBuffer(Buffer*, GLintptr, IndexType).
* behaves the same as @ref setIndexBuffer(Buffer&, GLintptr, IndexType).
* On OpenGL ES 2.0 this function behaves always as
* setIndexBuffer(Buffer*, GLintptr, IndexType), as this functionality
* is not available there.
* @ref setIndexBuffer(Buffer&, GLintptr, IndexType), as this
* functionality is not available there.
* @see @ref maxElementsIndices(), @ref maxElementsVertices(),
* @ref setIndexCount(), @ref MeshTools::compressIndices(),
* @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if
@ -546,7 +547,7 @@ class MAGNUM_EXPORT Mesh {
* @param type Index data type
* @return Reference to self (for method chaining)
*
* Prefer to use setIndexBuffer(Buffer*, GLintptr, IndexType, UnsignedInt, UnsignedInt)
* Prefer to use @ref setIndexBuffer(Buffer&, GLintptr, IndexType, UnsignedInt, UnsignedInt)
* for better performance.
* @see setIndexCount(), MeshTools::compressIndices(),
* @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if
@ -639,8 +640,8 @@ class MAGNUM_EXPORT Mesh {
(this->*attributePointerImplementation)(Attribute{
&buffer,
location+i,
static_cast<GLint>(attribute.components()),
static_cast<GLenum>(attribute.dataType()),
GLint(attribute.components()),
GLenum(attribute.dataType()),
bool(attribute.dataOptions() & AbstractShaderProgram::Attribute<location, T>::DataOption::Normalized),
offset,
stride
@ -652,8 +653,8 @@ class MAGNUM_EXPORT Mesh {
(this->*attributeIPointerImplementation)(IntegerAttribute{
&buffer,
location,
static_cast<GLint>(attribute.components()),
static_cast<GLenum>(attribute.dataType()),
GLint(attribute.components()),
GLenum(attribute.dataType()),
offset,
stride
});
@ -665,8 +666,8 @@ class MAGNUM_EXPORT Mesh {
(this->*attributeLPointerImplementation)(LongAttribute{
&buffer,
location+i,
static_cast<GLint>(attribute.components()),
static_cast<GLenum>(attribute.dataType()),
GLint(attribute.components()),
GLenum(attribute.dataType()),
offset,
stride
});

22
src/MeshTools/CompressIndices.cpp

@ -26,8 +26,10 @@
#include <cstring>
#include <algorithm>
#include <Containers/Array.h>
#include "Math/Functions.h"
#include "Buffer.h"
namespace Magnum { namespace MeshTools {
@ -38,17 +40,17 @@ template<> constexpr Mesh::IndexType indexType<UnsignedByte>() { return Mesh::In
template<> constexpr Mesh::IndexType indexType<UnsignedShort>() { return Mesh::IndexType::UnsignedShort; }
template<> constexpr Mesh::IndexType indexType<UnsignedInt>() { return Mesh::IndexType::UnsignedInt; }
template<class T> inline std::tuple<std::size_t, Mesh::IndexType, char*> compress(const std::vector<UnsignedInt>& indices) {
char* buffer = new char[indices.size()*sizeof(T)];
template<class T> inline std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> compress(const std::vector<UnsignedInt>& indices) {
Containers::Array<char> buffer(indices.size()*sizeof(T));
for(std::size_t i = 0; i != indices.size(); ++i) {
T index = static_cast<T>(indices[i]);
std::memcpy(buffer+i*sizeof(T), &index, sizeof(T));
std::memcpy(buffer.begin()+i*sizeof(T), &index, sizeof(T));
}
return std::make_tuple(indices.size(), indexType<T>(), buffer);
return std::make_tuple(indices.size(), indexType<T>(), std::move(buffer));
}
std::tuple<std::size_t, Mesh::IndexType, char*> compressIndicesInternal(const std::vector<UnsignedInt>& indices, UnsignedInt max) {
std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> compressIndicesInternal(const std::vector<UnsignedInt>& indices, UnsignedInt max) {
switch(Math::log(256, max)) {
case 0:
return compress<UnsignedByte>(indices);
@ -65,25 +67,23 @@ std::tuple<std::size_t, Mesh::IndexType, char*> compressIndicesInternal(const st
}
std::tuple<std::size_t, Mesh::IndexType, char*> compressIndices(const std::vector<UnsignedInt>& indices) {
std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> compressIndices(const std::vector<UnsignedInt>& indices) {
return compressIndicesInternal(indices, *std::max_element(indices.begin(), indices.end()));
}
void compressIndices(Mesh& mesh, Buffer& buffer, Buffer::Usage usage, const std::vector<UnsignedInt>& indices) {
void compressIndices(Mesh& mesh, Buffer& buffer, BufferUsage usage, const std::vector<UnsignedInt>& indices) {
auto minmax = std::minmax_element(indices.begin(), indices.end());
/** @todo Performance hint when range can be represented by smaller value? */
std::size_t indexCount;
Mesh::IndexType indexType;
char* data;
Containers::Array<char> data;
std::tie(indexCount, indexType, data) = compressIndicesInternal(indices, *minmax.second);
mesh.setIndexCount(indices.size())
.setIndexBuffer(buffer, 0, indexType, *minmax.first, *minmax.second);
buffer.setData({data, indexCount*Mesh::indexSize(indexType)}, usage);
delete[] data;
buffer.setData(data, usage);
}
}}

26
src/MeshTools/CompressIndices.h

@ -25,12 +25,11 @@
*/
/** @file
* @brief Function Magnum::MeshTools::compressIndices()
* @brief Function @ref Magnum::MeshTools::compressIndices()
*/
#include <tuple>
#include "Buffer.h"
#include "Mesh.h"
#include "magnumMeshToolsVisibility.h"
@ -40,28 +39,23 @@ namespace Magnum { namespace MeshTools {
/**
@brief Compress vertex indices
@param indices Index array
@return Index count, type and compressed index array. Deleting the array is
user responsibility.
@return Index count, type and compressed index array
This function takes index array and outputs them compressed to smallest
possible size. For example when your indices have maximum number 463, it's
wasteful to store them in array of 32bit integers, array of 16bit integers is
sufficient. Size of the buffer can be computed from index count and type, as
shown below. Example usage:
sufficient. Example usage:
@code
std::size_t indexCount;
Mesh::IndexType indexType;
char* data;
Containers::Array<char> data;
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(indices);
std::size_t dataSize = indexCount*Mesh::indexSize(indexType);
// ...
delete[] data;
@endcode
See also compressIndices(Mesh*, Buffer*, Buffer::Usage, const std::vector<UnsignedInt>&),
See also @ref compressIndices(Mesh&, Buffer&, BufferUsage, const std::vector<UnsignedInt>&),
which writes the compressed data directly into index buffer of given mesh.
*/
std::tuple<std::size_t, Mesh::IndexType, char*> MAGNUM_MESHTOOLS_EXPORT compressIndices(const std::vector<UnsignedInt>& indices);
std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> MAGNUM_MESHTOOLS_EXPORT compressIndices(const std::vector<UnsignedInt>& indices);
/**
@brief Compress vertex indices and write them to index buffer
@ -70,14 +64,14 @@ std::tuple<std::size_t, Mesh::IndexType, char*> MAGNUM_MESHTOOLS_EXPORT compress
@param usage Index buffer usage
@param indices Index array
The same as compressIndices(const std::vector<UnsignedInt>&), but this
The same as @ref compressIndices(const std::vector<UnsignedInt>&), but this
function writes the output to given buffer, updates index count and specifies
index buffer with proper index range in the mesh, so you don't have to call
Mesh::setIndexCount() and Mesh::setIndexBuffer() on your own.
@ref Mesh::setIndexCount() and @ref Mesh::setIndexBuffer() on your own.
@see MeshTools::interleave()
@see @ref MeshTools::interleave()
*/
void MAGNUM_MESHTOOLS_EXPORT compressIndices(Mesh& mesh, Buffer& buffer, Buffer::Usage usage, const std::vector<UnsignedInt>& indices);
void MAGNUM_MESHTOOLS_EXPORT compressIndices(Mesh& mesh, Buffer& buffer, BufferUsage usage, const std::vector<UnsignedInt>& indices);
}}

2
src/MeshTools/FullScreenTriangle.cpp

@ -50,7 +50,7 @@ std::pair<Buffer*, Mesh> fullScreenTriangle() {
Vector2(-1.0, -3.0),
Vector2( 3.0, 1.0)
};
buffer->setData(triangle, Buffer::Usage::StaticDraw);
buffer->setData(triangle, BufferUsage::StaticDraw);
/** @todo Is it possible to attach moveable buffer here to avoid heap
allocation? OTOH this is more effective in most (modern) cases */
mesh.addVertexBuffer(*buffer, 0, AbstractShaderProgram::Attribute<0, Vector2>());

53
src/MeshTools/Interleave.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Function Magnum::MeshTools::interleave()
* @brief Function @ref Magnum::MeshTools::interleave()
*/
#include <cstring>
@ -42,35 +42,35 @@ namespace Implementation {
class Interleave {
public:
Interleave(): _attributeCount(0), _stride(0), _data(nullptr) {}
Interleave(): _attributeCount(0), _stride(0) {}
template<class ...T> std::tuple<std::size_t, std::size_t, char*> operator()(const T&... attributes) {
template<class ...T> std::tuple<std::size_t, std::size_t, Containers::Array<char>> operator()(const T&... attributes) {
/* Compute buffer size and stride */
_attributeCount = attributeCount(attributes...);
Containers::Array<char> data;
if(_attributeCount && _attributeCount != ~std::size_t(0)) {
_stride = stride(attributes...);
/* Create output buffer */
_data = new char[_attributeCount*_stride];
data = Containers::Array<char>(_attributeCount*_stride);
/* Save the data */
write(_data, attributes...);
write(data.begin(), attributes...);
}
return std::make_tuple(_attributeCount, _stride, _data);
return std::make_tuple(_attributeCount, _stride, std::move(data));
}
template<class ...T> void operator()(Mesh& mesh, Buffer& buffer, Buffer::Usage usage, const T&... attributes) {
operator()(attributes...);
template<class ...T> void operator()(Mesh& mesh, Buffer& buffer, BufferUsage usage, const T&... attributes) {
Containers::Array<char> data;
std::tie(std::ignore, std::ignore, data) = operator()(attributes...);
mesh.setVertexCount(_attributeCount);
buffer.setData(Containers::ArrayReference<const void>{_data, _attributeCount*_stride}, usage);
delete[] _data;
buffer.setData({data, _attributeCount*_stride}, usage);
}
/* Specialization for only one attribute array */
template<class T> typename std::enable_if<!std::is_convertible<T, std::size_t>::value, void>::type operator()(Mesh& mesh, Buffer& buffer, Buffer::Usage usage, const T& attribute) {
template<class T> typename std::enable_if<!std::is_convertible<T, std::size_t>::value, void>::type operator()(Mesh& mesh, Buffer& buffer, BufferUsage usage, const T& attribute) {
mesh.setVertexCount(attribute.size());
buffer.setData(attribute, usage);
}
@ -106,18 +106,16 @@ class Interleave {
template<class T> typename std::enable_if<!std::is_convertible<T, std::size_t>::value, std::size_t>::type writeOne(char* startingOffset, const T& attributeList) {
auto it = attributeList.begin();
for(std::size_t i = 0; i != _attributeCount; ++i, ++it)
memcpy(startingOffset+i*_stride, reinterpret_cast<const char*>(&*it), sizeof(typename T::value_type));
std::memcpy(startingOffset+i*_stride, reinterpret_cast<const char*>(&*it), sizeof(typename T::value_type));
return sizeof(typename T::value_type);
}
/* Fill gap with zeros */
std::size_t writeOne(char* startingOffset, std::size_t gap) {
char* data = new char[gap]();
for(std::size_t i = 0; i != _attributeCount; ++i)
memcpy(startingOffset+i*_stride, data, gap);
std::memset(startingOffset+i*_stride, 0, gap);
delete[] data;
return gap;
}
@ -128,7 +126,6 @@ class Interleave {
std::size_t _attributeCount;
std::size_t _stride;
char* _data;
};
}
@ -148,11 +145,9 @@ std::vector<Vector4> positions;
std::vector<Vector2> textureCoordinates;
std::size_t attributeCount;
std::size_t stride;
char* data;
Containers::Array<char> data;
std::tie(attributeCount, stride, data) = MeshTools::interleave(positions, textureCoordinates);
std::size_t dataSize = attributeCount*stride;
// ...
delete[] data;
@endcode
It's often desirable to align data for one vertex on 32bit boundaries. To
@ -163,7 +158,7 @@ std::vector<GLushort> weights;
std::vector<BasicColor3<GLubyte>> vertexColors;
std::size_t attributeCount;
std::size_t stride;
char* data;
Containers::Array<char> data;
std::tie(attributeCount, stride, data) = MeshTools::interleave(positions, weights, 2, textureCoordinates, 1);
@endcode
This way vertex stride is 24 bytes, without gaps it would be 21 bytes, causing
@ -176,11 +171,11 @@ possible performance loss.
for) and function `size()` returning count of elements. In most cases it
will be `std::vector` or `std::array`.
See also interleave(Mesh*, Buffer*, Buffer::Usage, const T&...),
See also @ref interleave(Mesh&, Buffer&, BufferUsage, const T&...),
which writes the interleaved array directly into buffer of given mesh.
*/
/* enable_if to avoid clash with overloaded function below */
template<class T, class ...U> inline typename std::enable_if<!std::is_same<T, Mesh>::value, std::tuple<std::size_t, std::size_t, char*>>::type interleave(const T& first, const U&... next) {
template<class T, class ...U> inline typename std::enable_if<!std::is_same<T, Mesh>::value, std::tuple<std::size_t, std::size_t, Containers::Array<char>>>::type interleave(const T& first, const U&... next) {
return Implementation::Interleave()(first, next...);
}
@ -191,9 +186,9 @@ template<class T, class ...U> inline typename std::enable_if<!std::is_same<T, Me
@param usage Vertex buffer usage
@param attributes Attribute arrays and gaps
The same as interleave(const T&, const U&...), but this function writes the
The same as @ref interleave(const T&, const U&...), but this function writes the
output to given array buffer and updates vertex count in the mesh accordingly,
so you don't have to call Mesh::setVertexCount() on your own.
so you don't have to call @ref Mesh::setVertexCount() on your own.
@attention Setting primitive type and binding the attributes to shader is left
to user - see @ref Mesh-configuration "Mesh documentation".
@ -201,13 +196,13 @@ so you don't have to call Mesh::setVertexCount() on your own.
For only one attribute array this function is convenient equivalent to the
following, without any performance loss:
@code
buffer->setData(attribute, usage);
mesh->setVertexCount(attribute.size());
buffer.setData(attribute, usage);
mesh.setVertexCount(attribute.size());
@endcode
@see MeshTools::compressIndices()
@see @ref MeshTools::compressIndices()
*/
template<class ...T> inline void interleave(Mesh& mesh, Buffer& buffer, Buffer::Usage usage, const T&... attributes) {
template<class ...T> inline void interleave(Mesh& mesh, Buffer& buffer, BufferUsage usage, const T&... attributes) {
return Implementation::Interleave()(mesh, buffer, usage, attributes...);
}

23
src/MeshTools/Test/CompressIndicesTest.cpp

@ -22,6 +22,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Containers/Array.h>
#include <TestSuite/Tester.h>
#include <Utility/Endianness.h>
@ -47,48 +48,44 @@ CompressIndicesTest::CompressIndicesTest() {
void CompressIndicesTest::compressChar() {
std::size_t indexCount;
Mesh::IndexType indexType;
char* data;
Containers::Array<char> data;
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(
std::vector<UnsignedInt>{1, 2, 3, 0, 4});
CORRADE_COMPARE(indexCount, 5);
CORRADE_VERIFY(indexType == Mesh::IndexType::UnsignedByte);
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*Mesh::indexSize(indexType)),
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()),
(std::vector<char>{ 0x01, 0x02, 0x03, 0x00, 0x04 }));
delete[] data;
}
void CompressIndicesTest::compressShort() {
std::size_t indexCount;
Mesh::IndexType indexType;
char* data;
Containers::Array<char> data;
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(
std::vector<UnsignedInt>{1, 256, 0, 5});
CORRADE_COMPARE(indexCount, 4);
CORRADE_VERIFY(indexType == Mesh::IndexType::UnsignedShort);
if(!Utility::Endianness::isBigEndian()) {
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*Mesh::indexSize(indexType)),
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()),
(std::vector<char>{ 0x01, 0x00,
0x00, 0x01,
0x00, 0x00,
0x05, 0x00 }));
} else {
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*Mesh::indexSize(indexType)),
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()),
(std::vector<char>{ 0x00, 0x01,
0x01, 0x00,
0x00, 0x00,
0x00, 0x05 }));
}
delete[] data;
}
void CompressIndicesTest::compressInt() {
std::size_t indexCount;
Mesh::IndexType indexType;
char* data;
Containers::Array<char> data;
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(
std::vector<UnsignedInt>{65536, 3, 2});
@ -96,18 +93,16 @@ void CompressIndicesTest::compressInt() {
CORRADE_VERIFY(indexType == Mesh::IndexType::UnsignedInt);
if(!Utility::Endianness::isBigEndian()) {
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*Mesh::indexSize(indexType)),
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()),
(std::vector<char>{ 0x00, 0x00, 0x01, 0x00,
0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00 }));
} else {
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*Mesh::indexSize(indexType)),
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()),
(std::vector<char>{ 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x02 }));
}
delete[] data;
}
}}}

2
src/MeshTools/Test/GenerateFlatNormalsTest.cpp

@ -50,7 +50,7 @@ void GenerateFlatNormalsTest::wrongIndexCount() {
std::vector<Vector3> normals;
std::tie(indices, normals) = MeshTools::generateFlatNormals({
0, 1
}, {});
}, std::vector<Vector3>{});
CORRADE_COMPARE(indices.size(), 0);
CORRADE_COMPARE(normals.size(), 0);

21
src/MeshTools/Test/InterleaveTest.cpp

@ -84,7 +84,7 @@ void InterleaveTest::strideGaps() {
void InterleaveTest::write() {
std::size_t attributeCount;
std::size_t stride;
char* data;
Containers::Array<char> data;
std::tie(attributeCount, stride, data) = MeshTools::interleave(
std::vector<Byte>{0, 1, 2},
std::vector<Int>{3, 4, 5},
@ -92,28 +92,25 @@ void InterleaveTest::write() {
CORRADE_COMPARE(attributeCount, std::size_t(3));
CORRADE_COMPARE(stride, std::size_t(7));
std::size_t size = attributeCount*stride;
if(!Utility::Endianness::isBigEndian()) {
CORRADE_COMPARE(std::vector<char>(data, data+size), (std::vector<char>{
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()), (std::vector<char>{
0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00,
0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00,
0x02, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00
}));
} else {
CORRADE_COMPARE(std::vector<char>(data, data+size), (std::vector<char>{
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()), (std::vector<char>{
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07,
0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08
}));
}
delete[] data;
}
void InterleaveTest::writeGaps() {
std::size_t attributeCount;
std::size_t stride;
char* data;
Containers::Array<char> data;
std::tie(attributeCount, stride, data) = MeshTools::interleave(
std::vector<Byte>{0, 1, 2}, 3,
std::vector<Int>{3, 4, 5},
@ -121,22 +118,22 @@ void InterleaveTest::writeGaps() {
CORRADE_COMPARE(attributeCount, std::size_t(3));
CORRADE_COMPARE(stride, std::size_t(12));
std::size_t size = attributeCount*stride;
if(!Utility::Endianness::isBigEndian()) {
CORRADE_COMPARE(std::vector<char>(data, data+size), (std::vector<char>{
/* byte, _____________gap, int___________________, short_____, _______gap */
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()), (std::vector<char>{
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00
}));
} else {
CORRADE_COMPARE(std::vector<char>(data, data+size), (std::vector<char>{
/* byte, _____________gap, ___________________int, _____short, _______gap */
CORRADE_COMPARE(std::vector<char>(data.begin(), data.end()), (std::vector<char>{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00
}));
}
delete[] data;
}
}}}

12
src/MeshTools/magnumMeshToolsVisibility.h

@ -26,10 +26,16 @@
#include <Utility/Visibility.h>
#if defined(MagnumMeshTools_EXPORTS) || defined(MagnumMeshToolsObjects_EXPORTS)
#define MAGNUM_MESHTOOLS_EXPORT CORRADE_VISIBILITY_EXPORT
#include "magnumConfigure.h"
#ifndef MAGNUM_BUILD_STATIC
#if defined(MagnumMeshTools_EXPORTS) || defined(MagnumMeshToolsObjects_EXPORTS)
#define MAGNUM_MESHTOOLS_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_MESHTOOLS_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_MESHTOOLS_EXPORT CORRADE_VISIBILITY_IMPORT
#define MAGNUM_MESHTOOLS_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#endif

2
src/OpenGL.h

@ -56,8 +56,8 @@
#else
#include <OpenGL/GLES2/gl2platform.h>
#include <OpenGL/GLES2/gl2.h>
#include <OpenGL/GLES2/gl2ext.h>
#endif
#include <OpenGL/GLES2/gl2ext.h>
#endif
#endif

1
src/Platform/Implementation/GlxContextHandler.cpp

@ -24,6 +24,7 @@
#include "GlxContextHandler.h"
#include <cstdlib>
#include <GL/glxext.h>
#include <Utility/Debug.h>

2
src/Platform/magnum-info.cpp

@ -354,13 +354,11 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
}
#endif
#ifndef MAGNUM_TARGET_GLES3
if(c->isExtensionSupported<Extensions::GL::EXT::texture_filter_anisotropic>()) {
_h(EXT::texture_filter_anisotropic)
_l(Sampler::maxAnisotropy())
}
#endif
#undef _l
#undef _h

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save