diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 36b95f3f2..436453b6d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,7 @@ set(Magnum_SRCS OpenGL.cpp Query.cpp Renderbuffer.cpp + Renderer.cpp Resource.cpp Shader.cpp Timeline.cpp diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 2a515c686..1b17e38bb 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -72,6 +72,7 @@ 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 information. +@see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture" @see CubeMapTextureArray */ class CubeMapTexture: public AbstractTexture { @@ -86,21 +87,6 @@ class CubeMapTexture: public AbstractTexture { NegativeZ = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z /**< -Z cube side */ }; - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Enable/disable seamless cube map textures - * - * Initially disabled on desktop OpenGL. - * @see @fn_gl{Enable}/@fn_gl{Disable} with @def_gl{TEXTURE_CUBE_MAP_SEAMLESS} - * @requires_gl32 %Extension @extension{ARB,seamless_cube_map} - * @requires_gl Not available in OpenGL ES 2.0, always enabled in - * OpenGL ES 3.0. - */ - inline static void setSeamless(bool enabled) { - enabled ? glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS) : glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - } - #endif - /** * @brief Constructor * diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index 859621176..2c8577f90 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -74,7 +74,7 @@ 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. -@see CubeMapTexture::setSeamless() +@see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture" @requires_gl40 %Extension @extension{ARB,texture_cube_map_array} @requires_gl Cube map texture arrays are not available in OpenGL ES. */ diff --git a/src/Mesh.h b/src/Mesh.h index 137ca2787..014c423ad 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -244,194 +244,6 @@ class MAGNUM_EXPORT Mesh { Mesh& operator=(const Mesh&) = delete; public: - /** @name Polygon drawing settings */ - - /** - * @brief Front facing polygon winding - * - * @see setFrontFace() - */ - enum FrontFace: GLenum { - /** @brief Counterclockwise polygons are front facing (default). */ - CounterClockWise = GL_CCW, - - /** @brief Clockwise polygons are front facing. */ - ClockWise = GL_CW - }; - - /** - * @brief Set front-facing polygon winding - * - * Initial value is `FrontFace::%CounterClockWise`. - * @see @fn_gl{FrontFace} - */ - inline static void setFrontFace(FrontFace mode) { - glFrontFace(static_cast(mode)); - } - - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Provoking vertex - * - * @see setProvokingVertex() - * @requires_gl32 %Extension @extension{ARB,provoking_vertex}. Older - * versions behave always like - * @ref Magnum::Mesh::ProvokingVertex "ProvokingVertex::LastVertexConvention". - * @requires_gl OpenGL ES behaves always like - * @ref Magnum::Mesh::ProvokingVertex "ProvokingVertex::LastVertexConvention". - */ - enum class ProvokingVertex: GLenum { - /** @brief Use first vertex of each polygon. */ - FirstVertexConvention = GL_FIRST_VERTEX_CONVENTION, - - /** @brief Use last vertex of each polygon (default). */ - LastVertexConvention = GL_LAST_VERTEX_CONVENTION - }; - - /** - * @brief Set provoking vertex - * - * Initial value is @ref ProvokingVertex "ProvokingVertex::LastVertexConvention". - * @see @fn_gl{ProvokingVertex} - * @requires_gl32 %Extension @extension{ARB,provoking_vertex}. Older - * versions behave always like the default. - * @requires_gl OpenGL ES behaves always like the default. - */ - inline static void setProvokingVertex(ProvokingVertex mode) { - glProvokingVertex(static_cast(mode)); - } - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Polygon mode - * - * @see setPolygonMode() - * @requires_gl OpenGL ES behaves always like @ref Magnum::Mesh::PolygonMode "PolygonMode::Fill". - * See setPrimitive() for possible workaround. - */ - enum class PolygonMode: GLenum { - /** - * Interior of the polygon is filled (default). - */ - Fill = GL_FILL, - - /** - * Boundary edges are filled. See also setLineWidth(). - */ - Line = GL_LINE, - - /** - * Starts of boundary edges are drawn as points. See also - * setPointSize(). - */ - Point = GL_POINT - }; - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Set polygon drawing mode - * - * Initial value is @ref PolygonMode "PolygonMode::Fill". - * @see @fn_gl{PolygonMode} - * @requires_gl OpenGL ES behaves always like the default. See - * setPrimitive() for possible workaround. - */ - inline static void setPolygonMode(PolygonMode mode) { - glPolygonMode(GL_FRONT_AND_BACK, static_cast(mode)); - } - #endif - - /** - * @brief Mode affected by polygon offset - * - * @see setPolygonOffsetMode(), setPolygonOffset() - */ - enum class PolygonOffsetMode: GLenum { - /** Offset filled polygons. */ - Fill = GL_POLYGON_OFFSET_FILL - - #ifndef MAGNUM_TARGET_GLES - , - - /** - * Offset lines. - * @requires_gl Only @ref Magnum::Mesh::PolygonOffsetMode "PolygonOffsetMode::Fill" - * is available in OpenGL ES. - */ - Line = GL_POLYGON_OFFSET_LINE, - - /** - * Offset points. - * @requires_gl Only @ref Magnum::Mesh::PolygonOffsetMode "PolygonOffsetMode::Fill" - * is available in OpenGL ES. - */ - Point = GL_POLYGON_OFFSET_POINT - #endif - }; - - /** - * @brief Enable/disable polygon offset for given mode - * - * Initially disabled for all modes. - * @see setPolygonOffset(), @fn_gl{Enable}/@fn_gl{Disable} - */ - inline static void setPolygonOffsetMode(PolygonOffsetMode mode, bool enabled) { - enabled ? glEnable(static_cast(mode)) : glDisable(static_cast(mode)); - } - - /** - * @brief Set polygon offset - * @param factor Scale factor - * @param units Offset units - * - * @attention You have to call setPolygonOffsetMode() to enable - * polygon offset for desired polygon modes. - * @see @fn_gl{PolygonOffset} - */ - inline static void setPolygonOffset(Float factor, Float units) { - glPolygonOffset(factor, units); - } - - /** - * @brief Set line width - * - * Initial value is `1.0f`. - * @see @fn_gl{LineWidth} - */ - inline static void setLineWidth(Float width) { - glLineWidth(width); - } - - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Set point size - * - * Initial value is `1.0f`. - * @see setProgramPointSize(), @fn_gl{PointSize} - * @requires_gl Set directly in vertex shader using @c gl_PointSize - * builtin variable. - */ - inline static void setPointSize(Float size) { - glPointSize(size); - } - - /** - * @brief Enable/disable programmable point size - * - * If enabled, the point size is taken from vertex/geometry shader - * builtin `gl_PointSize`. Initially disabled on desktop OpenGL. - * @see setPointSize(), @fn_gl{Enable}/@fn_gl{Disable} with @def_gl{PROGRAM_POINT_SIZE} - * @requires_gl Always enabled on OpenGL ES. - */ - inline static void setProgramPointSize(bool enabled) { - enabled ? glEnable(GL_PROGRAM_POINT_SIZE) : glDisable(GL_PROGRAM_POINT_SIZE); - } - #endif - - /*@}*/ - /** * @brief Primitive type * diff --git a/src/Renderer.cpp b/src/Renderer.cpp new file mode 100644 index 000000000..80602741b --- /dev/null +++ b/src/Renderer.cpp @@ -0,0 +1,144 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + 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 "Renderer.h" + +#include "Color.h" +#include "Math/Geometry/Rectangle.h" + +namespace Magnum { + +void Renderer::setFeature(const Feature feature, const bool enabled) { + enabled ? glEnable(GLenum(feature)) : glDisable(GLenum(feature)); +} + +void Renderer::setFaceCullingMode(const PolygonFacing mode) { + glCullFace(GLenum(mode)); +} + +void Renderer::setClearColor(const Color4<>& color) { + glClearColor(color.r(), color.g(), color.b(), color.a()); +} + +void Renderer::setClearDepth(const Double depth) { + glClearDepth(depth); +} + +void Renderer::setClearDepth(const Float depth) { + glClearDepthf(depth); +} + +void Renderer::setClearStencil(const Int stencil) { + glClearStencil(stencil); +} + +void Renderer::setFrontFace(const FrontFace mode) { + glFrontFace(GLenum(mode)); +} + +void Renderer::setProvokingVertex(const ProvokingVertex mode) { + glProvokingVertex(GLenum(mode)); +} + +void Renderer::setPolygonMode(const PolygonMode mode) { + glPolygonMode(GL_FRONT_AND_BACK, GLenum(mode)); +} + +void Renderer::setPolygonOffset(const Float factor, const Float units) { + glPolygonOffset(factor, units); +} + +void Renderer::setLineWidth(const Float width) { + glLineWidth(width); +} + +void Renderer::setPointSize(const Float size) { + glPointSize(size); +} + +void Renderer::setScissor(const Rectanglei& rectangle) { + glScissor(rectangle.left(), rectangle.bottom(), rectangle.width(), rectangle.height()); +} + +void Renderer::setStencilFunction(const PolygonFacing facing, const StencilFunction function, const Int referenceValue, const UnsignedInt mask) { + glStencilFuncSeparate(GLenum(facing), GLenum(function), referenceValue, mask); +} + +void Renderer::setStencilFunction(const StencilFunction function, const Int referenceValue, const UnsignedInt mask) { + glStencilFunc(GLenum(function), referenceValue, mask); +} + +void Renderer::setStencilOperation(const PolygonFacing facing, const StencilOperation stencilFail, const StencilOperation depthFail, const StencilOperation depthPass) { + glStencilOpSeparate(GLenum(facing), GLenum(stencilFail), GLenum(depthFail), GLenum(depthPass)); +} + +void Renderer::setStencilOperation(const StencilOperation stencilFail, const StencilOperation depthFail, const StencilOperation depthPass) { + glStencilOp(GLenum(stencilFail), GLenum(depthFail), GLenum(depthPass)); +} + +void Renderer::setDepthFunction(const DepthFunction function) { + glDepthFunc(GLenum(function)); +} + +void Renderer::setColorMask(const GLboolean allowRed, const GLboolean allowGreen, const GLboolean allowBlue, const GLboolean allowAlpha) { + glColorMask(allowRed, allowGreen, allowBlue, allowAlpha); +} + +void Renderer::setDepthMask(const GLboolean allow) { + glDepthMask(allow); +} + +void Renderer::setStencilMask(const PolygonFacing facing, const UnsignedInt allowBits) { + glStencilMaskSeparate(GLenum(facing), allowBits); +} + +void Renderer::setStencilMask(const UnsignedInt allowBits) { + glStencilMask(allowBits); +} + +void Renderer::setBlendEquation(const BlendEquation equation) { + glBlendEquation(GLenum(equation)); +} + +void Renderer::setBlendEquation(const BlendEquation rgb, const BlendEquation alpha) { + glBlendEquationSeparate(GLenum(rgb), GLenum(alpha)); +} + +void Renderer::setBlendFunction(const BlendFunction source, const BlendFunction destination) { + glBlendFunc(GLenum(source), GLenum(destination)); +} + +void Renderer::setBlendFunction(const BlendFunction sourceRgb, const BlendFunction destinationRgb, const BlendFunction sourceAlpha, const BlendFunction destinationAlpha) { + glBlendFuncSeparate(GLenum(sourceRgb), GLenum(destinationRgb), GLenum(sourceAlpha), GLenum(destinationAlpha)); +} + +void Renderer::setBlendColor(const Color4<>& color) { + glBlendColor(color.r(), color.g(), color.b(), color.a()); +} + +void Renderer::setLogicOperation(const LogicOperation operation) { + glLogicOp(GLenum(operation)); +} + +} diff --git a/src/Renderer.h b/src/Renderer.h index 06f65be9b..eed34659e 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -30,11 +30,9 @@ #include -#include "AbstractImage.h" -#include "Buffer.h" -#include "CubeMapTexture.h" -#include "Color.h" -#include "Renderbuffer.h" +#include "Magnum.h" +#include "OpenGL.h" +#include "magnumVisibility.h" namespace Magnum { @@ -67,7 +65,7 @@ class MAGNUM_EXPORT Renderer { /** * @brief Features * - * If not specified otherwise, all features are disabled by default. + * All features are disabled by default unless specified otherwise. * @see setFeature() */ enum class Feature: GLenum { @@ -77,10 +75,37 @@ class MAGNUM_EXPORT Renderer { */ Blending = GL_BLEND, - DepthTest = GL_DEPTH_TEST, /**< Depth test */ - Dithering = GL_DITHER, /**< Dithering (enabled by default) */ + /** + * Seamless cube map texture. + * @see CubeMapTexture, CubeMapTextureArray + * @requires_gl32 %Extension @extension{ARB,seamless_cube_map} + * @requires_gl Not available in OpenGL ES 2.0, always enabled in + * OpenGL ES 3.0. + */ + SeamlessCubeMapTexture = GL_TEXTURE_CUBE_MAP_SEAMLESS, + + #ifndef MAGNUM_TARGET_GLES + /** + * Depth clamping. If enabled, ignores near and far clipping plane. + * @requires_gl32 %Extension @extension{ARB,depth_clamp} + * @requires_gl Depth clamping is not available in OpenGL ES. + */ + DepthClamp = GL_DEPTH_CLAMP, + #endif + + /** + * Depth test + * @see setClearDepth(), setDepthFunction(), setDepthMask() + */ + DepthTest = GL_DEPTH_TEST, - FaceCulling = GL_CULL_FACE, /**< Back face culling */ + Dithering = GL_DITHER, /**< Dithering. Enabled by default. */ + + /** + * Back face culling + * @see setFrontFace() + */ + FaceCulling = GL_CULL_FACE, #ifndef MAGNUM_TARGET_GLES /** @@ -94,28 +119,64 @@ class MAGNUM_EXPORT Renderer { #ifndef MAGNUM_TARGET_GLES /** - * Multisampling (enabled by default) + * Multisampling. Enabled by default. Note that the actual presence + * of this feature in default framebuffer depends on context + * configuration, see for example Platform::GlutApplication::Configuration::setSampleCount(). * @requires_gl Always enabled in OpenGL ES. */ Multisampling = GL_MULTISAMPLE, #endif + /** + * Offset filled polygons + * @see @ref Magnum::Renderer::Feature "Feature::PolygonOffsetLine", + * @ref Magnum::Renderer::Feature "Feature::PolygonOffsetPoint", + * setPolygonOffset() + */ + PolygonOffsetFill = GL_POLYGON_OFFSET_FILL, + #ifndef MAGNUM_TARGET_GLES /** - * Depth clamping. If enabled, ignores near and far clipping plane. - * @requires_gl32 %Extension @extension{ARB,depth_clamp} - * @requires_gl Depth clamping is not available in OpenGL ES. + * Offset lines + * @see @ref Magnum::Renderer::Feature "Feature::PolygonOffsetFill", + * @ref Magnum::Renderer::Feature "Feature::PolygonOffsetPoint", + * setPolygonOffset() + * @requires_gl Only @ref Magnum::Renderer::Feature "Feature::PolygonOffsetFill" + * is available in OpenGL ES. */ - DepthClamp = GL_DEPTH_CLAMP, + PolygonOffsetLine = GL_POLYGON_OFFSET_LINE, + + /** + * Offset points + * @see @ref Magnum::Renderer::Feature "Feature::PolygonOffsetFill", + * @ref Magnum::Renderer::Feature "Feature::PolygonOffsetLine", + * setPolygonOffset() + * @requires_gl Only @ref Magnum::Renderer::Feature "Feature::PolygonOffsetFill" + * is available in OpenGL ES. + */ + PolygonOffsetPoint = GL_POLYGON_OFFSET_POINT, #endif + /** + * Programmable point size. If enabled, the point size is taken + * from vertex/geometry shader builtin `gl_PointSize`. + * @see setPointSize() + * @requires_gl Always enabled on OpenGL ES. + */ + ProgramPointSize = GL_PROGRAM_POINT_SIZE, + /** * Scissor test * @see setScissor() */ ScissorTest = GL_SCISSOR_TEST, - StencilTest = GL_STENCIL_TEST /**< Stencil test */ + /** + * Stencil test + * @see setClearStencil(), setStencilFunction(), + * setStencilOperation(), setStencilMask() + */ + StencilTest = GL_STENCIL_TEST }; /** @@ -123,21 +184,16 @@ class MAGNUM_EXPORT Renderer { * * @see @fn_gl{Enable}/@fn_gl{Disable} */ - inline static void setFeature(Feature feature, bool enabled) { - enabled ? glEnable(static_cast(feature)) : glDisable(static_cast(feature)); - } + static void setFeature(Feature feature, bool enabled); /** * @brief Which polygon facing to cull * - * Initial value is `PolygonFacing::Back`. If set to both front and - * back, only points and lines are drawn. - * @attention You have to also enable face culling with setFeature(). - * @see @fn_gl{CullFace} + * Initial value is @ref PolygonFacing "PolygonFacing::Back". If set to + * both front and back, only points and lines are drawn. + * @see @ref Feature "Feature::FaceCulling", @fn_gl{CullFace} */ - inline static void setFaceCullingMode(PolygonFacing mode) { - glCullFace(static_cast(mode)); - } + static void setFaceCullingMode(PolygonFacing mode); /*@}*/ @@ -146,40 +202,165 @@ class MAGNUM_EXPORT Renderer { /** * @brief Set clear color * - * Initial value is `{0.0f, 0.0f, 0.0f, 1.0f}`. + * Initial value is fully opaque black. * @see @fn_gl{ClearColor} */ - inline static void setClearColor(const Color4<>& color) { - glClearColor(color.r(), color.g(), color.b(), color.a()); - } + static void setClearColor(const Color4<>& color); #ifndef MAGNUM_TARGET_GLES /** * @brief Set clear depth * * Initial value is `1.0`. - * @see @fn_gl{ClearDepth} + * @see @ref Feature "Feature::DepthTest", @fn_gl{ClearDepth} * @requires_gl See setClearDepth(Float), which is available in OpenGL ES. */ - inline static void setClearDepth(Double depth) { glClearDepth(depth); } + static void setClearDepth(Double depth); #endif /** * @overload * - * @see @fn_gl{ClearDepth} + * @see @ref Feature "Feature::DepthTest", @fn_gl{ClearDepth} * @requires_gl41 %Extension @extension{ARB,ES2_compatibility} * @todo Call double version if the extension is not available */ - inline static void setClearDepth(Float depth) { glClearDepthf(depth); } + static void setClearDepth(Float depth); /** * @brief Set clear stencil * * Initial value is `0`. - * @see @fn_gl{ClearStencil} + * @see @ref Feature "Feature::StencilTest", @fn_gl{ClearStencil} + */ + static void setClearStencil(Int stencil); + + /*@}*/ + + /** @name Polygon drawing settings */ + + /** + * @brief Front facing polygon winding + * + * @see setFrontFace() + */ + enum FrontFace: GLenum { + /** @brief Counterclockwise polygons are front facing (default). */ + CounterClockWise = GL_CCW, + + /** @brief Clockwise polygons are front facing. */ + ClockWise = GL_CW + }; + + /** + * @brief Set front-facing polygon winding + * + * Initial value is `FrontFace::%CounterClockWise`. + * @see @fn_gl{FrontFace} + */ + static void setFrontFace(FrontFace mode); + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Provoking vertex + * + * @see setProvokingVertex() + * @requires_gl32 %Extension @extension{ARB,provoking_vertex}. Older + * versions behave always like + * @ref Magnum::Renderer::ProvokingVertex "ProvokingVertex::LastVertexConvention". + * @requires_gl OpenGL ES behaves always like + * @ref Magnum::Renderer::ProvokingVertex "ProvokingVertex::LastVertexConvention". + */ + enum class ProvokingVertex: GLenum { + /** @brief Use first vertex of each polygon. */ + FirstVertexConvention = GL_FIRST_VERTEX_CONVENTION, + + /** @brief Use last vertex of each polygon (default). */ + LastVertexConvention = GL_LAST_VERTEX_CONVENTION + }; + + /** + * @brief Set provoking vertex + * + * Initial value is @ref ProvokingVertex "ProvokingVertex::LastVertexConvention". + * @see @fn_gl{ProvokingVertex} + * @requires_gl32 %Extension @extension{ARB,provoking_vertex}. Older + * versions behave always like the default. + * @requires_gl OpenGL ES behaves always like the default. + */ + static void setProvokingVertex(ProvokingVertex mode); + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Polygon mode + * + * @see setPolygonMode() + * @requires_gl OpenGL ES behaves always like @ref Magnum::Renderer::PolygonMode "PolygonMode::Fill". + * See @ref Magnum::Mesh::setPrimitive() "Mesh::setPrimitive()" + * for possible workaround. + */ + enum class PolygonMode: GLenum { + /** + * Interior of the polygon is filled (default). + */ + Fill = GL_FILL, + + /** + * Boundary edges are filled. See also setLineWidth(). + */ + Line = GL_LINE, + + /** + * Starts of boundary edges are drawn as points. See also + * setPointSize(). + */ + Point = GL_POINT + }; + + /** + * @brief Set polygon drawing mode + * + * Initial value is @ref PolygonMode "PolygonMode::Fill". + * @see @fn_gl{PolygonMode} + * @requires_gl OpenGL ES behaves always like the default. See + * @ref Magnum::Mesh::setPrimitive() "Mesh::setPrimitive()" for + * possible workaround. + */ + static void setPolygonMode(PolygonMode mode); + #endif + + /** + * @brief Set polygon offset + * @param factor Scale factor + * @param units Offset units + * + * @see @ref Feature "Feature::PolygonOffsetFill", + * @ref Feature "Feature::PolygonOffsetLine", + * @ref Feature "Feature::PolygonOffsetPoint", + * @fn_gl{PolygonOffset} */ - inline static void setClearStencil(Int stencil) { glClearStencil(stencil); } + static void setPolygonOffset(Float factor, Float units); + + /** + * @brief Set line width + * + * Initial value is `1.0f`. + * @see @fn_gl{LineWidth} + */ + static void setLineWidth(Float width); + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Set point size + * + * Initial value is `1.0f`. + * @see @ref Feature "Feature::ProgramPointSize", @fn_gl{PointSize} + * @requires_gl In OpenGL ES use `gl_PointSize` builtin vertex shader + * variable. + */ + static void setPointSize(Float size); + #endif /*@}*/ @@ -187,17 +368,10 @@ class MAGNUM_EXPORT Renderer { /** * @brief Set scissor rectangle - * @param bottomLeft Bottom left corner. Initial value is `(0, 0)`. - * @param size Scissor rectangle size. Initial value is - * size of the window when the context is first attached to a - * window. * - * @attention You have to enable scissoring with setFeature() first. - * @see @fn_gl{Scissor} + * @see @ref Feature "Feature::ScissorTest", @fn_gl{Scissor} */ - inline static void setScissor(const Vector2i& bottomLeft, const Vector2i& size) { - glScissor(bottomLeft.x(), bottomLeft.y(), size.x(), size.y()); - } + static void setScissor(const Rectanglei& rectangle); /*@}*/ @@ -206,7 +380,7 @@ class MAGNUM_EXPORT Renderer { /** * @brief Stencil function * - * @see setStencilFunction() + * @see setStencilFunction(), @ref DepthFunction */ enum class StencilFunction: GLenum { Never = GL_NEVER, /**< Never pass the test. */ @@ -268,29 +442,27 @@ class MAGNUM_EXPORT Renderer { * @brief Set stencil function * @param facing Affected polygon facing * @param function Stencil function. Initial value is - * `StencilFunction::Always`. + * @ref StencilFunction "StencilFunction::Always". * @param referenceValue Reference value. Initial value is `0`. * @param mask Mask for both reference and buffer value. * Initial value is all `1`s. * - * @attention You have to enable stencil test with setFeature() first. - * @see setStencilFunction(StencilFunction, Int, UnsignedInt), + * @see @ref Feature "Feature::StencilTest", + * setStencilFunction(StencilFunction, Int, UnsignedInt), + * setStencilOperation(), * @fn_gl{StencilFuncSeparate} */ - inline static void setStencilFunction(PolygonFacing facing, StencilFunction function, Int referenceValue, UnsignedInt mask) { - glStencilFuncSeparate(static_cast(facing), static_cast(function), referenceValue, mask); - } + static void setStencilFunction(PolygonFacing facing, StencilFunction function, Int referenceValue, UnsignedInt mask); /** * @brief Set stencil function * * The same as setStencilFunction(PolygonFacing, StencilFunction, Int, UnsignedInt) - * with `facing` set to `PolygonFacing::FrontAndBack`. - * @see @fn_gl{StencilFunc} + * with @p facing set to @ref PolygonFacing "PolygonFacing::FrontAndBack". + * @see @ref Feature "Feature::StencilTest", setStencilOperation(), + * @fn_gl{StencilFunc} */ - inline static void setStencilFunction(StencilFunction function, Int referenceValue, UnsignedInt mask) { - glStencilFunc(static_cast(function), referenceValue, mask); - } + static void setStencilFunction(StencilFunction function, Int referenceValue, UnsignedInt mask); /** * @brief Set stencil operation @@ -301,25 +473,22 @@ class MAGNUM_EXPORT Renderer { * @param depthPass Action when both stencil and depth test * pass * - * Initial value for all fields is `StencilOperation::Keep`. - * @attention You have to enable stencil test with setFeature() first. - * @see setStencilOperation(StencilOperation, StencilOperation, StencilOperation), - * @fn_gl{StencilOpSeparate} + * Initial value for all fields is @ref StencilOperation "StencilOperation::Keep". + * @see @ref Feature "Feature::StencilTest", + * setStencilOperation(StencilOperation, StencilOperation, StencilOperation), + * setStencilFunction(), @fn_gl{StencilOpSeparate} */ - inline static void setStencilOperation(PolygonFacing facing, StencilOperation stencilFail, StencilOperation depthFail, StencilOperation depthPass) { - glStencilOpSeparate(static_cast(facing), static_cast(stencilFail), static_cast(depthFail), static_cast(depthPass)); - } + static void setStencilOperation(PolygonFacing facing, StencilOperation stencilFail, StencilOperation depthFail, StencilOperation depthPass); /** * @brief Set stencil operation * * The same as setStencilOperation(PolygonFacing, StencilOperation, StencilOperation, StencilOperation) - * with `facing` set to `PolygonFacing::FrontAndBack`. - * @see @fn_gl{StencilOp} + * with @p facing set to @ref PolygonFacing "PolygonFacing::FrontAndBack". + * @see @ref Feature "Feature::StencilTest", setStencilFunction(), + * @fn_gl{StencilOp} */ - inline static void setStencilOperation(StencilOperation stencilFail, StencilOperation depthFail, StencilOperation depthPass) { - glStencilOp(static_cast(stencilFail), static_cast(depthFail), static_cast(depthPass)); - } + static void setStencilOperation(StencilOperation stencilFail, StencilOperation depthFail, StencilOperation depthPass); /*@}*/ @@ -335,13 +504,10 @@ class MAGNUM_EXPORT Renderer { /** * @brief Set depth function * - * Initial value is `DepthFunction::Less`. - * @attention You have to enable depth test with setFeature() first. - * @see @fn_gl{DepthFunc} + * Initial value is @ref DepthFunction "DepthFunction::Less". + * @see @ref Feature "Feature::DepthTest", @fn_gl{DepthFunc} */ - inline static void setDepthFunction(DepthFunction function) { - glDepthFunc(static_cast(function)); - } + static void setDepthFunction(DepthFunction function); /*@}*/ @@ -352,45 +518,38 @@ class MAGNUM_EXPORT Renderer { * * Set to `false` to disallow writing to given color channel. Initial * values are all `true`. - * @see @fn_gl{ColorMask} + * @see setDepthMask(), setStencilMask(), @fn_gl{ColorMask} * @todo Masking only given draw buffer */ - inline static void setColorMask(GLboolean allowRed, GLboolean allowGreen, GLboolean allowBlue, GLboolean allowAlpha) { - glColorMask(allowRed, allowGreen, allowBlue, allowAlpha); - } + static void setColorMask(GLboolean allowRed, GLboolean allowGreen, GLboolean allowBlue, GLboolean allowAlpha); /** * @brief Mask depth writes * * Set to `false` to disallow writing to depth buffer. Initial value * is `true`. - * @see @fn_gl{DepthMask} + * @see setColorMask(), setStencilMask(), @fn_gl{DepthMask} */ - inline static void setDepthMask(GLboolean allow) { - glDepthMask(allow); - } + static void setDepthMask(GLboolean allow); /** * @brief Mask stencil writes * * Set given bit to `0` to disallow writing stencil value for given * faces to it. Initial value is all `1`s. - * @see setStencilMask(UnsignedInt), @fn_gl{StencilMaskSeparate} + * @see setStencilMask(UnsignedInt), setColorMask(), setDepthMask(), + * @fn_gl{StencilMaskSeparate} */ - inline static void setStencilMask(PolygonFacing facing, UnsignedInt allowBits) { - glStencilMaskSeparate(static_cast(facing), allowBits); - } + static void setStencilMask(PolygonFacing facing, UnsignedInt allowBits); /** * @brief Mask stencil writes * - * The same as setStencilMask(PolygonFacing, UnsignedInt) with `facing` set - * to `PolygonFacing::FrontAndBack`. + * The same as calling setStencilMask(PolygonFacing, UnsignedInt) with + * `facing` set to @ref PolygonFacing "PolygonFacing::FrontAndBack". * @see @fn_gl{StencilMask} */ - inline static void setStencilMask(UnsignedInt allowBits) { - glStencilMask(allowBits); - } + static void setStencilMask(UnsignedInt allowBits); /*@}*/ @@ -559,67 +718,55 @@ class MAGNUM_EXPORT Renderer { * @brief Set blend equation * * How to combine source color (pixel value) with destination color - * (framebuffer). Initial value is `BlendEquation::Add`. - * @attention You have to enable blending with setFeature() first. - * @see setBlendEquation(BlendEquation, BlendEquation), - * @fn_gl{BlendEquation} + * (framebuffer). Initial value is @ref BlendEquation "BlendEquation::Add". + * @see @ref Feature "Feature::Blending", setBlendEquation(BlendEquation, BlendEquation), + * setBlendFunction(), setBlendColor(), @fn_gl{BlendEquation} */ - inline static void setBlendEquation(BlendEquation equation) { - glBlendEquation(static_cast(equation)); - } + static void setBlendEquation(BlendEquation equation); /** * @brief Set blend equation separately for RGB and alpha components * * See setBlendEquation(BlendEquation) for more information. - * @attention You have to enable blending with setFeature() first. - * @see @fn_gl{BlendEquationSeparate} + * @see @ref Feature "Feature::Blending", setBlendFunction(), + * setBlendColor(), @fn_gl{BlendEquationSeparate} */ - inline static void setBlendEquation(BlendEquation rgb, BlendEquation alpha) { - glBlendEquationSeparate(static_cast(rgb), static_cast(alpha)); - } + static void setBlendEquation(BlendEquation rgb, BlendEquation alpha); /** * @brief Set blend function * @param source How the source blending factor is computed - * from pixel value. Initial value is `BlendFunction::One`. + * from pixel value. Initial value is @ref BlendFunction "BlendFunction::One". * @param destination How the destination blending factor is - * computed from framebuffer. Initial value is - * `BlendFunction::Zero`. + * computed from framebuffer. Initial value is @ref BlendFunction "BlendFunction::Zero". * - * @attention You have to enable blending with setFeature() first. - * @see setBlendFunction(BlendFunction, BlendFunction, BlendFunction, BlendFunction), - * @fn_gl{BlendFunc} + * @see @ref Feature "Feature::Blending", + * setBlendFunction(BlendFunction, BlendFunction, BlendFunction, BlendFunction), + * setBlendEquation(), setBlendColor(), @fn_gl{BlendFunc} */ - inline static void setBlendFunction(BlendFunction source, BlendFunction destination) { - glBlendFunc(static_cast(source), static_cast(destination)); - } + static void setBlendFunction(BlendFunction source, BlendFunction destination); /** * @brief Set blend function separately for RGB and alpha components * * See setBlendFunction(BlendFunction, BlendFunction) for more information. - * @attention You have to enable blending with setFeature() first. - * @see @fn_gl{BlendFuncSeparate} + * @see @ref Feature "Feature::Blending", setBlendEquation(), + * setBlendColor(), @fn_gl{BlendFuncSeparate} */ - inline static void setBlendFunction(BlendFunction sourceRgb, BlendFunction destinationRgb, BlendFunction sourceAlpha, BlendFunction destinationAlpha) { - glBlendFuncSeparate(static_cast(sourceRgb), static_cast(destinationRgb), static_cast(sourceAlpha), static_cast(destinationAlpha)); - } + static void setBlendFunction(BlendFunction sourceRgb, BlendFunction destinationRgb, BlendFunction sourceAlpha, BlendFunction destinationAlpha); /** * @brief Set blend color * * Sets constant color used in setBlendFunction() by - * `BlendFunction::ConstantColor`, - * `BlendFunction::OneMinusConstantColor`, - * `BlendFunction::ConstantAlpha` and - * `BlendFunction::OneMinusConstantAlpha`. - * @attention You have to enable blending with setFeature() first. - * @see @fn_gl{BlendColor} - */ - inline static void setBlendColor(const Color4<>& color) { - glBlendColor(color.r(), color.g(), color.b(), color.a()); - } + * @ref BlendFunction "BlendFunction::ConstantColor", + * @ref BlendFunction "BlendFunction::OneMinusConstantColor", + * @ref BlendFunction "BlendFunction::ConstantAlpha" and + * @ref BlendFunction "BlendFunction::OneMinusConstantAlpha". + * @see @ref Feature "Feature::Blending", setBlendEquation(), + * setBlendFunction(), @fn_gl{BlendColor} + */ + static void setBlendColor(const Color4<>& color); /*@}*/ @@ -655,14 +802,11 @@ class MAGNUM_EXPORT Renderer { /** * @brief Set logical operation * - * @attention You have to enable logical operation with setFeature() first. - * @see @fn_gl{LogicOp} + * @see @ref Feature "Feature::LogicOperation", @fn_gl{LogicOp} * @requires_gl Logical operations on framebuffer are not available in * OpenGL ES. */ - inline static void setLogicOperation(LogicOperation operation) { - glLogicOp(static_cast(operation)); - } + static void setLogicOperation(LogicOperation operation); /*@}*/ #endif