SFML 3.0.2
Loading...
Searching...
No Matches
Typedefs
sf::Glsl Namespace Reference
Graphics module

Namespace with GLSL types. More...

## Typedefs
using | Vec2 = Vector2<float>
| 2D float vector (`vec2` in GLSL)
using | Ivec2 = Vector2<int>
| 2D int vector (`ivec2` in GLSL)
using | Bvec2 = Vector2<bool>
| 2D bool vector (`bvec2` in GLSL)
using | Vec3 = Vector3<float>
| 3D float vector (`vec3` in GLSL)
using | Ivec3 = Vector3<int>
| 3D int vector (`ivec3` in GLSL)
using | Bvec3 = Vector3<bool>
| 3D bool vector (`bvec3` in GLSL)
using | Vec4 = ImplementationDefined
| 4D float vector (`vec4` in GLSL)
using | Ivec4 = ImplementationDefined
| 4D int vector (`ivec4` in GLSL)
using | Bvec4 = ImplementationDefined
| 4D bool vector (`bvec4` in GLSL)
using | Mat3 = ImplementationDefined
| 3x3 float matrix (`mat3` in GLSL)
using | Mat4 = ImplementationDefined
| 4x4 float matrix (`mat4` in GLSL)

## 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 type aliases, 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

using sf::Glsl::Bvec2 = Vector2<bool>

2D bool vector (`bvec2` in GLSL)

Definition at line 73 of file Glsl.hpp.

## ◆ Bvec3

using sf::Glsl::Bvec3 = Vector3<bool>

3D bool vector (`bvec3` in GLSL)

Definition at line 91 of file Glsl.hpp.

## ◆ Bvec4

using sf::Glsl::Bvec4 = ImplementationDefined

4D bool vector (`bvec4` in GLSL)

Definition at line 127 of file Glsl.hpp.

## ◆ Ivec2

using sf::Glsl::Ivec2 = Vector2<int>

2D int vector (`ivec2` in GLSL)

Definition at line 67 of file Glsl.hpp.

## ◆ Ivec3

using sf::Glsl::Ivec3 = Vector3<int>

3D int vector (`ivec3` in GLSL)

Definition at line 85 of file Glsl.hpp.

## ◆ Ivec4

using sf::Glsl::Ivec4 = ImplementationDefined

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);
sf::Glsl::Ivec4 color = sf::Color::Cyan;
sf::Color::Cyan
static const Color Cyan
Cyan predefined color.
Definition Color.hpp:89
sf::Glsl::Ivec4
ImplementationDefined Ivec4
4D int vector (ivec4 in GLSL)
Definition Glsl.hpp:121

Definition at line 121 of file Glsl.hpp.

## ◆ Mat3

using sf::Glsl::Mat3 = ImplementationDefined

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);
sf::Glsl::Mat3
ImplementationDefined Mat3
3x3 float matrix (mat3 in GLSL)
Definition Glsl.hpp:152

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

sf::Transform transform;
sf::Glsl::Mat3 matrix = transform;
sf::Transform
3x3 transform matrix
Definition Transform.hpp:48

Definition at line 152 of file Glsl.hpp.

## ◆ Mat4

using sf::Glsl::Mat4 = ImplementationDefined

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);
sf::Glsl::Mat4
ImplementationDefined Mat4
4x4 float matrix (mat4 in GLSL)
Definition Glsl.hpp:178

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

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

Definition at line 178 of file Glsl.hpp.

## ◆ Vec2

using sf::Glsl::Vec2 = Vector2<float>

2D float vector (`vec2` in GLSL)

Definition at line 61 of file Glsl.hpp.

## ◆ Vec3

using sf::Glsl::Vec3 = Vector3<float>

3D float vector (`vec3` in GLSL)

Definition at line 79 of file Glsl.hpp.

## ◆ Vec4

using sf::Glsl::Vec4 = ImplementationDefined

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);
sf::Glsl::Vec4 color = sf::Color::Cyan;
sf::Glsl::Vec4
ImplementationDefined Vec4
4D float vector (vec4 in GLSL)
Definition Glsl.hpp:107

Definition at line 107 of file Glsl.hpp.