Skip to content

Commit ea1f3ad

Browse files
author
beryll1um
committed
mod(application): layers container changed
1 parent f5e4381 commit ea1f3ad

File tree

11 files changed

+46
-43
lines changed

11 files changed

+46
-43
lines changed

examples/interfaces/interfaces.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,14 @@ class TriangleLayer : public Layer
2525
}
2626

2727
};
28+
2829
class ImGuiLayer : public Modules::ImGuiLayer
2930
{
3031
public:
3132

3233
Graphics::Vertex2d *triangle;
3334

34-
ImGuiLayer(Application *application, Graphics::Vertex2d *triangle) : triangle(triangle) {
35-
Create(application);
36-
}
37-
38-
virtual ~ImGuiLayer() {
39-
Destroy();
40-
}
35+
ImGuiLayer(Application *application, Graphics::Vertex2d *triangle) : triangle(triangle) { }
4136

4237
virtual void OnUpdate(Time) override {
4338
ImGui::Begin("ExampleInterfaces");
@@ -65,11 +60,18 @@ class ExampleInterfaces : public Application
6560
public:
6661

6762
ExampleInterfaces() : Application("ExampleInterfaces") {
68-
push_layer<TriangleLayer>(this, triangle);
63+
Modules::ImGuiLayer::Create(this);
64+
6965
push_layer<ImGuiLayer>(this, triangle);
66+
push_layer<TriangleLayer>(this, triangle);
67+
7068
set_frame_limit(60);
7169
}
7270

71+
virtual ~ExampleInterfaces() {
72+
Modules::ImGuiLayer::Destroy();
73+
}
74+
7375
virtual bool OnUpdate(Time) override {
7476
clear();
7577
update_layers();

examples/layers/layers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ class ExampleLayers : public Application
8787
public:
8888

8989
ExampleLayers() : Application("ExampleLayers") {
90-
push_layer<ExampleLayer1>(this);
91-
push_layer<ExampleLayer2>(this);
9290
push_layer<ExampleLayer3>(this);
91+
push_layer<ExampleLayer2>(this);
92+
push_layer<ExampleLayer1>(this);
9393
set_frame_limit(60);
9494
}
9595

include/unified/application/application.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# include <unified/core/clock.hpp>
88

99
# include <utility>
10-
# include <deque>
10+
# include <forward_list>
1111

1212
# define BIND_EVENT_FN(method, object) std::bind(method, object, std::placeholders::_1)
1313

@@ -37,7 +37,7 @@ class Application : public Window, public UNIFIED_GRAPHICS_NAMESPACE::RenderTarg
3737
template <class _layer, class... _args>
3838
_layer *push_layer(_args&&... args) {
3939
_layer *new_layer = new _layer(std::forward<_args>(args)...);
40-
_layers.push_back(dynamic_cast<Layer*>(new_layer));
40+
_layers.push_front(dynamic_cast<Layer*>(new_layer));
4141
return new_layer;
4242
}
4343

@@ -57,7 +57,7 @@ class Application : public Window, public UNIFIED_GRAPHICS_NAMESPACE::RenderTarg
5757
Clock _frame_clock;
5858
Time _frame_duration;
5959

60-
std::deque<Layer*> _layers;
60+
std::forward_list<Layer*> _layers;
6161

6262
};
6363

include/unified/core/math/matrix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
UNIFIED_BEGIN_NAMESPACE
1313

1414
template <class _type, u32 _rows, u32 _columns>
15-
class Matrix
15+
struct Matrix
1616
{
1717
public:
1818

include/unified/core/math/matrix_fwd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
UNIFIED_BEGIN_NAMESPACE
88

99
template <class _type, u32 _rows, u32 _columns>
10-
class Matrix;
10+
struct Matrix;
1111

1212
UNIFIED_END_NAMESPACE
1313

include/unified/core/math/point4.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ UNIFIED_BEGIN_NAMESPACE
99
template <class _type>
1010
struct Point<_type, 4>
1111
{
12-
_type x, y, z, w;
12+
_type x, y, z, w;
1313

1414
UNIFIED_CONSTEXPR Point() : x(_type()), y(_type()), z(_type()), w(_type()) { }
1515
UNIFIED_CONSTEXPR Point(_type xyzw) : x(xyzw), y(xyzw), z(xyzw), w(xyzw) { }

include/unified/graphics/2d/vertex.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,31 @@ UNIFIED_BEGIN_NAMESPACE
99
UNIFIED_GRAPHICS_BEGIN_NAMESPACE
1010

1111
template <class _type>
12-
struct Vertex<_type, 2> : public Point<_type, 2>
12+
struct Vertex<_type, 2>
1313
{
1414

15-
UNIFIED_CONSTEXPR Vertex() : Point<_type, 2>(), color(), texture() { }
15+
UNIFIED_CONSTEXPR Vertex() : point(), color(), texture() { }
1616

17-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point) : Point<_type, 2>(point), color(), texture() { }
17+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point) : point(point), color(), texture() { }
1818

19-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point, const Color &color) : Point<_type, 2>(point), color(color), texture() { }
19+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point, const Color &color) : point(point), color(color), texture() { }
2020

21-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point, const Point<_type, 2> &vertex) : Point<_type, 2>(point), color(), texture(vertex) { }
21+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point, const Point<_type, 2> &vertex) : point(point), color(), texture(vertex) { }
2222

23-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point, const Color &color, const Point<_type, 2> &vertex) : Point<_type, 2>(point), color(color), texture(vertex) { }
23+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 2> &point, const Color &color, const Point<_type, 2> &vertex) : point(point), color(color), texture(vertex) { }
2424

2525
UNIFIED_CONSTEXPR bool operator==(const Vertex &r) const {
26-
return this->x == r.x && this->y == r.y && this->color == r.color;
26+
return this->point == r.point && this->color == r.color && this->texture == r.texture;
2727
}
2828

2929
UNIFIED_CONSTEXPR bool operator!=(const Vertex &r) const {
3030
return !this->operator==(r);
3131
}
3232

33+
Point<_type, 2> point;
3334
Color color;
3435
Point<_type, 2> texture;
35-
36+
3637
};
3738

3839
typedef Vertex<unsigned, 2> Vertex2u;

include/unified/graphics/3d/vertex.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,31 @@ UNIFIED_BEGIN_NAMESPACE
99
UNIFIED_GRAPHICS_BEGIN_NAMESPACE
1010

1111
template <class _type>
12-
struct Vertex<_type, 3> : public Point<_type, 3>
12+
struct Vertex<_type, 3>
1313
{
1414

15-
UNIFIED_CONSTEXPR Vertex() : Point<_type, 3>(), color(), texture() { }
15+
UNIFIED_CONSTEXPR Vertex() : point(), color(), texture() { }
1616

17-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point) : Point<_type, 3>(point), color(), texture() { }
17+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point) : point(point), color(), texture() { }
1818

19-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point, const Color &color) : Point<_type, 3>(point), color(color), texture() { }
19+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point, const Color &color) : point(point), color(color), texture() { }
2020

21-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point, const Point<_type, 2> &vertex) : Point<_type, 3>(point), color(), texture(vertex) { }
21+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point, const Point<_type, 2> &vertex) : point(point), color(), texture(vertex) { }
2222

23-
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point, const Color &color, const Point<_type, 2> &vertex) : Point<_type, 3>(point), color(color), texture(vertex) { }
23+
UNIFIED_CONSTEXPR Vertex(const Point<_type, 3> &point, const Color &color, const Point<_type, 2> &vertex) : point(point), color(color), texture(vertex) { }
2424

2525
UNIFIED_CONSTEXPR bool operator==(const Vertex &r) const {
26-
return this->x == r.x && this->y == r.y && this->color == r.color;
26+
return this->point == r.point && this->color == r.color && this->texture == r.texture;
2727
}
2828

2929
UNIFIED_CONSTEXPR bool operator!=(const Vertex &r) const {
3030
return !this->operator==(r);
3131
}
3232

33+
Point<_type, 3> point;
3334
Color color;
3435
Point<_type, 2> texture;
35-
36+
3637
};
3738

3839
typedef Vertex<unsigned, 3> Vertex3u;

include/unified/graphics/color.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
UNIFIED_BEGIN_NAMESPACE
77
UNIFIED_GRAPHICS_BEGIN_NAMESPACE
88

9-
class Color
9+
struct Color
1010
{
1111
public:
1212

include/unified/graphics/render_target.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RenderTarget
1313

1414
RenderTarget();
1515

16-
void clear(const Color &color = Color(0, 0, 0, 1.f));
16+
void clear(const Color &color = Color(0.f, 0.f, 0.f, 1.f));
1717

1818
void draw(const Drawable &object) const;
1919

0 commit comments

Comments
 (0)