Onsens  1.0
This is C++ game about bitwise logic.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Glsl.inl
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
30void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<3, 3>& dest);
31void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<4, 4>& dest);
32
40void SFML_GRAPHICS_API copyMatrix(const float* source, std::size_t elements, float* dest);
41
46void SFML_GRAPHICS_API copyVector(const Color& source, Vector4<float>& dest);
47void SFML_GRAPHICS_API copyVector(const Color& source, Vector4<int>& dest);
48
49
54template <std::size_t Columns, std::size_t Rows>
55struct Matrix
56{
65 explicit Matrix(const float* pointer)
66 {
67 copyMatrix(pointer, Columns * Rows, array);
68 }
69
79 Matrix(const Transform& transform)
80 {
81 copyMatrix(transform, *this);
82 }
83
84 float array[Columns * Rows];
85};
86
91template <typename T>
92struct Vector4
93{
99 x(0),
100 y(0),
101 z(0),
102 w(0)
103 {
104 }
105
115 Vector4(T X, T Y, T Z, T W) :
116 x(X),
117 y(Y),
118 z(Z),
119 w(W)
120 {
121 }
122
129 template <typename U>
130 explicit Vector4(const Vector4<U>& other) :
131 x(static_cast<T>(other.x)),
132 y(static_cast<T>(other.y)),
133 z(static_cast<T>(other.z)),
134 w(static_cast<T>(other.w))
135 {
136 }
137
145 Vector4(const Color& color)
146 // uninitialized
147 {
148 copyVector(color, *this);
149 }
150
151 T x;
152 T y;
153 T z;
154 T w;
155};
void SFML_GRAPHICS_API copyMatrix(const Transform &source, Matrix< 3, 3 > &dest)
Helper functions to copy sf::Transform to sf::Glsl::Mat3/4.
void SFML_GRAPHICS_API copyVector(const Color &source, Vector4< float > &dest)
Helper functions to copy sf::Color to sf::Glsl::Vec4/Ivec4.
#define SFML_GRAPHICS_API
Matrix type, used to set uniforms in GLSL.
Definition: Glsl.inl:56
float array[Columns *Rows]
Array holding matrix data.
Definition: Glsl.inl:84
Matrix(const Transform &transform)
Construct implicitly from SFML transform.
Definition: Glsl.inl:79
Matrix(const float *pointer)
Construct from raw data.
Definition: Glsl.inl:65
4D vector type, used to set uniforms in GLSL
Definition: Glsl.inl:93
T x
1st component (X) of the 4D vector
Definition: Glsl.inl:151
T z
3rd component (Z) of the 4D vector
Definition: Glsl.inl:153
Vector4(const Vector4< U > &other)
Conversion constructor.
Definition: Glsl.inl:130
T w
4th component (W) of the 4D vector
Definition: Glsl.inl:154
T y
2nd component (Y) of the 4D vector
Definition: Glsl.inl:152
Vector4(T X, T Y, T Z, T W)
Construct from 4 vector components.
Definition: Glsl.inl:115
Vector4(const Color &color)
Construct float vector implicitly from color.
Definition: Glsl.inl:145
Vector4()
Default constructor, creates a zero vector.
Definition: Glsl.inl:98