diff --git a/src/rtt.cpp b/src/rtt.cpp index 88aee87..d8e7cd7 100644 --- a/src/rtt.cpp +++ b/src/rtt.cpp @@ -222,6 +222,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format, void RTT::bindFramebuffer() { + assert(App::I->is_render_thread()); #ifdef _DEBUG if (bound) { @@ -240,6 +241,7 @@ void RTT::bindFramebuffer() void RTT::unbindFramebuffer() { + assert(App::I->is_render_thread()); if (!bound) return; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDFboID); @@ -251,12 +253,14 @@ void RTT::unbindFramebuffer() void RTT::clear(glm::vec4 color) { + assert(App::I->is_render_thread()); glClearColor(color.r, color.g, color.b, color.a); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void RTT::clear_mask(glm::bool4 mask, glm::vec4 color) { + assert(App::I->is_render_thread()); // save old state std::array old_mask; glGetBooleanv(GL_COLOR_WRITEMASK, old_mask.data()); @@ -331,11 +335,13 @@ float * RTT::createBufferFloat() void RTT::bindTexture() { + assert(App::I->is_render_thread()); glBindTexture(GL_TEXTURE_2D, texID); } void RTT::unbindTexture() { + assert(App::I->is_render_thread()); glBindTexture(GL_TEXTURE_2D, 0); } diff --git a/src/texture.cpp b/src/texture.cpp index 17e517c..f9719a8 100644 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -118,11 +118,13 @@ void Texture2D::destroy() void Texture2D::bind() const { + assert(App::I->is_render_thread()); glBindTexture(GL_TEXTURE_2D, m_tex); } void Texture2D::unbind() const { + assert(App::I->is_render_thread()); glBindTexture(GL_TEXTURE_2D, 0); } @@ -201,21 +203,17 @@ void Sampler::set_border(glm::vec4 rgba) } void Sampler::bind(int unit) const { - App::I->render_task([=] - { - current_unit = unit; + assert(App::I->is_render_thread()); + current_unit = unit; #if USE_SAMPLER - glBindSampler(unit, id); + glBindSampler(unit, id); #endif // USE_SAMPLER - }); } void Sampler::unbind() { - App::I->render_task([=] - { + assert(App::I->is_render_thread()); #if USE_SAMPLER - glBindSampler(current_unit, 0); + glBindSampler(current_unit, 0); #endif // USE_SAMPLER - }); }