FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_quad.inl
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17namespace fge
18{
19
20constexpr Quad::Quad(Vector2f const& fillValue) :
21 _points{fillValue, fillValue, fillValue, fillValue}
22{}
23constexpr Quad::Quad(RectFloat const& rect) :
24 _points{Vector2f{rect._x, rect._y}, Vector2f{rect._x + rect._width, rect._y},
25 Vector2f{rect._x + rect._width, rect._y + rect._height}, Vector2f{rect._x, rect._y + rect._height}}
26{}
27constexpr Quad::Quad(Vector2f const& vec1, Vector2f const& vec2, Vector2f const& vec3, Vector2f const& vec4) :
28 _points{vec1, vec2, vec3, vec4}
29{}
30
31constexpr bool Quad::operator==(Quad const& right) const
32{
33 return _points[0] == right._points[0] && _points[1] == right._points[1] && _points[2] == right._points[2] &&
34 _points[3] == right._points[3];
35}
36constexpr bool Quad::operator!=(Quad const& right) const
37{
38 return !(*this == right);
39}
40
41constexpr fge::Vector2f const& Quad::operator[](std::size_t index) const
42{
43 return this->_points[index];
44}
45constexpr fge::Vector2f& Quad::operator[](std::size_t index)
46{
47 return this->_points[index];
48}
49
50constexpr void Quad::fill(Vector2f const& fillValue)
51{
52 this->_points[0] = fillValue;
53 this->_points[1] = fillValue;
54 this->_points[2] = fillValue;
55 this->_points[3] = fillValue;
56}
57
58constexpr fge::Quad operator*(glm::mat4 const& left, fge::Quad const& right)
59{
60 return {left * glm::vec4{right[0], 0.0f, 1.0f}, left * glm::vec4{right[1], 0.0f, 1.0f},
61 left * glm::vec4{right[2], 0.0f, 1.0f}, left * glm::vec4{right[3], 0.0f, 1.0f}};
62}
63
64} // namespace fge
Definition C_quad.hpp:29