Documentation de SFML 2.5.1

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
sf::Glsl Namespace Reference

Namespace with GLSL types. More...

Typedefs

typedef Vector2< float > Vec2
 2D float vector (vec2 in GLSL) More...
 
typedef Vector2< int > Ivec2
 2D int vector (ivec2 in GLSL) More...
 
typedef Vector2< bool > Bvec2
 2D bool vector (bvec2 in GLSL) More...
 
typedef Vector3< float > Vec3
 3D float vector (vec3 in GLSL) More...
 
typedef Vector3< int > Ivec3
 3D int vector (ivec3 in GLSL) More...
 
typedef Vector3< bool > Bvec3
 3D bool vector (bvec3 in GLSL) More...
 
typedef implementation defined Vec4
 4D float vector (vec4 in GLSL) More...
 
typedef implementation defined Ivec4
 4D int vector (ivec4 in GLSL) More...
 
typedef implementation defined Bvec4
 4D bool vector (bvec4 in GLSL) More...
 
typedef implementation defined Mat3
 3x3 float matrix (mat3 in GLSL) More...
 
typedef implementation defined Mat4
 4x4 float matrix (mat4 in GLSL) More...
 

Detailed Description

Namespace with GLSL types.

The sf::Glsl namespace contains types that match their equivalents in GLSL, the OpenGL shading language. These types are exclusively used by the sf::Shader class.

Types that already exist in SFML, such as sf::Vector2<T> and sf::Vector3<T>, are reused as typedefs, so you can use the types in this namespace as well as the original ones. Others are newly defined, such as Glsl::Vec4 or Glsl::Mat3. Their actual type is an implementation detail and should not be used.

All vector types support a default constructor that initializes every component to zero, in addition to a constructor with one parameter for each component. The components are stored in member variables called x, y, z, and w.

All matrix types support a constructor with a float* parameter that points to a float array of the appropriate size (that is, 9 in a 3x3 matrix, 16 in a 4x4 matrix). Furthermore, they can be converted from sf::Transform objects.

See also
sf::Shader

Typedef Documentation

◆ Bvec2

typedef Vector2<bool> sf::Glsl::Bvec2

2D bool vector (bvec2 in GLSL)

Definition at line 76 of file Glsl.hpp.

◆ Bvec3

typedef Vector3<bool> sf::Glsl::Bvec3

3D bool vector (bvec3 in GLSL)

Definition at line 94 of file Glsl.hpp.

◆ Bvec4

typedef implementation defined sf::Glsl::Bvec4

4D bool vector (bvec4 in GLSL)

Definition at line 130 of file Glsl.hpp.

◆ Ivec2

typedef Vector2<int> sf::Glsl::Ivec2

2D int vector (ivec2 in GLSL)

Definition at line 70 of file Glsl.hpp.

◆ Ivec3

typedef Vector3<int> sf::Glsl::Ivec3

3D int vector (ivec3 in GLSL)

Definition at line 88 of file Glsl.hpp.

◆ Ivec4

typedef implementation defined sf::Glsl::Ivec4

4D int vector (ivec4 in GLSL)

4D int vectors can be implicitly converted from sf::Color instances. Each color channel remains unchanged inside the integer interval [0, 255].

sf::Glsl::Ivec4 zeroVector;
sf::Glsl::Ivec4 vector(1, 2, 3, 4);

Definition at line 124 of file Glsl.hpp.

◆ Mat3

typedef implementation defined sf::Glsl::Mat3

3x3 float matrix (mat3 in GLSL)

The matrix can be constructed from an array with 3x3 elements, aligned in column-major order. For example, a translation by (x, y) looks as follows:

float array[9] =
{
1, 0, 0,
0, 1, 0,
x, y, 1
};
sf::Glsl::Mat3 matrix(array);

Mat3 can also be implicitly converted from sf::Transform:

sf::Transform transform;
sf::Glsl::Mat3 matrix = transform;

Definition at line 155 of file Glsl.hpp.

◆ Mat4

typedef implementation defined sf::Glsl::Mat4

4x4 float matrix (mat4 in GLSL)

The matrix can be constructed from an array with 4x4 elements, aligned in column-major order. For example, a translation by (x, y, z) looks as follows:

float array[16] =
{
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
x, y, z, 1
};
sf::Glsl::Mat4 matrix(array);

Mat4 can also be implicitly converted from sf::Transform:

sf::Transform transform;
sf::Glsl::Mat4 matrix = transform;

Definition at line 181 of file Glsl.hpp.

◆ Vec2

typedef Vector2<float> sf::Glsl::Vec2

2D float vector (vec2 in GLSL)

Definition at line 64 of file Glsl.hpp.

◆ Vec3

typedef Vector3<float> sf::Glsl::Vec3

3D float vector (vec3 in GLSL)

Definition at line 82 of file Glsl.hpp.

◆ Vec4

typedef implementation defined sf::Glsl::Vec4

4D float vector (vec4 in GLSL)

4D float vectors can be implicitly converted from sf::Color instances. Each color channel is normalized from integers in [0, 255] to floating point values in [0, 1].

sf::Glsl::Vec4 zeroVector;
sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f);

Definition at line 110 of file Glsl.hpp.