Gamedev Framework (gf)  0.19.0
A C++17 framework for 2D games
RenderStates.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2021 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 "GraphicsApi.h"
29 #include "Matrix.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_GRAPHICS_API RenderStates {
85  const BareTexture *texture [2] = { nullptr, nullptr };
86  Shader *shader = nullptr;
87  float lineWidth = 0.0f;
88  };
89 
97  inline
98  bool operator==(const RenderStates& lhs, const RenderStates& rhs) {
99  return lhs.mode == rhs.mode && lhs.transform == rhs.transform && lhs.texture == rhs.texture && lhs.shader == rhs.shader;
100  }
101 
102 #ifndef DOXYGEN_SHOULD_SKIP_THIS
103 }
104 #endif
105 }
106 
107 #endif // GF_RENDER_STATES_H
BlendMode mode
The blending mode.
Definition: RenderStates.h:83
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.h:82
const BareTexture * texture[2]
The texture.
Definition: RenderStates.h:85
bool operator==(const RenderStates &lhs, const RenderStates &rhs)
Check render states equality.
Definition: RenderStates.h:98
An OpenGL vertex and/or fragment shader.
Definition: Shader.h:119
constexpr BlendMode BlendAlpha
Alpha blend mode.
Definition: Blend.h:211
constexpr Matrix3f identityTransform()
Identity transform.
Definition: Transform.h:349
constexpr Vector2f transform(const Matrix3f &mat, Vector2f point)
Apply an affine transformation to a 2D point.
Definition: Transform.h:326
The namespace for gf classes.
Definition: Action.h:35
An image that lives in the graphic memory that can be used for drawing.
Definition: Texture.h:79
Matrix3f transform
The transform matrix.
Definition: RenderStates.h:84
Blending modes for drawing.
Definition: Blend.h:126
Shader * shader
The shader.
Definition: RenderStates.h:86