From 10c773fce1854142fcc83c62c384900631381e64 Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Fri, 4 Feb 2022 13:01:26 -0500 Subject: [PATCH] Framebuffer update linux build working --- core.s | 1 + imgui.ini | 12 ++++++++++++ src/graphics/opengl/glGraphics.cpp | 18 ++++++++---------- src/internal_libs/utils/grid.h | 2 +- src/internal_libs/utils/opRes.cpp | 8 ++++---- src/internal_libs/utils/opRes.h | 2 +- src/run_modes/tester/CMakeLists.txt | 2 +- 7 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 core.s create mode 100644 imgui.ini diff --git a/core.s b/core.s new file mode 100644 index 0000000..20366cb --- /dev/null +++ b/core.s @@ -0,0 +1 @@ + .file "core.cpp" diff --git a/imgui.ini b/imgui.ini new file mode 100644 index 0000000..32877ae --- /dev/null +++ b/imgui.ini @@ -0,0 +1,12 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][Dear ImGui Demo] +Pos=708,10 +Size=550,680 +Collapsed=0 + +[Docking][Data] + diff --git a/src/graphics/opengl/glGraphics.cpp b/src/graphics/opengl/glGraphics.cpp index d3471da..98d04de 100644 --- a/src/graphics/opengl/glGraphics.cpp +++ b/src/graphics/opengl/glGraphics.cpp @@ -29,12 +29,13 @@ namespace lunarium void GLAPIENTRY MessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { + uint32_t level = LogLevel::OGL_DEBUG; if (type == GL_DEBUG_TYPE_ERROR) { - Logger::Log(LogCategory::GRAPHICS, LogLevel::ERROR, "OPENGL ERROR"); + level = LogLevel::ERROR; } - Logger::Log(LogCategory::GRAPHICS, LogLevel::OGL_DEBUG, + Logger::Log(LogCategory::GRAPHICS, level, "%s (type: %s, source: %s, severity: %s), message: %s", (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), OglGraphics::mDebugMsgSources[source].c_str(), @@ -151,17 +152,14 @@ namespace lunarium glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindTexture(GL_TEXTURE_2D, fb->Texture.GetGLTextureID()); - if (fb->Texture.GetFormat() == ImageFormat::RGBA) + GLenum format = GL_RGBA; + if (fb->Texture.GetFormat() == ImageFormat::RGB) { - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*)fb->Buffer); - Logger::Log(LogCategory::GRAPHICS, LogLevel::INFO, "RGBA ID: %d", mActiveFrameBuffer); - } - else if (fb->Texture.GetFormat() == ImageFormat::RGB) - { - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, (void*)fb->Buffer); - Logger::Log(LogCategory::GRAPHICS, LogLevel::INFO, "RGB ID: %d", mActiveFrameBuffer); + format = GL_RGB; } + glGetTexImage(GL_TEXTURE_2D, 0, format, GL_UNSIGNED_BYTE, (void*)fb->Buffer); + fb->Texture.SetData(fb->Buffer); return &fb->Texture; diff --git a/src/internal_libs/utils/grid.h b/src/internal_libs/utils/grid.h index 49d04f4..279fe07 100644 --- a/src/internal_libs/utils/grid.h +++ b/src/internal_libs/utils/grid.h @@ -89,4 +89,4 @@ namespace lunarium } } } -#endif GRID_H_ \ No newline at end of file +#endif // GRID_H_ \ No newline at end of file diff --git a/src/internal_libs/utils/opRes.cpp b/src/internal_libs/utils/opRes.cpp index f42c3f1..312c025 100644 --- a/src/internal_libs/utils/opRes.cpp +++ b/src/internal_libs/utils/opRes.cpp @@ -50,10 +50,10 @@ namespace lunarium return res.Type == ResultType::OK; } - // bool Failed(OpRes&& res) - // { - // return res.Type == ResultType::FAIL; - // } + bool Failed(OpRes&& res) + { + return res.Type == ResultType::FAIL; + } bool Failed(OpRes& res) { diff --git a/src/internal_libs/utils/opRes.h b/src/internal_libs/utils/opRes.h index 324e841..e4dbaa0 100644 --- a/src/internal_libs/utils/opRes.h +++ b/src/internal_libs/utils/opRes.h @@ -42,7 +42,7 @@ namespace lunarium bool IsOK(OpRes&& res); bool IsOK(OpRes& res); - //bool Failed(OpRes&& res); + bool Failed(OpRes&& res); bool Failed(OpRes& res); } diff --git a/src/run_modes/tester/CMakeLists.txt b/src/run_modes/tester/CMakeLists.txt index 8662eed..cc1e75a 100644 --- a/src/run_modes/tester/CMakeLists.txt +++ b/src/run_modes/tester/CMakeLists.txt @@ -10,4 +10,4 @@ target_include_directories(tester PUBLIC ../../../external/box2d/include ) -target_link_libraries(tester box2d) \ No newline at end of file +target_link_libraries(tester box2d utils) \ No newline at end of file