Move app render state mapping to renderer gl
This commit is contained in:
59
src/app.cpp
59
src/app.cpp
@@ -97,6 +97,11 @@ namespace {
|
||||
return static_cast<GLenum>(pp::renderer::gl::depth_test_state());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum scissor_test_state() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::scissor_test_state());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum program_point_size_state() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::program_point_size_state());
|
||||
@@ -132,6 +137,36 @@ namespace {
|
||||
return static_cast<GLint>(pp::renderer::gl::rgba8_internal_format());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum linear_texture_filter() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::linear_texture_filter());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum nearest_texture_filter() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::nearest_texture_filter());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum repeat_texture_wrap() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::repeat_texture_wrap());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLenum framebuffer_target() noexcept
|
||||
{
|
||||
return static_cast<GLenum>(pp::renderer::gl::framebuffer_target());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLuint default_framebuffer_id() noexcept
|
||||
{
|
||||
return static_cast<GLuint>(pp::renderer::gl::default_framebuffer_id());
|
||||
}
|
||||
|
||||
[[nodiscard]] GLbitfield framebuffer_color_buffer_mask() noexcept
|
||||
{
|
||||
return static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask());
|
||||
}
|
||||
|
||||
}
|
||||
std::thread App::render_thread;
|
||||
std::thread::id App::render_thread_id;
|
||||
@@ -256,7 +291,7 @@ bool App::request_close()
|
||||
void App::clear()
|
||||
{
|
||||
glClearColor(.1f, .1f, .1f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClear(framebuffer_color_buffer_mask());
|
||||
}
|
||||
|
||||
void App::initAssets()
|
||||
@@ -265,9 +300,9 @@ void App::initAssets()
|
||||
FontManager::init();
|
||||
|
||||
LOG("initializing assets create sampler");
|
||||
sampler.create(GL_NEAREST);
|
||||
sampler_stencil.create(GL_LINEAR, GL_REPEAT);
|
||||
sampler_linear.create(GL_LINEAR);
|
||||
sampler.create(nearest_texture_filter());
|
||||
sampler_stencil.create(linear_texture_filter(), repeat_texture_wrap());
|
||||
sampler_linear.create(linear_texture_filter());
|
||||
m_face_plane.create<1>(2, 2);
|
||||
sphere.create<8, 8>(1);
|
||||
LOG("initializing assets load uvs texture");
|
||||
@@ -587,7 +622,7 @@ void App::async_start()
|
||||
android_async_lock();
|
||||
#elif _WIN32
|
||||
async_lock();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
|
||||
#elif __LINUX__ || __WEB__
|
||||
glfwMakeContextCurrent(glfw_window);
|
||||
#endif
|
||||
@@ -686,13 +721,13 @@ void App::draw(float dt)
|
||||
uirtt.bindFramebuffer();
|
||||
uirtt.clear();
|
||||
glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight());
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glEnable(scissor_test_state());
|
||||
for (int i = 1; i < layout[main_id]->m_children.size(); i++)
|
||||
layout[main_id]->m_children[i]->watch(observer);
|
||||
for (int i = 0; layout_designer.get(main_id) && i < layout_designer[main_id]->m_children.size(); i++)
|
||||
layout_designer[main_id]->m_children[i]->watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(scissor_test_state());
|
||||
uirtt.unbindFramebuffer();
|
||||
}
|
||||
|
||||
@@ -701,16 +736,16 @@ void App::draw(float dt)
|
||||
#if __IOS__
|
||||
[ios_view->glview bindDrawable];
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
|
||||
#endif
|
||||
glViewport(off_x, off_y, (GLsizei)width, (GLsizei)height);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glEnable(scissor_test_state());
|
||||
for (int i = 0; i < layout[main_id]->m_children.size(); i++)
|
||||
layout[main_id]->m_children[i]->watch(observer);
|
||||
for (int i = 0; layout_designer.get(main_id) && i < layout_designer[main_id]->m_children.size(); i++)
|
||||
layout_designer[main_id]->m_children[i]->watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(scissor_test_state());
|
||||
}
|
||||
|
||||
redraw = false;
|
||||
@@ -1012,7 +1047,7 @@ void App::ui_thread_tick()
|
||||
update(0);
|
||||
render_task([this]
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
|
||||
clear();
|
||||
draw(0);
|
||||
async_swap();
|
||||
@@ -1114,7 +1149,7 @@ void App::ui_thread_main()
|
||||
update(t_frame);
|
||||
render_task([this, t_frame]
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
|
||||
clear();
|
||||
draw(t_frame);
|
||||
async_swap();
|
||||
|
||||
Reference in New Issue
Block a user