Gamedev Framework (gf)  0.7.0
A C++14 framework for 2D games
RenderStates.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * 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
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  *
21  * Part of this file comes from SFML, with the same license:
22  * Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
23  */
24 #ifndef GF_RENDER_STATES_H
25 #define GF_RENDER_STATES_H
26 
27 #include "Blend.h"
28 #include "Matrix.h"
29 #include "Portability.h"
30 #include "Transform.h"
31 
32 namespace gf {
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 inline namespace v1 {
35 #endif
36 
37  class BareTexture;
38  class Shader;
39 
82  struct GF_API RenderStates {
85  const BareTexture *texture = nullptr;
86  Shader *shader = nullptr;
87  float lineWidth = 0.0f;
88  };
89 
98  inline
99  bool operator==(const RenderStates& lhs, const RenderStates& rhs) {
100  return lhs.mode == rhs.mode && lhs.transform == rhs.transform && lhs.texture == rhs.texture && lhs.shader == rhs.shader;
101  }
102 
103 #ifndef DOXYGEN_SHOULD_SKIP_THIS
104 }
105 #endif
106 }
107 
108 #endif // GF_RENDER_STATES_H
constexpr Vector2f transform(const Matrix3f &mat, Vector2f point)
Apply an affine transformation to a 2D point.
Definition: Transform.h:331
BlendMode mode
The blending mode.
Definition: RenderStates.h:83
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.h:82
constexpr BlendMode BlendAlpha
Alpha blend mode.
Definition: Blend.h:217
An OpenGL vertex and/or fragment shader.
Definition: Shader.h:120
The namespace for gf classes.
Definition: Action.h:34
An image that lives in the graphic memory that can be used for drawing.
Definition: Texture.h:67
Matrix3f transform
The transform matrix.
Definition: RenderStates.h:84
Blending modes for drawing.
Definition: Blend.h:132
const BareTexture * texture
The texture.
Definition: RenderStates.h:85
bool operator==(const RenderStates &lhs, const RenderStates &rhs)
Check render states equality.
Definition: RenderStates.h:99
Shader * shader
The shader.
Definition: RenderStates.h:86
constexpr Matrix3f identityTransform()
Identity transform.
Definition: Transform.h:354