Skip to content

Commit 8664091

Browse files
committed
text: made render function non static
1 parent e670f85 commit 8664091

File tree

13 files changed

+96
-96
lines changed

13 files changed

+96
-96
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
**Brenta Engine** is a simple 3D graphics engine written in modern
44
C++/OpenGL using a hybrid scene-graph and Entity Component System
5-
architecture. The engine was created by Giovanni Santini in the summer
6-
of 2024, the name is inspired by the Brenta Dolimites in the Italian
7-
Alps.
5+
architecture.
86

9-
Check out [GUIDE.md](./docs/GUIDE.md) for a quick introduction on how
10-
the engine works, and [DESIGN.md](./docs/DESIGN.md) for an overview of
11-
the engine's internals.
7+
Check out [DESIGN.md](./docs/DESIGN.md) for an overview of
8+
the engine's architecture, and [GUIDE.md](./docs/GUIDE.md) for an
9+
introduction to its API.
1210

1311
<h2 align=center> Features </h2>
1412

TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- move sound to the asset manager and make it non-static
2+
- remove unnecessary setters and getters
23
- rework website

docs/DESIGN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
I could tell you that the Brenta engine was perfectly designed, with a
44
clear vision from its inception, with a beautiful and powerful API
55
that makes programming truly enjoyable. Except the fact that it would
6-
be a lie. It does not mean that I don't find the current design and
7-
API beautiful and fun - I think Brenta is a powerful engine - but its
6+
be a lie. I do not mean that I don't find the current design and API
7+
beautiful and fun - I think Brenta is a powerful engine - but its
88
development has been more iterative than meticulously designed. I
99
rewrote huge parts of the engine many many times, to the point where I
1010
am not scared to do big refactoring anymore - that is just routine -

docs/GUIDE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ and a `Window`. These are indeed subsystems. You can work with any
154154
class that implements the `Subsystem` interface by adding it to the
155155
`Engine` using `with(MyClass::Builder)`.
156156

157-
We then call `Engine::manager()` which will return an object (an
157+
We then call `Engine::managed()` which will return an object (an
158158
"engine manager") that will terminate the engine and all its
159159
subsystems when it goes out of scope. If you don't want to use this,
160160
you can initialize and terminate the engine manually:
@@ -171,7 +171,7 @@ engine.terminate();
171171

172172
Each subsystem can be configured through their builder, as we have
173173
already discussed. Like all other things, these usage of `Engine` is
174-
not mandatory, but it provides a nice way to do manage subsystems.
174+
not mandatory, but it provides a nice way to manage subsystems.
175175

176176
### Drivers
177177

@@ -182,8 +182,9 @@ example, playing audio can be done with several libraries such as
182182
including your favourite in the list). Some functionalities may even
183183
be OS-dependent such as waiting for files in the filesystem (inotify
184184
on Linux, iocp in Windows). To support multiple implementations
185-
("backends"), the engine often uses a `Driver` abstraction. A driver
186-
specifies an interface that can be implemented by different classes.
185+
("backends") of the same API, the engine often uses a `Driver`
186+
abstraction. A driver specifies an interface that can be implemented
187+
by different classes.
187188

188189
In practice, it looks like the following:
189190

docs/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
**Brenta Engine** is a simple 3D graphics engine written in modern
44
C++/OpenGL using a hybrid scene-graph and Entity Component System
5-
architecture. The engine was created by Giovanni Santini in the summer
6-
of 2024, the name is inspired by the Brenta Dolimites in the Italian
7-
Alps.
5+
architecture.
6+
7+
Check out [DESIGN.md](./DESIGN.md) for an overview of
8+
the engine's architecture, and [GUIDE.md](./GUIDE.md) for an
9+
introduction to its API.
810

911
<h2 align=center> Features </h2>
1012

examples/text.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ int main()
4141
//
4242

4343
auto font = Font("examples/assets/fonts/arial.ttf", 100);
44+
auto font_ptr =
45+
tenno::make_shared<Font>(tenno::move(font));
46+
Text hello = {
47+
"Hello OpenGL!",
48+
25.0f,
49+
25.0f,
50+
1.0f,
51+
Color::yellow(),
52+
font_ptr
53+
};
4454

4555
while (!Window::should_close())
4656
{
@@ -50,9 +60,7 @@ int main()
5060
Gl::set_color(Color::grey());
5161
Gl::clear();
5262

53-
Text::render("Hello OpenGL!",
54-
25.0f, 25.0f, 1.0f,
55-
Color::yellow(), font);
63+
hello.render();
5664

5765
Window::poll_events();
5866
Window::swap_buffers();

include/brenta/renderer/material.hpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,44 @@ class Material
3030
{
3131
public:
3232

33-
class Builder;
33+
class Builder
34+
{
35+
public:
36+
37+
Builder& shader(tenno::shared_ptr<Shader> shader);
38+
Builder& integer(const std::string &name, int val);
39+
Builder& floating(const std::string &name, float val);
40+
Builder& vector(const std::string &name, glm::vec3 val);
41+
Builder& texture(const std::string &name,
42+
tenno::shared_ptr<Texture> val, int index);
43+
44+
// Add path to be watched for hot-reloading
45+
Builder &watch(const std::filesystem::path &path);
46+
47+
Material build();
48+
tenno::vector<std::filesystem::path> get_watch_paths() const;
49+
50+
private:
51+
52+
tenno::shared_ptr<Shader> _shader;
53+
tenno::vector<std::pair<std::string, int>> ints;
54+
tenno::vector<std::pair<std::string, float>> floats;
55+
tenno::vector<std::pair<std::string, glm::vec3>> vectors;
56+
tenno::vector<std::pair<std::string,
57+
std::pair<int, tenno::shared_ptr<Texture>>>> textures;
58+
59+
};
3460

3561
tenno::shared_ptr<Shader> shader;
3662

3763
Material() = default;
3864
Material(tenno::shared_ptr<Shader> s) : shader(s) {}
3965
Material(Shader&& s);
4066
Material(Material&& other) = default;
67+
Material(Material::Builder& builder)
68+
{
69+
*this = builder.build();
70+
}
4171
Material &operator=(Material&& other) = default;
4272

4373
void apply();
@@ -58,32 +88,4 @@ class Material
5888

5989
};
6090

61-
class Material::Builder
62-
{
63-
public:
64-
65-
Builder& shader(tenno::shared_ptr<Shader> shader);
66-
Builder& integer(const std::string &name, int val);
67-
Builder& floating(const std::string &name, float val);
68-
Builder& vector(const std::string &name, glm::vec3 val);
69-
Builder& texture(const std::string &name,
70-
tenno::shared_ptr<Texture> val, int index);
71-
72-
// Add path to be watched for hot-reloading
73-
Builder &watch(const std::filesystem::path &path);
74-
75-
Material build();
76-
tenno::vector<std::filesystem::path> get_watch_paths() const;
77-
78-
private:
79-
80-
tenno::shared_ptr<Shader> _shader;
81-
tenno::vector<std::pair<std::string, int>> ints;
82-
tenno::vector<std::pair<std::string, float>> floats;
83-
tenno::vector<std::pair<std::string, glm::vec3>> vectors;
84-
tenno::vector<std::pair<std::string,
85-
std::pair<int, tenno::shared_ptr<Texture>>>> textures;
86-
87-
};
88-
8991
} // namespace brenta

include/brenta/text.hpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,8 @@ class Text
3434
: text(text), x(x), y(y), scale(scale), color(color), font(font)
3535
{}
3636
~Text() = default;
37-
38-
//
39-
// Static API
40-
//
4137

42-
static void render(const std::string &text,
43-
float x,
44-
float y,
45-
float scale,
46-
Color color,
47-
Font& font);
48-
static void render(const Text& text);
38+
void render();
4939

5040
};
5141

src/drivers/fswatcher_unix.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
#include <brenta/fswatcher.hpp>
99
#include <sys/inotify.h>
1010

11-
using namespace brenta;
12-
13-
#define _FSWATCHER_BUFFER_LEN (1024 * (sizeof(struct inotify_event) + 16))
11+
namespace brenta
12+
{
1413

1514
struct FsWatcherUnixWdList
1615
{
@@ -26,6 +25,12 @@ struct FsWatcherUnix
2625
FsWatcherUnixWdList *wd_list;
2726
};
2827

28+
} // namespace brenta
29+
30+
using namespace brenta;
31+
32+
#define _FSWATCHER_BUFFER_LEN (1024 * (sizeof(struct inotify_event) + 16))
33+
2934
FilesystemWatcher::~FilesystemWatcher()
3035
{
3136
this->destroy();

src/drivers/fswatcher_windows.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#define WIN32_LEAN_AND_MEAN
99
#include <windows.h>
1010

11+
namespace brenta
12+
{
13+
1114
struct FsWatcherWindowsDirList
1215
{
1316
HANDLE hDir;
@@ -25,6 +28,10 @@ struct FsWatcherWindows
2528
FsWatcherWindowsDirList *dir_list;
2629
};
2730

31+
} // namespace brenta
32+
33+
using namespace brenta;
34+
2835
FilesystemWatcher::~FilesystemWatcher()
2936
{
3037
this->destroy();

0 commit comments

Comments
 (0)