Skip to content

Commit 1756937

Browse files
committed
stuff
1 parent c1a6376 commit 1756937

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

src/ruis/render/opengl/context.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2222
#include "context.hpp"
2323

2424
#include <utki/shared.hpp>
25+
#include <utki/config.hpp>
2526

2627
#include "shaders/shader_color.hpp"
2728
#include "shaders/shader_color_pos_lum.hpp"
@@ -56,6 +57,7 @@ using namespace ruis::render::opengl;
5657
// } // namespace
5758

5859
#ifdef DEBUG
60+
# if CFG_OS != CFG_OS_MACOSX
5961
namespace {
6062
void GLAPIENTRY opengl_error_callback(
6163
GLenum source,
@@ -70,6 +72,7 @@ void GLAPIENTRY opengl_error_callback(
7072
std::cout << "OpenGL" << (type == GL_DEBUG_TYPE_ERROR ? " ERROR" : "") << ": " << message << std::endl;
7173
}
7274
} // namespace
75+
# endif
7376
#endif
7477

7578
context::context(utki::shared_ref<ruis::render::native_window> native_window) :
@@ -107,16 +110,24 @@ context::context(utki::shared_ref<ruis::render::native_window> native_window) :
107110
GLint old_fb;
108111
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fb);
109112
utki::log_debug([&](auto& o) {
110-
o << "old_fb = " << old_fb << std::endl;
113+
o << "ruis::render::opengl::context::context(): old_fb = " << old_fb << std::endl;
111114
});
112115
this->default_framebuffer = GLuint(old_fb);
113116

114117
#ifdef DEBUG
118+
// glDebugMessageCallback() was introduced in OpenGL 4.3, Macos does not support this version
119+
# if CFG_OS != CFG_OS_MACOSX
120+
// utki::logcat_debug("ruis::render::opengl::context::context(): enable debug output", '\n');
115121
glEnable(GL_DEBUG_OUTPUT);
116-
glDebugMessageCallback(opengl_error_callback, nullptr);
122+
// utki::logcat_debug("ruis::render::opengl::context::context(): debug output enabled", '\n');
123+
glDebugMessageCallback(&opengl_error_callback, nullptr);
124+
// utki::logcat_debug("ruis::render::opengl::context::context(): debug message callback set", '\n');
125+
# endif
117126
#endif
118127

128+
// utki::logcat_debug("ruis::render::opengl::context::context(): enable face culling", '\n');
119129
glEnable(GL_CULL_FACE);
130+
// utki::logcat_debug("ruis::render::opengl::context::context(): face culling enabled", '\n');
120131
});
121132
}
122133

src/ruis/render/opengl/frame_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ frame_buffer::frame_buffer(
5959
assert_opengl_no_error();
6060

6161
if (this->color) {
62-
ASSERT(dynamic_cast<texture_2d*>(this->color.get()))
62+
utki::assert(dynamic_cast<texture_2d*>(this->color.get()), SL);
6363
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
6464
auto& tex = static_cast<texture_2d&>(*this->color);
6565

@@ -70,7 +70,7 @@ frame_buffer::frame_buffer(
7070
}
7171

7272
if (this->depth) {
73-
ASSERT(dynamic_cast<texture_depth*>(this->depth.get()))
73+
utki::assert(dynamic_cast<texture_depth*>(this->depth.get()), SL);
7474
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
7575
auto& tex = static_cast<texture_depth&>(*this->depth);
7676

src/ruis/render/opengl/opengl_texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ GLint opengl_texture::set_swizzeling(rasterimage::format f) const
5656
{
5757
switch (f) {
5858
default:
59-
ASSERT(false)
59+
utki::assert(false, SL);
6060
case rasterimage::format::grey:
6161
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
6262
assert_opengl_no_error();

src/ruis/render/opengl/texture_2d.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ texture_2d::texture_2d(
3737
dims
3838
)
3939
{
40-
ASSERT(data.size() % rasterimage::to_num_channels(type) == 0)
41-
ASSERT(data.size() % dims.x() == 0)
42-
ASSERT(data.size() == 0 || data.size() / rasterimage::to_num_channels(type) / dims.x() == dims.y())
40+
utki::assert(data.size() % rasterimage::to_num_channels(type) == 0, SL);
41+
utki::assert(data.size() % dims.x() == 0, SL);
42+
utki::assert(data.size() == 0 || data.size() / rasterimage::to_num_channels(type) / dims.x() == dims.y(), SL);
4343

4444
this->bind(0);
4545

src/ruis/render/opengl/util.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,34 @@ inline void assert_opengl_no_error()
3434
case GL_NO_ERROR:
3535
return;
3636
case GL_INVALID_ENUM:
37-
ASSERT(false, [](auto& o) {
37+
utki::assert(false, [](auto& o) {
3838
o << "OpenGL error: GL_INVALID_ENUM";
39-
})
39+
}, SL);
4040
break;
4141
case GL_INVALID_VALUE:
42-
ASSERT(false, [](auto& o) {
42+
utki::assert(false, [](auto& o) {
4343
o << "OpenGL error: GL_INVALID_VALUE";
44-
})
44+
}, SL);
4545
break;
4646
case GL_INVALID_OPERATION:
47-
ASSERT(false, [](auto& o) {
47+
utki::assert(false, [](auto& o) {
4848
o << "OpenGL error: GL_INVALID_OPERATION";
49-
})
49+
}, SL);
5050
break;
5151
case GL_INVALID_FRAMEBUFFER_OPERATION:
52-
ASSERT(false, [](auto& o) {
52+
utki::assert(false, [](auto& o) {
5353
o << "OpenGL error: GL_INVALID_FRAMEBUFFER_OPERATION";
54-
})
54+
}, SL);
5555
break;
5656
case GL_OUT_OF_MEMORY:
57-
// TODO: throw exception
58-
ASSERT(false, [](auto& o) {
57+
utki::assert(false, [](auto& o) {
5958
o << "OpenGL error: GL_OUT_OF_MEMORY";
60-
})
59+
}, SL);
6160
break;
6261
default:
63-
ASSERT(false, [&](auto& o) {
62+
utki::assert(false, [&](auto& o) {
6463
o << "Unknown OpenGL error, code = " << int(error);
65-
})
64+
}, SL);
6665
break;
6766
}
6867
#endif

0 commit comments

Comments
 (0)