Skip to content

Commit

Permalink
Tweak OpenGL renderer structure
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 9, 2024
1 parent 60ef604 commit 5dc8f8e
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 98 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@ add_subdirectory("source/zstd_compression")
add_subdirectory("source/yaml_format")
add_subdirectory("source/main")

if (TACTILE_BUILD_OPENGL_RENDERER MATCHES "ON")
add_subdirectory("source/opengl")

if (TACTILE_BUILD_TESTS MATCHES "ON")
add_subdirectory("source/opengl/test")
endif ()
if (TACTILE_BUILD_OPENGL_RENDERER)
add_subdirectory("source/opengl_renderer")
endif ()

if (TACTILE_BUILD_VULKAN_RENDERER)
Expand Down
43 changes: 0 additions & 43 deletions source/opengl/CMakeLists.txt

This file was deleted.

24 changes: 0 additions & 24 deletions source/opengl/test/CMakeLists.txt

This file was deleted.

7 changes: 7 additions & 0 deletions source/opengl_renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project(tactile-opengl-renderer CXX)

add_subdirectory("lib")

if (TACTILE_BUILD_TESTS)
add_subdirectory("test")
endif ()
46 changes: 46 additions & 0 deletions source/opengl_renderer/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
project(tactile-opengl-renderer-lib CXX)

add_library(tactile-opengl-renderer SHARED EXCLUDE_FROM_ALL)
add_library(tactile::opengl_renderer ALIAS tactile-opengl-renderer)

target_sources(tactile-opengl-renderer
PRIVATE
"${PROJECT_SOURCE_DIR}/inc/tactile/opengl_renderer/api.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/opengl_renderer/opengl_error.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/opengl_renderer/opengl_error.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/opengl_renderer/opengl_imgui.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/opengl_renderer/opengl_imgui.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/opengl_renderer/opengl_renderer.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/opengl_renderer/opengl_renderer.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/opengl_renderer/opengl_renderer_plugin.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/opengl_renderer/opengl_renderer_plugin.cpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/opengl_renderer/opengl_texture.hpp"
"${PROJECT_SOURCE_DIR}/src/tactile/opengl_renderer/opengl_texture.cpp"
)

tactile_prepare_target(tactile-opengl-renderer)

target_compile_definitions(tactile-opengl-renderer
PRIVATE
"TACTILE_BUILDING_OPENGL_RENDERER"
)

target_include_directories(tactile-opengl-renderer
PUBLIC
"${PROJECT_SOURCE_DIR}/inc"

SYSTEM PRIVATE
"${Stb_INCLUDE_DIR}"
)

target_link_libraries(tactile-opengl-renderer
PUBLIC
tactile::base
tactile::runtime

PRIVATE
OpenGL::GL
glad::glad
SDL2::SDL2
imgui::imgui
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "tactile/base/container/expected.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/opengl/api.hpp"
#include "tactile/opengl_renderer/api.hpp"

namespace tactile {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "tactile/base/container/expected.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/opengl/api.hpp"
#include "tactile/opengl_renderer/api.hpp"

struct SDL_Window;
struct ImGuiContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "tactile/base/container/smart_ptr.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/render/renderer.hpp"
#include "tactile/opengl/api.hpp"
#include "tactile/opengl_renderer/api.hpp"

namespace tactile {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "tactile/base/container/maybe.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/opengl/api.hpp"
#include "tactile/opengl/opengl_renderer.hpp"
#include "tactile/opengl_renderer/api.hpp"
#include "tactile/opengl_renderer/opengl_renderer.hpp"
#include "tactile/runtime/plugin.hpp"

namespace tactile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "tactile/base/int.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/base/render/texture.hpp"
#include "tactile/opengl/api.hpp"
#include "tactile/opengl_renderer/api.hpp"

namespace tactile {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_error.hpp"
#include "tactile/opengl_renderer/opengl_error.hpp"

#include <glad/glad.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (C) 2023 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_imgui.hpp"
#include "tactile/opengl_renderer/opengl_imgui.hpp"

#include <utility> // exchange

#include <imgui_impl_opengl3.h>
#include <imgui_impl_sdl2.h>

#include "tactile/opengl/opengl_error.hpp"
#include "tactile/opengl_renderer/opengl_error.hpp"

namespace tactile {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_renderer.hpp"
#include "tactile/opengl_renderer/opengl_renderer.hpp"

#include <cstdlib> // malloc, free
#include <list> // list
Expand All @@ -17,9 +17,9 @@
#include "tactile/base/container/maybe.hpp"
#include "tactile/base/container/smart_ptr.hpp"
#include "tactile/base/render/window.hpp"
#include "tactile/opengl/opengl_error.hpp"
#include "tactile/opengl/opengl_imgui.hpp"
#include "tactile/opengl/opengl_texture.hpp"
#include "tactile/opengl_renderer/opengl_error.hpp"
#include "tactile/opengl_renderer/opengl_imgui.hpp"
#include "tactile/opengl_renderer/opengl_texture.hpp"
#include "tactile/runtime/runtime.hpp"

namespace tactile {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_renderer_plugin.hpp"
#include "tactile/opengl_renderer/opengl_renderer_plugin.hpp"

#include <new> // nothrow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_texture.hpp"
#include "tactile/opengl_renderer/opengl_texture.hpp"

#define STB_IMAGE_IMPLEMENTATION

Expand All @@ -10,7 +10,7 @@
#include <glad/glad.h>
#include <stb_image.h>

#include "tactile/opengl/opengl_error.hpp"
#include "tactile/opengl_renderer/opengl_error.hpp"

namespace tactile {

Expand Down
24 changes: 24 additions & 0 deletions source/opengl_renderer/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
project(tactile-opengl-renderer-test CXX)

add_executable(tactile-opengl-renderer-test)

target_sources(tactile-opengl-renderer-test
PRIVATE
"${PROJECT_SOURCE_DIR}/src/main.cpp"
"${PROJECT_SOURCE_DIR}/src/opengl_error_test.cpp"
"${PROJECT_SOURCE_DIR}/src/opengl_renderer_test.cpp"
"${PROJECT_SOURCE_DIR}/src/opengl_texture_test.cpp"
)

tactile_prepare_target(tactile-opengl-renderer-test)

target_link_libraries(tactile-opengl-renderer-test
PUBLIC
tactile::opengl_renderer
GTest::gtest

PRIVATE
glad::glad
SDL2::SDL2
imgui::imgui
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_error.hpp"
#include "tactile/opengl_renderer/opengl_error.hpp"

#include <utility> // to_underlying

Expand All @@ -13,10 +13,14 @@ namespace tactile {
TEST(OpenGLError, MapOpenGLErrorCode)
{
EXPECT_EQ(map_opengl_error_code(GL_INVALID_ENUM), OpenGLError::kInvalidEnum);
EXPECT_EQ(map_opengl_error_code(GL_INVALID_VALUE), OpenGLError::kInvalidValue);
EXPECT_EQ(map_opengl_error_code(GL_INVALID_OPERATION), OpenGLError::kInvalidOperation);
EXPECT_EQ(map_opengl_error_code(GL_STACK_OVERFLOW), OpenGLError::kStackOverflow);
EXPECT_EQ(map_opengl_error_code(GL_STACK_UNDERFLOW), OpenGLError::kStackUnderflow);
EXPECT_EQ(map_opengl_error_code(GL_INVALID_VALUE),
OpenGLError::kInvalidValue);
EXPECT_EQ(map_opengl_error_code(GL_INVALID_OPERATION),
OpenGLError::kInvalidOperation);
EXPECT_EQ(map_opengl_error_code(GL_STACK_OVERFLOW),
OpenGLError::kStackOverflow);
EXPECT_EQ(map_opengl_error_code(GL_STACK_UNDERFLOW),
OpenGLError::kStackUnderflow);
EXPECT_EQ(map_opengl_error_code(GL_OUT_OF_MEMORY), OpenGLError::kOutOfMemory);
EXPECT_EQ(map_opengl_error_code(GL_INVALID_FRAMEBUFFER_OPERATION),
OpenGLError::kInvalidFramebufferOperation);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_renderer.hpp"
#include "tactile/opengl_renderer/opengl_renderer.hpp"

#include <gtest/gtest.h>

#include "tactile/opengl/opengl_renderer_plugin.hpp"
#include "tactile/opengl_renderer/opengl_renderer_plugin.hpp"
#include "tactile/runtime/runtime.hpp"

namespace tactile {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/opengl/opengl_texture.hpp"
#include "tactile/opengl_renderer/opengl_texture.hpp"

#include <gtest/gtest.h>

#include "tactile/opengl/opengl_renderer_plugin.hpp"
#include "tactile/opengl_renderer/opengl_renderer_plugin.hpp"
#include "tactile/runtime/runtime.hpp"

namespace tactile {
Expand Down

0 comments on commit 5dc8f8e

Please sign in to comment.