Skip to content

Commit 71192bf

Browse files
committed
stuff
1 parent 005d182 commit 71192bf

File tree

2 files changed

+37
-31
lines changed

2 files changed

+37
-31
lines changed

src/ruis/render/opengl/context.cpp

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -72,46 +72,52 @@ void GLAPIENTRY opengl_error_callback(
7272
} // namespace
7373
#endif
7474

75-
context::context() :
75+
context::context(utki::shared_ref<ruis::native_window> native_window) :
7676
ruis::render::context(
77-
{.initial_matrix = ruis::matrix4()
78-
// OpenGL identity matrix:
79-
// viewport edges: left = -1, right = 1, top = 1, bottom = -1
80-
// z-axis towards viewer
81-
.set_identity()
82-
// x-axis right, y-axis down, z-axis away
83-
.scale(1, -1, -1)
84-
// viewport edges: left = 0, top = 0
85-
.translate(-1, -1)
86-
// viewport edges: right = 1, bottom = 1
87-
.scale(2, 2)}
77+
std::move(native_window),
78+
// clang-format off
79+
{
80+
.initial_matrix = ruis::matrix4()
81+
// OpenGL identity matrix:
82+
// viewport edges: left = -1, right = 1, top = 1, bottom = -1
83+
// z-axis towards viewer
84+
.set_identity()
85+
// x-axis right, y-axis down, z-axis away
86+
.scale(1, -1, -1)
87+
// viewport edges: left = 0, top = 0
88+
.translate(-1, -1)
89+
// viewport edges: right = 1, bottom = 1
90+
.scale(2, 2)
91+
} // clang-format on
8892
)
8993
{
90-
LOG([](auto& o) {
91-
o << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
92-
})
94+
this->apply([&]() {
95+
utki::log_debug([](auto& o) {
96+
o << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
97+
});
9398

94-
// On some platforms the default framebuffer is not 0, so because of this
95-
// check if default framebuffer value is saved or not everytime some
96-
// framebuffer is going to be bound and save the value if needed.
99+
// On some platforms the default framebuffer is not 0, so because of this
100+
// check if default framebuffer value is saved or not everytime some
101+
// framebuffer is going to be bound and save the value if needed.
97102

98-
// the old_fb variable is initialized via output argument, so no need to initialize
99-
// it here
103+
// the old_fb variable is initialized via output argument, so no need to initialize
104+
// it here
100105

101-
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
102-
GLint old_fb;
103-
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fb);
104-
LOG([&](auto& o) {
105-
o << "old_fb = " << old_fb << std::endl;
106-
})
107-
this->default_framebuffer = GLuint(old_fb);
106+
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
107+
GLint old_fb;
108+
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fb);
109+
utki::log_debug([&](auto& o) {
110+
o << "old_fb = " << old_fb << std::endl;
111+
});
112+
this->default_framebuffer = GLuint(old_fb);
108113

109114
#ifdef DEBUG
110-
glEnable(GL_DEBUG_OUTPUT);
111-
glDebugMessageCallback(opengl_error_callback, nullptr);
115+
glEnable(GL_DEBUG_OUTPUT);
116+
glDebugMessageCallback(opengl_error_callback, nullptr);
112117
#endif
113118

114-
glEnable(GL_CULL_FACE);
119+
glEnable(GL_CULL_FACE);
120+
});
115121
}
116122

117123
utki::shared_ref<ruis::render::context::shaders> context::make_shaders()

src/ruis/render/opengl/context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class context : public ruis::render::context
3232
GLuint default_framebuffer;
3333

3434
public:
35-
context();
35+
context(utki::shared_ref<ruis::native_window> native_window);
3636

3737
// ===============================
3838
// ====== factory functions ======

0 commit comments

Comments
 (0)