|
|
|||
File indexing completed on 2026-06-02 08:58:13
0001 //////////////////////////////////////////////////////////// 0002 // 0003 // SFML - Simple and Fast Multimedia Library 0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) 0005 // 0006 // This software is provided 'as-is', without any express or implied warranty. 0007 // In no event will the authors be held liable for any damages arising from the use of this software. 0008 // 0009 // Permission is granted to anyone to use this software for any purpose, 0010 // including commercial applications, and to alter it and redistribute it freely, 0011 // subject to the following restrictions: 0012 // 0013 // 1. The origin of this software must not be misrepresented; 0014 // you must not claim that you wrote the original software. 0015 // If you use this software in a product, an acknowledgment 0016 // in the product documentation would be appreciated but is not required. 0017 // 0018 // 2. Altered source versions must be plainly marked as such, 0019 // and must not be misrepresented as being the original software. 0020 // 0021 // 3. This notice may not be removed or altered from any source distribution. 0022 // 0023 //////////////////////////////////////////////////////////// 0024 0025 #ifndef SFML_GLSL_HPP 0026 #define SFML_GLSL_HPP 0027 0028 //////////////////////////////////////////////////////////// 0029 // Headers 0030 //////////////////////////////////////////////////////////// 0031 #include <SFML/Graphics/Transform.hpp> 0032 #include <SFML/Graphics/Color.hpp> 0033 #include <SFML/System/Vector2.hpp> 0034 #include <SFML/System/Vector3.hpp> 0035 0036 0037 namespace sf 0038 { 0039 namespace priv 0040 { 0041 // Forward declarations 0042 template <std::size_t Columns, std::size_t Rows> 0043 struct Matrix; 0044 0045 template <typename T> 0046 struct Vector4; 0047 0048 #include <SFML/Graphics/Glsl.inl> 0049 0050 } // namespace priv 0051 0052 0053 //////////////////////////////////////////////////////////// 0054 /// \brief Namespace with GLSL types 0055 /// 0056 //////////////////////////////////////////////////////////// 0057 namespace Glsl 0058 { 0059 0060 //////////////////////////////////////////////////////////// 0061 /// \brief 2D float vector (\p vec2 in GLSL) 0062 /// 0063 //////////////////////////////////////////////////////////// 0064 typedef Vector2<float> Vec2; 0065 0066 //////////////////////////////////////////////////////////// 0067 /// \brief 2D int vector (\p ivec2 in GLSL) 0068 /// 0069 //////////////////////////////////////////////////////////// 0070 typedef Vector2<int> Ivec2; 0071 0072 //////////////////////////////////////////////////////////// 0073 /// \brief 2D bool vector (\p bvec2 in GLSL) 0074 /// 0075 //////////////////////////////////////////////////////////// 0076 typedef Vector2<bool> Bvec2; 0077 0078 //////////////////////////////////////////////////////////// 0079 /// \brief 3D float vector (\p vec3 in GLSL) 0080 /// 0081 //////////////////////////////////////////////////////////// 0082 typedef Vector3<float> Vec3; 0083 0084 //////////////////////////////////////////////////////////// 0085 /// \brief 3D int vector (\p ivec3 in GLSL) 0086 /// 0087 //////////////////////////////////////////////////////////// 0088 typedef Vector3<int> Ivec3; 0089 0090 //////////////////////////////////////////////////////////// 0091 /// \brief 3D bool vector (\p bvec3 in GLSL) 0092 /// 0093 //////////////////////////////////////////////////////////// 0094 typedef Vector3<bool> Bvec3; 0095 0096 #ifdef SFML_DOXYGEN 0097 0098 //////////////////////////////////////////////////////////// 0099 /// \brief 4D float vector (\p vec4 in GLSL) 0100 /// 0101 /// 4D float vectors can be implicitly converted from sf::Color 0102 /// instances. Each color channel is normalized from integers 0103 /// in [0, 255] to floating point values in [0, 1]. 0104 /// \code 0105 /// sf::Glsl::Vec4 zeroVector; 0106 /// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f); 0107 /// sf::Glsl::Vec4 color = sf::Color::Cyan; 0108 /// \endcode 0109 //////////////////////////////////////////////////////////// 0110 typedef implementation-defined Vec4; 0111 0112 //////////////////////////////////////////////////////////// 0113 /// \brief 4D int vector (\p ivec4 in GLSL) 0114 /// 0115 /// 4D int vectors can be implicitly converted from sf::Color 0116 /// instances. Each color channel remains unchanged inside 0117 /// the integer interval [0, 255]. 0118 /// \code 0119 /// sf::Glsl::Ivec4 zeroVector; 0120 /// sf::Glsl::Ivec4 vector(1, 2, 3, 4); 0121 /// sf::Glsl::Ivec4 color = sf::Color::Cyan; 0122 /// \endcode 0123 //////////////////////////////////////////////////////////// 0124 typedef implementation-defined Ivec4; 0125 0126 //////////////////////////////////////////////////////////// 0127 /// \brief 4D bool vector (\p bvec4 in GLSL) 0128 /// 0129 //////////////////////////////////////////////////////////// 0130 typedef implementation-defined Bvec4; 0131 0132 //////////////////////////////////////////////////////////// 0133 /// \brief 3x3 float matrix (\p mat3 in GLSL) 0134 /// 0135 /// The matrix can be constructed from an array with 3x3 0136 /// elements, aligned in column-major order. For example, 0137 /// a translation by (x, y) looks as follows: 0138 /// \code 0139 /// float array[9] = 0140 /// { 0141 /// 1, 0, 0, 0142 /// 0, 1, 0, 0143 /// x, y, 1 0144 /// }; 0145 /// 0146 /// sf::Glsl::Mat3 matrix(array); 0147 /// \endcode 0148 /// 0149 /// Mat3 can also be implicitly converted from sf::Transform: 0150 /// \code 0151 /// sf::Transform transform; 0152 /// sf::Glsl::Mat3 matrix = transform; 0153 /// \endcode 0154 //////////////////////////////////////////////////////////// 0155 typedef implementation-defined Mat3; 0156 0157 //////////////////////////////////////////////////////////// 0158 /// \brief 4x4 float matrix (\p mat4 in GLSL) 0159 /// 0160 /// The matrix can be constructed from an array with 4x4 0161 /// elements, aligned in column-major order. For example, 0162 /// a translation by (x, y, z) looks as follows: 0163 /// \code 0164 /// float array[16] = 0165 /// { 0166 /// 1, 0, 0, 0, 0167 /// 0, 1, 0, 0, 0168 /// 0, 0, 1, 0, 0169 /// x, y, z, 1 0170 /// }; 0171 /// 0172 /// sf::Glsl::Mat4 matrix(array); 0173 /// \endcode 0174 /// 0175 /// Mat4 can also be implicitly converted from sf::Transform: 0176 /// \code 0177 /// sf::Transform transform; 0178 /// sf::Glsl::Mat4 matrix = transform; 0179 /// \endcode 0180 //////////////////////////////////////////////////////////// 0181 typedef implementation-defined Mat4; 0182 0183 #else // SFML_DOXYGEN 0184 0185 typedef priv::Vector4<float> Vec4; 0186 typedef priv::Vector4<int> Ivec4; 0187 typedef priv::Vector4<bool> Bvec4; 0188 typedef priv::Matrix<3, 3> Mat3; 0189 typedef priv::Matrix<4, 4> Mat4; 0190 0191 #endif // SFML_DOXYGEN 0192 0193 } // namespace Glsl 0194 } // namespace sf 0195 0196 #endif // SFML_GLSL_HPP 0197 0198 0199 //////////////////////////////////////////////////////////// 0200 /// \namespace sf::Glsl 0201 /// \ingroup graphics 0202 /// 0203 /// \details The sf::Glsl namespace contains types that match 0204 /// their equivalents in GLSL, the OpenGL shading language. 0205 /// These types are exclusively used by the sf::Shader class. 0206 /// 0207 /// Types that already exist in SFML, such as \ref sf::Vector2<T> 0208 /// and \ref sf::Vector3<T>, are reused as typedefs, so you can use 0209 /// the types in this namespace as well as the original ones. 0210 /// Others are newly defined, such as Glsl::Vec4 or Glsl::Mat3. Their 0211 /// actual type is an implementation detail and should not be used. 0212 /// 0213 /// All vector types support a default constructor that 0214 /// initializes every component to zero, in addition to a 0215 /// constructor with one parameter for each component. 0216 /// The components are stored in member variables called 0217 /// x, y, z, and w. 0218 /// 0219 /// All matrix types support a constructor with a float* 0220 /// parameter that points to a float array of the appropriate 0221 /// size (that is, 9 in a 3x3 matrix, 16 in a 4x4 matrix). 0222 /// Furthermore, they can be converted from sf::Transform 0223 /// objects. 0224 /// 0225 /// \see sf::Shader 0226 /// 0227 ////////////////////////////////////////////////////////////
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|