diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Doxyfile | 2 | ||||
-rw-r--r-- | doc/architecture.markdown | 10 | ||||
-rw-r--r-- | src/blu_cat/com/command.cpp (renamed from src/blucat/command.cpp) | 0 | ||||
-rw-r--r-- | src/blu_cat/com/command.hpp (renamed from src/blucat/command.hpp) | 6 | ||||
-rw-r--r-- | src/blu_cat/com/job_queue.cpp (renamed from src/blucat/job_queue.cpp) | 5 | ||||
-rw-r--r-- | src/blu_cat/com/job_queue.hpp (renamed from src/blucat/job_queue.hpp) | 11 | ||||
-rw-r--r-- | src/blu_cat/com/worker.cpp (renamed from src/blucat/worker.cpp) | 5 | ||||
-rw-r--r-- | src/blu_cat/com/worker.hpp (renamed from src/blucat/worker.hpp) | 11 | ||||
-rw-r--r-- | src/blu_cat/gra/animation.cpp (renamed from src/blucat/animation.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/animation.hpp (renamed from src/blucat/animation.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/animation/frame.hpp (renamed from src/blucat/animation/frame.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/base_buffer.cpp (renamed from src/blucat/base_buffer.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/base_buffer.hpp (renamed from src/blucat/base_buffer.hpp) | 10 | ||||
-rw-r--r-- | src/blu_cat/gra/binary_reader.cpp (renamed from src/blucat/binary_reader.cpp) | 0 | ||||
-rw-r--r-- | src/blu_cat/gra/binary_reader.hpp (renamed from src/blucat/binary_reader.hpp) | 0 | ||||
-rw-r--r-- | src/blu_cat/gra/character.cpp (renamed from src/blucat/character.cpp) | 34 | ||||
-rw-r--r-- | src/blu_cat/gra/character.hpp (renamed from src/blucat/character.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/command_pool.cpp (renamed from src/blucat/command_pool.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/command_pool.hpp (renamed from src/blucat/command_pool.hpp) | 10 | ||||
-rw-r--r-- | src/blu_cat/gra/descriptor_set_layout.cpp (renamed from src/blucat/descriptor_set_layout.cpp) | 36 | ||||
-rw-r--r-- | src/blu_cat/gra/descriptor_set_layout.hpp (renamed from src/blucat/descriptor_set_layout.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/destination_buffer.cpp (renamed from src/blucat/destination_buffer.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/destination_buffer.hpp (renamed from src/blucat/destination_buffer.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/device.cpp (renamed from src/blucat/device.cpp) | 13 | ||||
-rw-r--r-- | src/blu_cat/gra/device.hpp (renamed from src/blucat/device.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/font.cpp (renamed from src/blucat/font.cpp) | 7 | ||||
-rw-r--r-- | src/blu_cat/gra/font.hpp (renamed from src/blucat/font.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/framebuffer.cpp (renamed from src/blucat/framebuffer.cpp) | 76 | ||||
-rw-r--r-- | src/blu_cat/gra/framebuffer.hpp (renamed from src/blucat/framebuffer.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_solid.cpp (renamed from src/blucat/graphics_pipeline_2d_solid.cpp) | 30 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_solid.hpp (renamed from src/blucat/graphics_pipeline_2d_solid.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_solid_layout.cpp (renamed from src/blucat/graphics_pipeline_2d_solid_layout.cpp) | 18 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_solid_layout.hpp (renamed from src/blucat/graphics_pipeline_2d_solid_layout.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_wired.cpp (renamed from src/blucat/graphics_pipeline_2d_wired.cpp) | 42 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_wired.hpp (renamed from src/blucat/graphics_pipeline_2d_wired.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_wired_layout.cpp (renamed from src/blucat/graphics_pipeline_2d_wired_layout.cpp) | 20 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_wired_layout.hpp (renamed from src/blucat/graphics_pipeline_2d_wired_layout.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_3d.cpp (renamed from src/blucat/graphics_pipeline_3d.cpp) | 42 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_3d.hpp (renamed from src/blucat/graphics_pipeline_3d.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_3d_layout.cpp (renamed from src/blucat/graphics_pipeline_3d_layout.cpp) | 20 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_3d_layout.hpp (renamed from src/blucat/graphics_pipeline_3d_layout.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_3d_skeletal.cpp (renamed from src/blucat/graphics_pipeline_3d_skeletal.cpp) | 48 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_3d_skeletal.hpp (renamed from src/blucat/graphics_pipeline_3d_skeletal.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_sprite_3d.cpp (renamed from src/blucat/graphics_pipeline_sprite_3d.cpp) | 38 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_sprite_3d.hpp (renamed from src/blucat/graphics_pipeline_sprite_3d.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/image.cpp (renamed from src/blucat/image.cpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/image.hpp (renamed from src/blucat/image.hpp) | 12 | ||||
-rw-r--r-- | src/blu_cat/gra/light.cpp (renamed from src/blucat/light.cpp) | 50 | ||||
-rw-r--r-- | src/blu_cat/gra/light.hpp (renamed from src/blucat/light.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/log.cpp (renamed from src/blucat/log.cpp) | 0 | ||||
-rw-r--r-- | src/blu_cat/gra/log.hpp (renamed from src/blucat/log.hpp) | 0 | ||||
-rw-r--r-- | src/blu_cat/gra/qoi.cpp (renamed from src/blucat/qoi.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/qoi.hpp (renamed from src/blucat/qoi.hpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/queue.cpp (renamed from src/blucat/queue.cpp) | 4 | ||||
-rw-r--r-- | src/blu_cat/gra/queue.hpp (renamed from src/blucat/queue.hpp) | 14 | ||||
-rw-r--r-- | src/blu_cat/gra/queue_family.cpp (renamed from src/blucat/queue_family.cpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/queue_family.hpp (renamed from src/blucat/queue_family.hpp) | 12 | ||||
-rw-r--r-- | src/blu_cat/gra/rectangle.cpp (renamed from src/blucat/rectangle.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/rectangle.hpp (renamed from src/blucat/rectangle.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/render_pass.cpp (renamed from src/blucat/render_pass.cpp) | 24 | ||||
-rw-r--r-- | src/blu_cat/gra/render_pass.hpp (renamed from src/blucat/render_pass.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/renderer.cpp (renamed from src/blucat/renderer.cpp) | 134 | ||||
-rw-r--r-- | src/blu_cat/gra/renderer.hpp (renamed from src/blucat/renderer.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/skeletal_mesh.cpp (renamed from src/blucat/skeletal_mesh.cpp) | 40 | ||||
-rw-r--r-- | src/blu_cat/gra/skeletal_mesh.hpp (renamed from src/blucat/skeletal_mesh.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/skeletal_mesh_vertex.hpp (renamed from src/blucat/skeletal_mesh_vertex.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/skeletal_model.cpp (renamed from src/blucat/skeletal_model.cpp) | 38 | ||||
-rw-r--r-- | src/blu_cat/gra/skeletal_model.hpp (renamed from src/blucat/skeletal_model.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/source_buffer.cpp (renamed from src/blucat/source_buffer.cpp) | 6 | ||||
-rw-r--r-- | src/blu_cat/gra/source_buffer.hpp (renamed from src/blucat/source_buffer.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/sprite.cpp (renamed from src/blucat/sprite.cpp) | 20 | ||||
-rw-r--r-- | src/blu_cat/gra/sprite.hpp (renamed from src/blucat/sprite.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/sprite_3d.cpp (renamed from src/blucat/sprite_3d.cpp) | 34 | ||||
-rw-r--r-- | src/blu_cat/gra/sprite_3d.hpp (renamed from src/blucat/sprite_3d.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/sprite_to_draw.cpp (renamed from src/blucat/sprite_to_draw.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/sprite_to_draw.hpp (renamed from src/blucat/sprite_to_draw.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/static_mesh.cpp (renamed from src/blucat/static_mesh.cpp) | 28 | ||||
-rw-r--r-- | src/blu_cat/gra/static_mesh.hpp (renamed from src/blucat/static_mesh.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/static_mesh_vertex.hpp (renamed from src/blucat/static_mesh_vertex.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/static_model.cpp (renamed from src/blucat/static_model.cpp) | 30 | ||||
-rw-r--r-- | src/blu_cat/gra/static_model.hpp (renamed from src/blucat/static_model.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/swapchain.cpp (renamed from src/blucat/swapchain.cpp) | 54 | ||||
-rw-r--r-- | src/blu_cat/gra/swapchain.hpp (renamed from src/blucat/swapchain.hpp) | 10 | ||||
-rw-r--r-- | src/blu_cat/gra/texture.cpp (renamed from src/blucat/texture.cpp) | 100 | ||||
-rw-r--r-- | src/blu_cat/gra/texture.hpp (renamed from src/blucat/texture.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/uniform_buffer.cpp (renamed from src/blucat/uniform_buffer.cpp) | 2 | ||||
-rw-r--r-- | src/blu_cat/gra/uniform_buffer.hpp (renamed from src/blucat/uniform_buffer.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/uniform_data_object.hpp (renamed from src/blucat/uniform_data_object.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/view_2d.cpp (renamed from src/blucat/view_2d.cpp) | 34 | ||||
-rw-r--r-- | src/blu_cat/gra/view_2d.hpp (renamed from src/blucat/view_2d.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/view_3d.cpp (renamed from src/blucat/view_3d.cpp) | 32 | ||||
-rw-r--r-- | src/blu_cat/gra/view_3d.hpp (renamed from src/blucat/view_3d.hpp) | 8 | ||||
-rw-r--r-- | src/blu_cat/gra/vulkan.hpp (renamed from src/blucat/vulkan.hpp) | 6 | ||||
-rw-r--r-- | src/blu_cat/int/core.cpp (renamed from src/blucat/core.cpp) | 126 | ||||
-rw-r--r-- | src/blu_cat/int/core.hpp | 123 | ||||
-rw-r--r-- | src/blucat/core.hpp | 118 | ||||
-rw-r--r-- | src/candy_gear/candy_gear.cpp (renamed from src/candy_gear.cpp) | 16 | ||||
-rw-r--r-- | src/candy_gear/candy_gear.hpp (renamed from src/candy_gear.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/core.cpp (renamed from src/core.cpp) | 48 | ||||
-rw-r--r-- | src/candy_gear/core.hpp (renamed from src/core.hpp) | 6 | ||||
-rw-r--r-- | src/candy_gear/font.cpp (renamed from src/font.cpp) | 12 | ||||
-rw-r--r-- | src/candy_gear/font.hpp (renamed from src/font.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/graphic.cpp (renamed from src/graphic.cpp) | 6 | ||||
-rw-r--r-- | src/candy_gear/graphic.hpp (renamed from src/graphic.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/key.cpp (renamed from src/key.cpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/key.hpp (renamed from src/key.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/main.cpp (renamed from src/main.cpp) | 10 | ||||
-rw-r--r-- | src/candy_gear/orientation_3d.cpp (renamed from src/orientation_3d.cpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/orientation_3d.hpp (renamed from src/orientation_3d.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/skeletal_mesh.cpp (renamed from src/skeletal_mesh.cpp) | 16 | ||||
-rw-r--r-- | src/candy_gear/skeletal_mesh.hpp (renamed from src/skeletal_mesh.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/skeletal_model.cpp (renamed from src/skeletal_model.cpp) | 32 | ||||
-rw-r--r-- | src/candy_gear/skeletal_model.hpp (renamed from src/skeletal_model.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/sound.cpp (renamed from src/sound.cpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/sound.hpp (renamed from src/sound.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/sprite.cpp (renamed from src/sprite.cpp) | 24 | ||||
-rw-r--r-- | src/candy_gear/sprite.hpp (renamed from src/sprite.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/sprite_3d.cpp (renamed from src/sprite_3d.cpp) | 22 | ||||
-rw-r--r-- | src/candy_gear/sprite_3d.hpp (renamed from src/sprite_3d.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/static_mesh.cpp (renamed from src/static_mesh.cpp) | 16 | ||||
-rw-r--r-- | src/candy_gear/static_mesh.hpp (renamed from src/static_mesh.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/static_model.cpp (renamed from src/static_model.cpp) | 34 | ||||
-rw-r--r-- | src/candy_gear/static_model.hpp (renamed from src/static_model.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/texture.cpp (renamed from src/texture.cpp) | 34 | ||||
-rw-r--r-- | src/candy_gear/texture.hpp (renamed from src/texture.hpp) | 2 | ||||
-rw-r--r-- | src/candy_gear/vector_3d.cpp (renamed from src/vector_3d.cpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/vector_3d.hpp (renamed from src/vector_3d.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/vector_4d.cpp (renamed from src/vector_4d.cpp) | 6 | ||||
-rw-r--r-- | src/candy_gear/vector_4d.hpp (renamed from src/vector_4d.hpp) | 0 | ||||
-rw-r--r-- | src/candy_gear/view_2d.cpp (renamed from src/view_2d.cpp) | 28 | ||||
-rw-r--r-- | src/candy_gear/view_2d.hpp (renamed from src/view_2d.hpp) | 4 | ||||
-rw-r--r-- | src/candy_gear/view_3d.cpp (renamed from src/view_3d.cpp) | 26 | ||||
-rw-r--r-- | src/candy_gear/view_3d.hpp (renamed from src/view_3d.hpp) | 0 |
134 files changed, 1119 insertions, 1086 deletions
@@ -1,6 +1,6 @@ -candy_gear -candy_gear.exe -doc +/candy_gear +/candy_gear.exe +/dox_doc pkg mruby-* @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = doc +OUTPUT_DIRECTORY = dox_doc # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and diff --git a/doc/architecture.markdown b/doc/architecture.markdown new file mode 100644 index 0000000..e63f23c --- /dev/null +++ b/doc/architecture.markdown @@ -0,0 +1,10 @@ +Architecture +============ + +This project is split into two parts BluCat and CandyGear. +BluCat is the C++ engine, and CandyGear is the mruby engine. +BluCat consists of a few modules: + +- COM: common code that other modules use. +- INT: integration of all modules. +- GRA: graphics module. diff --git a/src/blucat/command.cpp b/src/blu_cat/com/command.cpp index a1d3240..a1d3240 100644 --- a/src/blucat/command.cpp +++ b/src/blu_cat/com/command.cpp diff --git a/src/blucat/command.hpp b/src/blu_cat/com/command.hpp index 47552a5..5079c58 100644 --- a/src/blucat/command.hpp +++ b/src/blu_cat/com/command.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_COMMAND_CHAIN_H -#define CANDY_GEAR_COMMAND_CHAIN_H 1 +#ifndef BLU_CAT_COM_COMMAND_CHAIN_H +#define BLU_CAT_COM_COMMAND_CHAIN_H 1 #include <cstdint> #include <initializer_list> @@ -89,4 +89,4 @@ public: }; -#endif /* CANDY_GEAR_COMMAND_CHAIN_H */ +#endif /* BLU_CAT_COM_COMMAND_CHAIN_H */ diff --git a/src/blucat/job_queue.cpp b/src/blu_cat/com/job_queue.cpp index 49bf34f..beaf989 100644 --- a/src/blucat/job_queue.cpp +++ b/src/blu_cat/com/job_queue.cpp @@ -18,6 +18,9 @@ #include <chrono> +namespace BluCat::COM +{ + JobQueue::JobQueue(): jobs{}, _stop{false} @@ -59,3 +62,5 @@ JobQueue::pop() return Job{nullptr}; } } + +} diff --git a/src/blucat/job_queue.hpp b/src/blu_cat/com/job_queue.hpp index 2a7735b..856946d 100644 --- a/src/blucat/job_queue.hpp +++ b/src/blu_cat/com/job_queue.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_JOB_QUEUE_H -#define CANDY_GEAR_JOB_QUEUE_H 1 +#ifndef BLU_CAT_COM_JOB_QUEUE_H +#define BLU_CAT_COM_JOB_QUEUE_H 1 #include <atomic> #include <condition_variable> @@ -23,6 +23,9 @@ #include <functional> #include <mutex> +namespace BluCat::COM +{ + class Worker; typedef std::function<void(void)> Job; @@ -49,4 +52,6 @@ public: push(Job job); }; -#endif /* CANDY_GEAR_JOB_QUEUE_H */ +} + +#endif /* BLU_CAT_COM_JOB_QUEUE_H */ diff --git a/src/blucat/worker.cpp b/src/blu_cat/com/worker.cpp index bcf654e..847b571 100644 --- a/src/blucat/worker.cpp +++ b/src/blu_cat/com/worker.cpp @@ -18,6 +18,9 @@ #include <thread> +namespace BluCat::COM +{ + Worker::Worker(JobQueue *job_queue): job_queue{job_queue} { @@ -32,3 +35,5 @@ Worker::operator()() if(job) job(); } } + +} diff --git a/src/blucat/worker.hpp b/src/blu_cat/com/worker.hpp index 449e1b0..d74aa24 100644 --- a/src/blucat/worker.hpp +++ b/src/blu_cat/com/worker.hpp @@ -14,11 +14,14 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_WORKER_H -#define CANDY_GEAR_WORKER_H 1 +#ifndef BLU_CAT_COM_WORKER_H +#define BLU_CAT_COM_WORKER_H 1 #include "job_queue.hpp" +namespace BluCat::COM +{ + class Worker { JobQueue *job_queue; @@ -30,4 +33,6 @@ public: operator()(); }; -#endif /* CANDY_GEAR_WORKER_H */ +} + +#endif /* BLU_CAT_COM_WORKER_H */ diff --git a/src/blucat/animation.cpp b/src/blu_cat/gra/animation.cpp index b4daeef..dc2c281 100644 --- a/src/blucat/animation.cpp +++ b/src/blu_cat/gra/animation.cpp @@ -16,7 +16,7 @@ #include "animation.hpp" -namespace BluCat +namespace BluCat::GRA { Bone::Bone(glm::mat4 offset_matrix): diff --git a/src/blucat/animation.hpp b/src/blu_cat/gra/animation.hpp index b1ddd06..1275b48 100644 --- a/src/blucat/animation.hpp +++ b/src/blu_cat/gra/animation.hpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_ANIMATION_H -#define CANDY_GEAR_BLUCAT_ANIMATION_H 1 +#ifndef BLU_CAT_GRA_ANIMATION_H +#define BLU_CAT_GRA_ANIMATION_H 1 #include <vector> #include "vulkan.hpp" #include "animation/frame.hpp" -namespace BluCat +namespace BluCat::GRA { struct Bone @@ -48,4 +48,4 @@ struct Animation } -#endif /* CANDY_GEAR_BLUCAT_ANIMATION_H */ +#endif /* BLU_CAT_GRA_ANIMATION_H */ diff --git a/src/blucat/animation/frame.hpp b/src/blu_cat/gra/animation/frame.hpp index 663483d..b1ea913 100644 --- a/src/blucat/animation/frame.hpp +++ b/src/blu_cat/gra/animation/frame.hpp @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_FRAME_H -#define CANDY_GEAR_BLUCAT_FRAME_H 1 +#ifndef BLU_CAT_GRA_FRAME_H +#define BLU_CAT_GRA_FRAME_H 1 #include <vector> #include "../vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { template<typename T> @@ -82,4 +82,4 @@ struct Channel }; } -#endif /* CANDY_GEAR_BLUCAT_FRAME_H */ +#endif /* BLU_CAT_GRA_FRAME_H */ diff --git a/src/blucat/base_buffer.cpp b/src/blu_cat/gra/base_buffer.cpp index 762c89a..1add9fb 100644 --- a/src/blucat/base_buffer.cpp +++ b/src/blu_cat/gra/base_buffer.cpp @@ -16,7 +16,7 @@ #include "base_buffer.hpp" -namespace BluCat +namespace BluCat::GRA { const CommandChain BaseBuffer::loader{ diff --git a/src/blucat/base_buffer.hpp b/src/blu_cat/gra/base_buffer.hpp index cdc9f9c..cb4cdf8 100644 --- a/src/blucat/base_buffer.hpp +++ b/src/blu_cat/gra/base_buffer.hpp @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_BASE_BUFFER_H -#define CANDY_GEAR_BLUCAT_BASE_BUFFER_H 1 +#ifndef BLU_CAT_GRA_BASE_BUFFER_H +#define BLU_CAT_GRA_BASE_BUFFER_H 1 -#include "command.hpp" +#include "../com/command.hpp" #include "vulkan.hpp" #include "device.hpp" -namespace BluCat +namespace BluCat::GRA { class BaseBuffer @@ -53,4 +53,4 @@ class BaseBuffer } -#endif /* CANDY_GEAR_BLUCAT_BASE_BUFFER_H */ +#endif /* BLU_CAT_GRA_BASE_BUFFER_H */ diff --git a/src/blucat/binary_reader.cpp b/src/blu_cat/gra/binary_reader.cpp index 14fc39c..14fc39c 100644 --- a/src/blucat/binary_reader.cpp +++ b/src/blu_cat/gra/binary_reader.cpp diff --git a/src/blucat/binary_reader.hpp b/src/blu_cat/gra/binary_reader.hpp index 1995402..1995402 100644 --- a/src/blucat/binary_reader.hpp +++ b/src/blu_cat/gra/binary_reader.hpp diff --git a/src/blucat/character.cpp b/src/blu_cat/gra/character.cpp index 220295d..f0e7512 100644 --- a/src/blucat/character.cpp +++ b/src/blu_cat/gra/character.cpp @@ -16,8 +16,8 @@ #include "character.hpp" -#include "command.hpp" -#include "core.hpp" +#include "../com/command.hpp" +#include "../int/core.hpp" #include "font.hpp" #include "image.hpp" #include "source_buffer.hpp" @@ -27,16 +27,16 @@ namespace struct CharacterBuilder { - BluCat::Character *character; + BluCat::GRA::Character *character; FT_Face face; uint32_t character_code; CharacterBuilder( - BluCat::Character *character, FT_Face face, uint32_t character_code); + BluCat::GRA::Character *character, FT_Face face, uint32_t character_code); }; CharacterBuilder::CharacterBuilder( - BluCat::Character *character, FT_Face face, uint32_t character_code): + BluCat::GRA::Character *character, FT_Face face, uint32_t character_code): character{character}, face{face}, character_code{character_code} @@ -104,8 +104,8 @@ load_image(void *obj) } } - BluCat::SourceBuffer source_image_buffer{ - BluCat::core.vk_device_with_swapchain, source_image_raw.data(), + BluCat::GRA::SourceBuffer source_image_buffer{ + BluCat::INT::core.vk_device_with_swapchain, source_image_raw.data(), image_size}; { // Create Vulkan image. @@ -116,8 +116,8 @@ load_image(void *obj) vk_extent3d.height = self->face->glyph->bitmap.rows; vk_extent3d.depth = 1; - BluCat::Image::create( - BluCat::core.vk_device_with_swapchain, + BluCat::GRA::Image::create( + BluCat::INT::core.vk_device_with_swapchain, &self->character->image, &self->character->device_memory, VK_FORMAT_R8G8B8A8_UNORM, @@ -126,21 +126,21 @@ load_image(void *obj) VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); } - catch(BluCat::Image::Error error) + catch(BluCat::GRA::Image::Error error) { throw CommandError{error.what()}; } } { // Copy image from buffer into image. - auto queue_family{BluCat::core.vk_device_with_swapchain-> + auto queue_family{BluCat::INT::core.vk_device_with_swapchain-> get_queue_family_with_presentation()}; auto queue{queue_family->get_queue()}; - BluCat::CommandPool command_pool{queue_family, 1}; + BluCat::GRA::CommandPool command_pool{queue_family, 1}; VkCommandBuffer vk_command_buffer{command_pool.command_buffers[0]}; queue.submit_one_time_command(vk_command_buffer, [&](){ - BluCat::Image::move_image_state( + BluCat::GRA::Image::move_image_state( vk_command_buffer, self->character->image, VK_FORMAT_R8G8B8A8_UNORM, 0, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_HOST_BIT, @@ -162,7 +162,7 @@ load_image(void *obj) vk_command_buffer, source_image_buffer.buffer, self->character->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &image_copy); - BluCat::Image::move_image_state( + BluCat::GRA::Image::move_image_state( vk_command_buffer, self->character->image, VK_FORMAT_R8G8B8A8_UNORM, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -179,10 +179,10 @@ unload_image(void *obj) auto self = static_cast<CharacterBuilder*>(obj); vkDestroyImage( - BluCat::core.vk_device_with_swapchain->device, self->character->image, + BluCat::INT::core.vk_device_with_swapchain->device, self->character->image, nullptr); vkFreeMemory( - BluCat::core.vk_device_with_swapchain->device, + BluCat::INT::core.vk_device_with_swapchain->device, self->character->device_memory, nullptr); } @@ -192,7 +192,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Character::Character(FT_Face face, uint32_t character_code) diff --git a/src/blucat/character.hpp b/src/blu_cat/gra/character.hpp index 9d0829f..8968384 100644 --- a/src/blucat/character.hpp +++ b/src/blu_cat/gra/character.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_CHARACTER_H -#define CANDY_GEAR_BLUCAT_CHARACTER_H 1 +#ifndef BLU_CAT_GRA_CHARACTER_H +#define BLU_CAT_GRA_CHARACTER_H 1 #include <ft2build.h> #include FT_FREETYPE_H @@ -24,7 +24,7 @@ #include <vector> -namespace BluCat +namespace BluCat::GRA { struct Character @@ -46,4 +46,4 @@ struct Character } -#endif /* CANDY_GEAR_BLUCAT_CHARACTER_H */ +#endif /* BLU_CAT_GRA_CHARACTER_H */ diff --git a/src/blucat/command_pool.cpp b/src/blu_cat/gra/command_pool.cpp index 898d7ae..2602522 100644 --- a/src/blucat/command_pool.cpp +++ b/src/blu_cat/gra/command_pool.cpp @@ -16,7 +16,7 @@ #include "command_pool.hpp" -namespace BluCat +namespace BluCat::GRA { const CommandChain CommandPool::loader{ diff --git a/src/blucat/command_pool.hpp b/src/blu_cat/gra/command_pool.hpp index 92451d8..7487365 100644 --- a/src/blucat/command_pool.hpp +++ b/src/blu_cat/gra/command_pool.hpp @@ -14,16 +14,16 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_COMMAND_POOL_H -#define CANDY_GEAR_BLUCAT_COMMAND_POOL_H 1 +#ifndef BLU_CAT_GRA_COMMAND_POOL_H +#define BLU_CAT_GRA_COMMAND_POOL_H 1 #include <vector> -#include "command.hpp" +#include "../com/command.hpp" #include "device.hpp" #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { class CommandPool @@ -56,4 +56,4 @@ private: } -#endif /* CANDY_GEAR_BLUCAT_COMMAND_POOL_H */ +#endif /* BLU_CAT_GRA_COMMAND_POOL_H */ diff --git a/src/blucat/descriptor_set_layout.cpp b/src/blu_cat/gra/descriptor_set_layout.cpp index 7d32346..e1e8852 100644 --- a/src/blucat/descriptor_set_layout.cpp +++ b/src/blu_cat/gra/descriptor_set_layout.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" namespace { @@ -26,7 +26,7 @@ namespace void load_world(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); std::array<VkDescriptorSetLayoutBinding, 2> set_layouts{}; set_layouts[0].binding = 0; @@ -49,7 +49,7 @@ load_world(void *obj) layout_info.pBindings = set_layouts.data(); if(vkCreateDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, &layout_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &layout_info, nullptr, &self->world) != VK_SUCCESS) throw CommandError{ "Failed to create Vulkan descriptor set layout for world view."}; @@ -58,16 +58,16 @@ load_world(void *obj) void unload_world(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); vkDestroyDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, self->world, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->world, nullptr); } void load_view(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); std::array<VkDescriptorSetLayoutBinding, 1> layout_bindings{}; @@ -85,7 +85,7 @@ load_view(void *obj) layout_info.pBindings = layout_bindings.data(); if(vkCreateDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, &layout_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &layout_info, nullptr, &self->view) != VK_SUCCESS) throw CommandError{ "Failed to create Vulkan descriptor set layout for view."}; @@ -94,16 +94,16 @@ load_view(void *obj) void unload_view(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); vkDestroyDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, self->view, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->view, nullptr); } void load_texture(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); std::array<VkDescriptorSetLayoutBinding, 1> layout_bindings{}; @@ -122,7 +122,7 @@ load_texture(void *obj) layout_info.pBindings = layout_bindings.data(); if(vkCreateDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, &layout_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &layout_info, nullptr, &self->texture) != VK_SUCCESS) throw CommandError{ "Failed to create Vulkan descriptor set layout for textures."}; @@ -131,16 +131,16 @@ load_texture(void *obj) void unload_texture(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); vkDestroyDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, self->texture, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->texture, nullptr); } void load_model(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); std::array<VkDescriptorSetLayoutBinding, 1> layout_bindings; layout_bindings[0].binding = 0; @@ -157,7 +157,7 @@ load_model(void *obj) layout_info.pBindings = layout_bindings.data(); if(vkCreateDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, &layout_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &layout_info, nullptr, &self->model) != VK_SUCCESS) throw CommandError{ "Failed to create Vulkan descriptor set layout for model instance."}; @@ -166,10 +166,10 @@ load_model(void *obj) void unload_model(void *obj) { - auto self = static_cast<BluCat::DescriptorSetLayout*>(obj); + auto self = static_cast<BluCat::GRA::DescriptorSetLayout*>(obj); vkDestroyDescriptorSetLayout( - BluCat::core.vk_device_with_swapchain->device, self->model, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->model, nullptr); } const CommandChain loader{ @@ -181,7 +181,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { DescriptorSetLayout::DescriptorSetLayout() diff --git a/src/blucat/descriptor_set_layout.hpp b/src/blu_cat/gra/descriptor_set_layout.hpp index 0724e40..42003b9 100644 --- a/src/blucat/descriptor_set_layout.hpp +++ b/src/blu_cat/gra/descriptor_set_layout.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_DESCRIPTOR_SET_LAYOUT_H -#define CANDY_GEAR_BLUCAT_DESCRIPTOR_SET_LAYOUT_H 1 +#ifndef BLU_CAT_GRA_DESCRIPTOR_SET_LAYOUT_H +#define BLU_CAT_GRA_DESCRIPTOR_SET_LAYOUT_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct DescriptorSetLayout @@ -35,4 +35,4 @@ struct DescriptorSetLayout } -#endif /* CANDY_GEAR_BLUCAT_DESCRIPTOR_SET_LAYOUT_H */ +#endif /* BLU_CAT_GRA_DESCRIPTOR_SET_LAYOUT_H */ diff --git a/src/blucat/destination_buffer.cpp b/src/blu_cat/gra/destination_buffer.cpp index ea5f31e..3c53db4 100644 --- a/src/blucat/destination_buffer.cpp +++ b/src/blu_cat/gra/destination_buffer.cpp @@ -18,7 +18,7 @@ #include "command_pool.hpp" -namespace BluCat +namespace BluCat::GRA { DestinationBuffer::DestinationBuffer( diff --git a/src/blucat/destination_buffer.hpp b/src/blu_cat/gra/destination_buffer.hpp index 7f5fb4b..7df1e50 100644 --- a/src/blucat/destination_buffer.hpp +++ b/src/blu_cat/gra/destination_buffer.hpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_DESTINATION_BUFFER_H -#define CANDY_GEAR_BLUCAT_DESTINATION_BUFFER_H 1 +#ifndef BLU_CAT_GRA_DESTINATION_BUFFER_H +#define BLU_CAT_GRA_DESTINATION_BUFFER_H 1 #include "base_buffer.hpp" #include "vulkan.hpp" #include "source_buffer.hpp" #include "queue_family.hpp" -namespace BluCat +namespace BluCat::GRA { struct DestinationBuffer: public BaseBuffer @@ -51,4 +51,4 @@ struct DestinationBuffer: public BaseBuffer } -#endif /* CANDY_GEAR_BLUCAT_DESTINATION_BUFFER_H */ +#endif /* BLU_CAT_GRA_DESTINATION_BUFFER_H */ diff --git a/src/blucat/device.cpp b/src/blu_cat/gra/device.cpp index 8ce6d17..b2d114a 100644 --- a/src/blucat/device.cpp +++ b/src/blu_cat/gra/device.cpp @@ -23,7 +23,7 @@ #include <sstream> #endif -#include "core.hpp" +#include "../int/core.hpp" namespace { @@ -61,7 +61,7 @@ create_shader_module(VkDevice vk_device, const char *filename) } } -namespace BluCat +namespace BluCat::GRA { Device::Device(VkPhysicalDevice vk_physical_device, bool with_swapchain) @@ -98,7 +98,7 @@ Device::Device(VkPhysicalDevice vk_physical_device, bool with_swapchain) message << "Device ID: " << physical_properties.deviceID << std::endl; message << "Device type: " << physical_properties.deviceType << std::endl; - core.log.message(Log::Level::Trace, message.str()); + BluCat::INT::core.log.message(Log::Level::Trace, message.str()); #endif std::vector<VkDeviceQueueCreateInfo> device_queue_create_infos; @@ -300,7 +300,8 @@ Device::Device(VkPhysicalDevice vk_physical_device, bool with_swapchain) // Select families with presentation support. VkBool32 present_supported; vkGetPhysicalDeviceSurfaceSupportKHR( - vk_physical_device, i, core.window_surface, &present_supported); + vk_physical_device, i, BluCat::INT::core.window_surface, + &present_supported); if(present_supported) this->queue_families_with_presentation.push_back( &this->queue_families[i]); @@ -371,7 +372,7 @@ Device::get_queue_family_with_graphics() const */ std::uniform_int_distribution<std::size_t> random_distribution{ 0, this->queue_families_with_graphics.size() -1}; - auto random = random_distribution(random_number_generator); + auto random = random_distribution(INT::random_number_generator); return this->queue_families_with_graphics[0]; } @@ -385,7 +386,7 @@ Device::get_queue_family_with_presentation() const */ std::uniform_int_distribution<std::size_t> random_distribution{ 0, this->queue_families_with_presentation.size() -1}; - auto random = random_distribution(random_number_generator); + auto random = random_distribution(INT::random_number_generator); return this->queue_families_with_presentation[0]; } diff --git a/src/blucat/device.hpp b/src/blu_cat/gra/device.hpp index 61e87a4..fd53198 100644 --- a/src/blucat/device.hpp +++ b/src/blu_cat/gra/device.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_DEVICE_H -#define CANDY_GEAR_BLUCAT_DEVICE_H 1 +#ifndef BLU_CAT_GRA_DEVICE_H +#define BLU_CAT_GRA_DEVICE_H 1 #include <cstdlib> #include <vector> @@ -23,7 +23,7 @@ #include "vulkan.hpp" #include "queue_family.hpp" -namespace BluCat +namespace BluCat::GRA { struct Device @@ -66,4 +66,4 @@ public: } -#endif /* CANDY_GEAR_BLUCAT_DEVICE_H */ +#endif /* BLU_CAT_GRA_DEVICE_H */ diff --git a/src/blucat/font.cpp b/src/blu_cat/gra/font.cpp index 603dda1..a9c2074 100644 --- a/src/blucat/font.cpp +++ b/src/blu_cat/gra/font.cpp @@ -16,15 +16,16 @@ #include "font.hpp" -#include "core.hpp" +#include "../int/core.hpp" -namespace BluCat +namespace BluCat::GRA { Font::Font(const char* font_path, int font_size) { FT_Error error; - error = FT_New_Face(core.font_library, font_path, 0, &this->face); + error = FT_New_Face( + BluCat::INT::core.font_library, font_path, 0, &this->face); if(error == FT_Err_Unknown_File_Format) throw std::invalid_argument( "The font file could be opened and read, but it appears that its font " "format is unsupported."); diff --git a/src/blucat/font.hpp b/src/blu_cat/gra/font.hpp index 1b9be69..72ec6d3 100644 --- a/src/blucat/font.hpp +++ b/src/blu_cat/gra/font.hpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_FONT_H -#define CANDY_GEAR_BLUCAT_FONT_H 1 +#ifndef BLU_CAT_GRA_FONT_H +#define BLU_CAT_GRA_FONT_H 1 #include <memory> #include <unordered_map> #include "character.hpp" -namespace BluCat +namespace BluCat::GRA { struct Font @@ -39,4 +39,4 @@ struct Font } -#endif /* CANDY_GEAR_BLUCAT_FONT_H */ +#endif /* BLU_CAT_GRA_FONT_H */ diff --git a/src/blucat/framebuffer.cpp b/src/blu_cat/gra/framebuffer.cpp index c4d3230..e2d0b7c 100644 --- a/src/blucat/framebuffer.cpp +++ b/src/blu_cat/gra/framebuffer.cpp @@ -16,8 +16,8 @@ #include "framebuffer.hpp" -#include "command.hpp" -#include "core.hpp" +#include "../com/command.hpp" +#include "../int/core.hpp" #include "image.hpp" namespace @@ -25,17 +25,17 @@ namespace void load_depth_image(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); VkExtent3D extent3d{}; - extent3d.width = BluCat::core.display_width; - extent3d.height = BluCat::core.display_height; + extent3d.width = BluCat::INT::core.display_width; + extent3d.height = BluCat::INT::core.display_height; extent3d.depth = 1; try { - BluCat::Image::create( - BluCat::core.vk_device_with_swapchain, + BluCat::GRA::Image::create( + BluCat::INT::core.vk_device_with_swapchain, &self->depth_image, &self->depth_image_memory, VK_FORMAT_D32_SFLOAT, @@ -45,7 +45,7 @@ load_depth_image(void *obj) VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT ); } - catch(BluCat::Image::Error error) + catch(BluCat::GRA::Image::Error error) { std::string error_message{"Failed to create depth image → "}; error_message += error.what(); @@ -56,29 +56,29 @@ load_depth_image(void *obj) void unload_depth_image(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); vkDestroyImage( - BluCat::core.vk_device_with_swapchain->device, self->depth_image, + BluCat::INT::core.vk_device_with_swapchain->device, self->depth_image, nullptr); vkFreeMemory( - BluCat::core.vk_device_with_swapchain->device, + BluCat::INT::core.vk_device_with_swapchain->device, self->depth_image_memory, nullptr); } void load_depth_image_view(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); try { - BluCat::Image::create_view( - BluCat::core.vk_device_with_swapchain, &self->depth_image_view, + BluCat::GRA::Image::create_view( + BluCat::INT::core.vk_device_with_swapchain, &self->depth_image_view, self->depth_image, VK_FORMAT_D32_SFLOAT, VK_IMAGE_ASPECT_DEPTH_BIT); } - catch(BluCat::Image::Error error) + catch(BluCat::GRA::Image::Error error) { std::string error_message{"Failed to create depth image view → "}; error_message += error.what(); @@ -89,38 +89,38 @@ load_depth_image_view(void *obj) void unload_depth_image_view(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); vkDestroyImageView( - BluCat::core.vk_device_with_swapchain->device, self->depth_image_view, + BluCat::INT::core.vk_device_with_swapchain->device, self->depth_image_view, nullptr); } void load_3d(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); - self->pipeline_3d.resize(BluCat::core.vk_swapchain->images_count); - for (auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->pipeline_3d.resize(BluCat::INT::core.vk_swapchain->images_count); + for (auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) { std::array<VkImageView, 2> attachments = { - BluCat::core.vk_swapchain->image_views[i], + BluCat::INT::core.vk_swapchain->image_views[i], self->depth_image_view }; VkFramebufferCreateInfo framebuffer_info{}; framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = BluCat::core.vk_render_pass->pipeline_3d; + framebuffer_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_3d; framebuffer_info.attachmentCount = attachments.size(); framebuffer_info.pAttachments = attachments.data(); - framebuffer_info.width = BluCat::core.display_width; - framebuffer_info.height = BluCat::core.display_height; + framebuffer_info.width = BluCat::INT::core.display_width; + framebuffer_info.height = BluCat::INT::core.display_height; framebuffer_info.layers = 1; if(vkCreateFramebuffer( - BluCat::core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, &self->pipeline_3d[i]) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan Framebuffer."}; } @@ -129,36 +129,36 @@ load_3d(void *obj) void unload_3d(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); for(auto framebuffer: self->pipeline_3d) vkDestroyFramebuffer( - BluCat::core.vk_device_with_swapchain->device, framebuffer, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, framebuffer, nullptr); } void load_2d(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); - self->pipeline_2d.resize(BluCat::core.vk_swapchain->images_count); - for (auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->pipeline_2d.resize(BluCat::INT::core.vk_swapchain->images_count); + for (auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) { std::array<VkImageView, 1> attachments = { - BluCat::core.vk_swapchain->image_views[i] + BluCat::INT::core.vk_swapchain->image_views[i] }; VkFramebufferCreateInfo framebuffer_info{}; framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = BluCat::core.vk_render_pass->pipeline_2d; + framebuffer_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_2d; framebuffer_info.attachmentCount = attachments.size(); framebuffer_info.pAttachments = attachments.data(); - framebuffer_info.width = BluCat::core.display_width; - framebuffer_info.height = BluCat::core.display_height; + framebuffer_info.width = BluCat::INT::core.display_width; + framebuffer_info.height = BluCat::INT::core.display_height; framebuffer_info.layers = 1; if(vkCreateFramebuffer( - BluCat::core.vk_device_with_swapchain->device, &framebuffer_info, + BluCat::INT::core.vk_device_with_swapchain->device, &framebuffer_info, nullptr, &self->pipeline_2d[i]) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan Framebuffer."}; @@ -168,11 +168,11 @@ load_2d(void *obj) void unload_2d(void *obj) { - auto self = static_cast<BluCat::Framebuffer*>(obj); + auto self = static_cast<BluCat::GRA::Framebuffer*>(obj); for(auto framebuffer: self->pipeline_2d) vkDestroyFramebuffer( - BluCat::core.vk_device_with_swapchain->device, framebuffer, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, framebuffer, nullptr); } const CommandChain loader{ @@ -184,7 +184,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Framebuffer::Framebuffer() diff --git a/src/blucat/framebuffer.hpp b/src/blu_cat/gra/framebuffer.hpp index e9303f8..ddbf5c4 100644 --- a/src/blucat/framebuffer.hpp +++ b/src/blu_cat/gra/framebuffer.hpp @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_FRAMEBUFFER_H -#define CANDY_GEAR_BLUCAT_FRAMEBUFFER_H 1 +#ifndef BLU_CAT_GRA_FRAMEBUFFER_H +#define BLU_CAT_GRA_FRAMEBUFFER_H 1 #include <vector> #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct Framebuffer @@ -40,4 +40,4 @@ struct Framebuffer } -#endif /* CANDY_GEAR_BLUCAT_FRAMEBUFFER_H */ +#endif /* BLU_CAT_GRA_FRAMEBUFFER_H */ diff --git a/src/blucat/graphics_pipeline_2d_solid.cpp b/src/blu_cat/gra/graphics_pipeline_2d_solid.cpp index afd8a2e..7acca09 100644 --- a/src/blucat/graphics_pipeline_2d_solid.cpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_solid.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "sprite.hpp" #include "uniform_data_object.hpp" @@ -28,7 +28,7 @@ namespace void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DSolid*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DSolid*>(obj); VkPipelineShaderStageCreateInfo vert_shader_stage_info{}; vert_shader_stage_info.sType = @@ -37,7 +37,7 @@ load_pipeline(void *obj) vert_shader_stage_info.flags = 0; vert_shader_stage_info.stage = VK_SHADER_STAGE_VERTEX_BIT; vert_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->vert2d_solid_shader_module; + BluCat::INT::core.vk_device_with_swapchain->vert2d_solid_shader_module; vert_shader_stage_info.pName = "main"; vert_shader_stage_info.pSpecializationInfo = nullptr; @@ -48,7 +48,7 @@ load_pipeline(void *obj) frag_shader_stage_info.flags = 0; frag_shader_stage_info.stage = VK_SHADER_STAGE_FRAGMENT_BIT; frag_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->frag2d_solid_shader_module; + BluCat::INT::core.vk_device_with_swapchain->frag2d_solid_shader_module; frag_shader_stage_info.pName = "main"; frag_shader_stage_info.pSpecializationInfo = nullptr; @@ -91,14 +91,14 @@ load_pipeline(void *obj) VkViewport viewport = {}; viewport.x = 0; viewport.y = 0; - viewport.width = BluCat::core.display_width; - viewport.height = BluCat::core.display_height; + viewport.width = BluCat::INT::core.display_width; + viewport.height = BluCat::INT::core.display_height; viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor = {}; scissor.offset = {0, 0}; - scissor.extent = {BluCat::core.display_width, BluCat::core.display_height}; + scissor.extent = {BluCat::INT::core.display_width, BluCat::INT::core.display_height}; VkPipelineViewportStateCreateInfo viewport_state = {}; viewport_state.sType = @@ -191,14 +191,14 @@ load_pipeline(void *obj) pipeline_info.pColorBlendState = &color_blending; pipeline_info.pDynamicState = &dynamic_state_info; pipeline_info.layout = - BluCat::core.vk_graphics_pipeline_2d_solid_layout->pipeline; - pipeline_info.renderPass = BluCat::core.vk_render_pass->pipeline_2d; + BluCat::INT::core.vk_graphics_pipeline_2d_solid_layout->pipeline; + pipeline_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_2d; pipeline_info.subpass = 0; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; pipeline_info.basePipelineIndex = -1; if(vkCreateGraphicsPipelines( - BluCat::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, + BluCat::INT::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &self->graphic_pipeline) != VK_SUCCESS) throw CommandError{"Failed to create graphics pipeline."}; @@ -207,10 +207,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DSolid*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DSolid*>(obj); vkDestroyPipeline( - BluCat::core.vk_device_with_swapchain->device, self->graphic_pipeline, + BluCat::INT::core.vk_device_with_swapchain->device, self->graphic_pipeline, nullptr); } @@ -220,7 +220,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline2DSolid::GraphicsPipeline2DSolid() @@ -277,7 +277,7 @@ GraphicsPipeline2DSolid::draw( vkCmdBindDescriptorSets( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - core.vk_graphics_pipeline_2d_solid_layout->pipeline, 0, + INT::core.vk_graphics_pipeline_2d_solid_layout->pipeline, 0, vk_descriptor_sets.size(), vk_descriptor_sets.data(), 0, nullptr); vkCmdBindVertexBuffers( draw_command_buffer, 0, 1, &sprite_to_draw.sprite->vertex_buffer->buffer, @@ -286,7 +286,7 @@ GraphicsPipeline2DSolid::draw( UDOVector4D position{sprite_to_draw.position}; vkCmdPushConstants( draw_command_buffer, - core.vk_graphics_pipeline_2d_solid_layout->pipeline, + INT::core.vk_graphics_pipeline_2d_solid_layout->pipeline, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(UDOVector4D), &position); vkCmdDraw(draw_command_buffer, Sprite::vertex_count, 1, 0, 0); } diff --git a/src/blucat/graphics_pipeline_2d_solid.hpp b/src/blu_cat/gra/graphics_pipeline_2d_solid.hpp index 753e9d8..c1520c2 100644 --- a/src/blucat/graphics_pipeline_2d_solid.hpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_solid.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_SOLID_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_SOLID_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_SOLID_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_SOLID_H 1 #include <memory> @@ -23,7 +23,7 @@ #include "command_pool.hpp" #include "view_2d.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline2DSolid @@ -41,4 +41,4 @@ struct GraphicsPipeline2DSolid } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_SOLID_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_SOLID_H */ diff --git a/src/blucat/graphics_pipeline_2d_solid_layout.cpp b/src/blu_cat/gra/graphics_pipeline_2d_solid_layout.cpp index 666556d..476bac1 100644 --- a/src/blucat/graphics_pipeline_2d_solid_layout.cpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_solid_layout.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -27,17 +27,17 @@ namespace void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DSolidLayout*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DSolidLayout*>(obj); std::array<VkDescriptorSetLayout, 2> set_layouts{ - BluCat::core.vk_descriptor_set_layout->view, - BluCat::core.vk_descriptor_set_layout->texture + BluCat::INT::core.vk_descriptor_set_layout->view, + BluCat::INT::core.vk_descriptor_set_layout->texture }; std::array<VkPushConstantRange, 1> push_constants; push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; push_constants[0].offset = 0; - push_constants[0].size = sizeof(BluCat::UDOVector4D); + push_constants[0].size = sizeof(BluCat::GRA::UDOVector4D); VkPipelineLayoutCreateInfo pipeline_layout_info{}; pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; @@ -47,7 +47,7 @@ load_pipeline(void *obj) pipeline_layout_info.pPushConstantRanges = push_constants.data(); if(vkCreatePipelineLayout( - BluCat::core.vk_device_with_swapchain->device, &pipeline_layout_info, + BluCat::INT::core.vk_device_with_swapchain->device, &pipeline_layout_info, nullptr, &self->pipeline) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan pipeline layout."}; } @@ -55,10 +55,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DSolidLayout*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DSolidLayout*>(obj); vkDestroyPipelineLayout( - BluCat::core.vk_device_with_swapchain->device, self->pipeline, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->pipeline, nullptr); } const CommandChain loader{ @@ -67,7 +67,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline2DSolidLayout::GraphicsPipeline2DSolidLayout() diff --git a/src/blucat/graphics_pipeline_2d_solid_layout.hpp b/src/blu_cat/gra/graphics_pipeline_2d_solid_layout.hpp index f6a8960..6abd65d 100644 --- a/src/blucat/graphics_pipeline_2d_solid_layout.hpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_solid_layout.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_LAYOUT_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_LAYOUT_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_LAYOUT_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_LAYOUT_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline2DSolidLayout @@ -32,4 +32,4 @@ struct GraphicsPipeline2DSolidLayout } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_LAYOUT_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_LAYOUT_H */ diff --git a/src/blucat/graphics_pipeline_2d_wired.cpp b/src/blu_cat/gra/graphics_pipeline_2d_wired.cpp index 9cd3a86..20491ed 100644 --- a/src/blucat/graphics_pipeline_2d_wired.cpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_wired.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "rectangle.hpp" #include "sprite.hpp" #include "uniform_data_object.hpp" @@ -29,17 +29,17 @@ namespace void load_indexes(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DWired*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DWired*>(obj); self->queue_family = - BluCat::core.vk_device_with_swapchain->get_queue_family_with_graphics(); + BluCat::INT::core.vk_device_with_swapchain->get_queue_family_with_graphics(); std::array<uint32_t, 4> indexes{0, 1, 2, 3}; void *indexes_data{indexes.data()}; size_t indexes_size{sizeof(indexes[0]) * indexes.size()}; - BluCat::SourceBuffer source_index_buffer{ + BluCat::GRA::SourceBuffer source_index_buffer{ self->queue_family->device, indexes_data, indexes_size}; - self->index_buffer = new BluCat::DestinationBuffer{ + self->index_buffer = new BluCat::GRA::DestinationBuffer{ self->queue_family, &source_index_buffer, VK_BUFFER_USAGE_INDEX_BUFFER_BIT}; } @@ -47,7 +47,7 @@ load_indexes(void *obj) void unload_indexes(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DWired*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DWired*>(obj); delete self->index_buffer; } @@ -55,7 +55,7 @@ unload_indexes(void *obj) void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DWired*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DWired*>(obj); VkPipelineShaderStageCreateInfo vert_shader_stage_info{}; vert_shader_stage_info.sType = @@ -64,7 +64,7 @@ load_pipeline(void *obj) vert_shader_stage_info.flags = 0; vert_shader_stage_info.stage = VK_SHADER_STAGE_VERTEX_BIT; vert_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->vert2d_wired_shader_module; + BluCat::INT::core.vk_device_with_swapchain->vert2d_wired_shader_module; vert_shader_stage_info.pName = "main"; vert_shader_stage_info.pSpecializationInfo = nullptr; @@ -75,7 +75,7 @@ load_pipeline(void *obj) frag_shader_stage_info.flags = 0; frag_shader_stage_info.stage = VK_SHADER_STAGE_FRAGMENT_BIT; frag_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->frag2d_wired_shader_module; + BluCat::INT::core.vk_device_with_swapchain->frag2d_wired_shader_module; frag_shader_stage_info.pName = "main"; frag_shader_stage_info.pSpecializationInfo = nullptr; @@ -105,14 +105,14 @@ load_pipeline(void *obj) VkViewport viewport = {}; viewport.x = 0; viewport.y = 0; - viewport.width = BluCat::core.display_width; - viewport.height = BluCat::core.display_height; + viewport.width = BluCat::INT::core.display_width; + viewport.height = BluCat::INT::core.display_height; viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor = {}; scissor.offset = {0, 0}; - scissor.extent = {BluCat::core.display_width, BluCat::core.display_height}; + scissor.extent = {BluCat::INT::core.display_width, BluCat::INT::core.display_height}; VkPipelineViewportStateCreateInfo viewport_state = {}; viewport_state.sType = @@ -203,14 +203,14 @@ load_pipeline(void *obj) pipeline_info.pColorBlendState = &color_blending; pipeline_info.pDynamicState = &dynamic_state_info; pipeline_info.layout = - BluCat::core.vk_graphics_pipeline_2d_wired_layout->pipeline; - pipeline_info.renderPass = BluCat::core.vk_render_pass->pipeline_2d; + BluCat::INT::core.vk_graphics_pipeline_2d_wired_layout->pipeline; + pipeline_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_2d; pipeline_info.subpass = 0; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; pipeline_info.basePipelineIndex = -1; if(vkCreateGraphicsPipelines( - BluCat::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, + BluCat::INT::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &self->graphic_pipeline) != VK_SUCCESS) throw CommandError{"Failed to create graphics pipeline."}; } @@ -218,10 +218,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DWired*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DWired*>(obj); vkDestroyPipeline( - BluCat::core.vk_device_with_swapchain->device, self->graphic_pipeline, + BluCat::INT::core.vk_device_with_swapchain->device, self->graphic_pipeline, nullptr); } @@ -232,7 +232,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline2DWired::GraphicsPipeline2DWired() @@ -278,7 +278,7 @@ GraphicsPipeline2DWired::draw( vkCmdBindDescriptorSets( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - core.vk_graphics_pipeline_2d_wired_layout->pipeline, 0, + INT::core.vk_graphics_pipeline_2d_wired_layout->pipeline, 0, vk_descriptor_sets.size(), vk_descriptor_sets.data(), 0, nullptr); vkCmdBindPipeline( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, @@ -295,11 +295,11 @@ GraphicsPipeline2DWired::draw( UDOVector3D color{rect.color}; vkCmdPushConstants( draw_command_buffer, - core.vk_graphics_pipeline_2d_wired_layout->pipeline, + INT::core.vk_graphics_pipeline_2d_wired_layout->pipeline, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(UDOVector4D), &position); vkCmdPushConstants( draw_command_buffer, - core.vk_graphics_pipeline_2d_wired_layout->pipeline, + INT::core.vk_graphics_pipeline_2d_wired_layout->pipeline, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(UDOVector4D), sizeof(UDOVector3D), &color); vkCmdDrawIndexed( diff --git a/src/blucat/graphics_pipeline_2d_wired.hpp b/src/blu_cat/gra/graphics_pipeline_2d_wired.hpp index a351aee..7d2752e 100644 --- a/src/blucat/graphics_pipeline_2d_wired.hpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_wired.hpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_WIRED_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_WIRED_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_WIRED_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_WIRED_H 1 #include <memory> #include "vulkan.hpp" #include "view_2d.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline2DWired @@ -44,4 +44,4 @@ struct GraphicsPipeline2DWired } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_WIRED_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_WIRED_H */ diff --git a/src/blucat/graphics_pipeline_2d_wired_layout.cpp b/src/blu_cat/gra/graphics_pipeline_2d_wired_layout.cpp index 104c599..431a845 100644 --- a/src/blucat/graphics_pipeline_2d_wired_layout.cpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_wired_layout.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "graphics_pipeline_2d_solid_layout.hpp" #include "uniform_data_object.hpp" @@ -28,20 +28,20 @@ namespace void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DWiredLayout*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DWiredLayout*>(obj); std::array<VkDescriptorSetLayout, 1> set_layouts{ - BluCat::core.vk_descriptor_set_layout->view + BluCat::INT::core.vk_descriptor_set_layout->view }; std::array<VkPushConstantRange, 2> push_constants; push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; push_constants[0].offset = 0; - push_constants[0].size = sizeof(BluCat::UDOVector4D); + push_constants[0].size = sizeof(BluCat::GRA::UDOVector4D); push_constants[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; - push_constants[1].offset = sizeof(BluCat::UDOVector4D); - push_constants[1].size = sizeof(BluCat::UDOVector3D); + push_constants[1].offset = sizeof(BluCat::GRA::UDOVector4D); + push_constants[1].size = sizeof(BluCat::GRA::UDOVector3D); VkPipelineLayoutCreateInfo pipeline_layout_info{}; pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; @@ -51,7 +51,7 @@ load_pipeline(void *obj) pipeline_layout_info.pPushConstantRanges = push_constants.data(); if(vkCreatePipelineLayout( - BluCat::core.vk_device_with_swapchain->device, &pipeline_layout_info, + BluCat::INT::core.vk_device_with_swapchain->device, &pipeline_layout_info, nullptr, &self->pipeline) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan pipeline layout."}; } @@ -59,10 +59,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline2DWiredLayout*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline2DWiredLayout*>(obj); vkDestroyPipelineLayout( - BluCat::core.vk_device_with_swapchain->device, self->pipeline, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->pipeline, nullptr); } const CommandChain loader{ @@ -71,7 +71,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline2DWiredLayout::GraphicsPipeline2DWiredLayout() diff --git a/src/blucat/graphics_pipeline_2d_wired_layout.hpp b/src/blu_cat/gra/graphics_pipeline_2d_wired_layout.hpp index 402e7dc..16f23ea 100644 --- a/src/blucat/graphics_pipeline_2d_wired_layout.hpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_wired_layout.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_WIRED_LAYOUT_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_WIRED_LAYOUT_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_WIRED_LAYOUT_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_WIRED_LAYOUT_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline2DWiredLayout @@ -32,4 +32,4 @@ struct GraphicsPipeline2DWiredLayout } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_2D_LAYOUT_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_2D_LAYOUT_H */ diff --git a/src/blucat/graphics_pipeline_3d.cpp b/src/blu_cat/gra/graphics_pipeline_3d.cpp index bd64ebc..1f7324a 100644 --- a/src/blucat/graphics_pipeline_3d.cpp +++ b/src/blu_cat/gra/graphics_pipeline_3d.cpp @@ -19,7 +19,7 @@ #include <array> #include <stdexcept> -#include "core.hpp" +#include "../int/core.hpp" #include "vulkan.hpp" #include "static_mesh_vertex.hpp" #include "uniform_data_object.hpp" @@ -30,7 +30,7 @@ namespace void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline3D*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline3D*>(obj); VkPipelineShaderStageCreateInfo vert_shader_stage_info = {}; vert_shader_stage_info.sType = @@ -39,7 +39,7 @@ load_pipeline(void *obj) vert_shader_stage_info.flags = 0; vert_shader_stage_info.stage = VK_SHADER_STAGE_VERTEX_BIT; vert_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->vert3d_shader_module; + BluCat::INT::core.vk_device_with_swapchain->vert3d_shader_module; vert_shader_stage_info.pName = "main"; vert_shader_stage_info.pSpecializationInfo = nullptr; @@ -50,7 +50,7 @@ load_pipeline(void *obj) frag_shader_stage_info.flags = 0; frag_shader_stage_info.stage = VK_SHADER_STAGE_FRAGMENT_BIT; frag_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->frag3d_shader_module; + BluCat::INT::core.vk_device_with_swapchain->frag3d_shader_module; frag_shader_stage_info.pName = "main"; frag_shader_stage_info.pSpecializationInfo = nullptr; @@ -61,7 +61,7 @@ load_pipeline(void *obj) VkVertexInputBindingDescription vertex_input_binding{}; vertex_input_binding.binding = 0; - vertex_input_binding.stride = sizeof(BluCat::StaticMeshVertex); + vertex_input_binding.stride = sizeof(BluCat::GRA::StaticMeshVertex); vertex_input_binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; std::array<VkVertexInputAttributeDescription, 3> vertex_attribute{}; @@ -69,17 +69,17 @@ load_pipeline(void *obj) vertex_attribute[0].location = 0; vertex_attribute[0].binding = 0; vertex_attribute[0].format = VK_FORMAT_R32G32B32_SFLOAT; - vertex_attribute[0].offset = offsetof(BluCat::StaticMeshVertex, position); + vertex_attribute[0].offset = offsetof(BluCat::GRA::StaticMeshVertex, position); // Normal. vertex_attribute[1].location = 1; vertex_attribute[1].binding = 0; vertex_attribute[1].format = VK_FORMAT_R32G32B32_SFLOAT; - vertex_attribute[1].offset = offsetof(BluCat::StaticMeshVertex, normal); + vertex_attribute[1].offset = offsetof(BluCat::GRA::StaticMeshVertex, normal); // Texture coordinate. vertex_attribute[2].location = 2; vertex_attribute[2].binding = 0; vertex_attribute[2].format = VK_FORMAT_R32G32_SFLOAT; - vertex_attribute[2].offset = offsetof(BluCat::StaticMeshVertex, texture_coord); + vertex_attribute[2].offset = offsetof(BluCat::GRA::StaticMeshVertex, texture_coord); VkPipelineVertexInputStateCreateInfo vertex_input_info = {}; vertex_input_info.sType = @@ -103,14 +103,14 @@ load_pipeline(void *obj) VkViewport viewport = {}; viewport.x = 0; viewport.y = 0; - viewport.width = BluCat::core.display_width; - viewport.height = BluCat::core.display_height; + viewport.width = BluCat::INT::core.display_width; + viewport.height = BluCat::INT::core.display_height; viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor = {}; scissor.offset = {0, 0}; - scissor.extent = {BluCat::core.display_width, BluCat::core.display_height}; + scissor.extent = {BluCat::INT::core.display_width, BluCat::INT::core.display_height}; VkPipelineViewportStateCreateInfo viewport_state = {}; viewport_state.sType = @@ -213,14 +213,14 @@ load_pipeline(void *obj) pipeline_info.pDepthStencilState = &depth_stencil; pipeline_info.pColorBlendState = &color_blending; pipeline_info.pDynamicState = &dynamic_state_info; - pipeline_info.layout = BluCat::core.vk_graphics_pipeline_3d_layout->pipeline; - pipeline_info.renderPass = BluCat::core.vk_render_pass->pipeline_3d; + pipeline_info.layout = BluCat::INT::core.vk_graphics_pipeline_3d_layout->pipeline; + pipeline_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_3d; pipeline_info.subpass = 0; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; pipeline_info.basePipelineIndex = -1; if(vkCreateGraphicsPipelines( - BluCat::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, + BluCat::INT::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &self->graphic_pipeline) != VK_SUCCESS) throw CommandError{"Failed to create graphics pipeline."}; @@ -229,10 +229,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline3D*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline3D*>(obj); vkDestroyPipeline( - BluCat::core.vk_device_with_swapchain->device, self->graphic_pipeline, + BluCat::INT::core.vk_device_with_swapchain->device, self->graphic_pipeline, nullptr); } @@ -242,7 +242,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline3D::GraphicsPipeline3D() @@ -266,7 +266,7 @@ GraphicsPipeline3D::draw( // Draw models for(auto& [static_mesh, instances]: - core.vk_renderer->static_models_to_draw[current_frame]) + INT::core.vk_renderer->static_models_to_draw[current_frame]) { VkBuffer vertex_buffers[]{static_mesh->vertex_buffer->buffer}; VkDeviceSize offsets[]{0}; @@ -285,20 +285,20 @@ GraphicsPipeline3D::draw( glm::mat4 rotation_matrix{glm::toMat4(*instance->orientation)}; std::array<VkDescriptorSet, 4> vk_descriptor_sets{ - core.vk_light->descriptor_sets_world[image_index], + INT::core.vk_light->descriptor_sets_world[image_index], view->descriptor_sets_3d[image_index], instance->descriptor_sets[image_index], instance->texture->descriptor_sets[image_index]}; vkCmdBindDescriptorSets( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - core.vk_graphics_pipeline_3d_layout->pipeline, 0, + INT::core.vk_graphics_pipeline_3d_layout->pipeline, 0, vk_descriptor_sets.size(), vk_descriptor_sets.data(), 0, nullptr); vkCmdDrawIndexed( draw_command_buffer, static_mesh->index_count, 1, 0, 0, 0); - BluCat::UDOStaticModel udo_static_model{}; + BluCat::GRA::UDOStaticModel udo_static_model{}; udo_static_model.base_matrix = translation_matrix * rotation_matrix; instance->uniform_buffers[image_index].copy_data(&udo_static_model); } diff --git a/src/blucat/graphics_pipeline_3d.hpp b/src/blu_cat/gra/graphics_pipeline_3d.hpp index 6942955..0dc0b03 100644 --- a/src/blucat/graphics_pipeline_3d.hpp +++ b/src/blu_cat/gra/graphics_pipeline_3d.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_H 1 #include <memory> @@ -23,7 +23,7 @@ #include "command_pool.hpp" #include "view_3d.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline3D @@ -40,4 +40,4 @@ struct GraphicsPipeline3D } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_H */ diff --git a/src/blucat/graphics_pipeline_3d_layout.cpp b/src/blu_cat/gra/graphics_pipeline_3d_layout.cpp index 6bac1bb..504b46e 100644 --- a/src/blucat/graphics_pipeline_3d_layout.cpp +++ b/src/blu_cat/gra/graphics_pipeline_3d_layout.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -27,13 +27,13 @@ namespace void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline3DLayout*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline3DLayout*>(obj); std::array<VkDescriptorSetLayout, 4> set_layouts{ - BluCat::core.vk_descriptor_set_layout->world, - BluCat::core.vk_descriptor_set_layout->view, - BluCat::core.vk_descriptor_set_layout->model, - BluCat::core.vk_descriptor_set_layout->texture}; + BluCat::INT::core.vk_descriptor_set_layout->world, + BluCat::INT::core.vk_descriptor_set_layout->view, + BluCat::INT::core.vk_descriptor_set_layout->model, + BluCat::INT::core.vk_descriptor_set_layout->texture}; VkPipelineLayoutCreateInfo pipeline_layout_info{}; pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; @@ -43,7 +43,7 @@ load_pipeline(void *obj) pipeline_layout_info.pPushConstantRanges = nullptr; if(vkCreatePipelineLayout( - BluCat::core.vk_device_with_swapchain->device, + BluCat::INT::core.vk_device_with_swapchain->device, &pipeline_layout_info, nullptr, &self->pipeline) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan pipeline layout."}; } @@ -51,10 +51,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline3DLayout*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline3DLayout*>(obj); vkDestroyPipelineLayout( - BluCat::core.vk_device_with_swapchain->device, self->pipeline, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->pipeline, nullptr); } const CommandChain loader{ @@ -63,7 +63,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline3DLayout::GraphicsPipeline3DLayout() diff --git a/src/blucat/graphics_pipeline_3d_layout.hpp b/src/blu_cat/gra/graphics_pipeline_3d_layout.hpp index bc86646..13820c4 100644 --- a/src/blucat/graphics_pipeline_3d_layout.hpp +++ b/src/blu_cat/gra/graphics_pipeline_3d_layout.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_LAYOUT_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_LAYOUT_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_LAYOUT_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_LAYOUT_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline3DLayout @@ -32,4 +32,4 @@ struct GraphicsPipeline3DLayout } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_LAYOUT_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_LAYOUT_H */ diff --git a/src/blucat/graphics_pipeline_3d_skeletal.cpp b/src/blu_cat/gra/graphics_pipeline_3d_skeletal.cpp index 6b56221..e8eda6b 100644 --- a/src/blucat/graphics_pipeline_3d_skeletal.cpp +++ b/src/blu_cat/gra/graphics_pipeline_3d_skeletal.cpp @@ -19,7 +19,7 @@ #include <array> #include <stdexcept> -#include "core.hpp" +#include "../int/core.hpp" #include "skeletal_mesh_vertex.hpp" #include "uniform_data_object.hpp" @@ -29,7 +29,7 @@ namespace void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline3DSkeletal*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline3DSkeletal*>(obj); VkPipelineShaderStageCreateInfo vert_shader_stage_info = {}; vert_shader_stage_info.sType = @@ -38,7 +38,7 @@ load_pipeline(void *obj) vert_shader_stage_info.flags = 0; vert_shader_stage_info.stage = VK_SHADER_STAGE_VERTEX_BIT; vert_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->vert3d_skeletal_shader_module; + BluCat::INT::core.vk_device_with_swapchain->vert3d_skeletal_shader_module; vert_shader_stage_info.pName = "main"; vert_shader_stage_info.pSpecializationInfo = nullptr; @@ -49,7 +49,7 @@ load_pipeline(void *obj) frag_shader_stage_info.flags = 0; frag_shader_stage_info.stage = VK_SHADER_STAGE_FRAGMENT_BIT; frag_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->frag3d_shader_module; + BluCat::INT::core.vk_device_with_swapchain->frag3d_shader_module; frag_shader_stage_info.pName = "main"; frag_shader_stage_info.pSpecializationInfo = nullptr; @@ -60,7 +60,7 @@ load_pipeline(void *obj) VkVertexInputBindingDescription vertex_input_binding{}; vertex_input_binding.binding = 0; - vertex_input_binding.stride = sizeof(BluCat::SkeletalMeshVertex); + vertex_input_binding.stride = sizeof(BluCat::GRA::SkeletalMeshVertex); vertex_input_binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; std::array<VkVertexInputAttributeDescription, 5> vertex_attribute{}; @@ -68,27 +68,27 @@ load_pipeline(void *obj) vertex_attribute[0].location = 0; vertex_attribute[0].binding = 0; vertex_attribute[0].format = VK_FORMAT_R32G32B32_SFLOAT; - vertex_attribute[0].offset = offsetof(BluCat::SkeletalMeshVertex, position); + vertex_attribute[0].offset = offsetof(BluCat::GRA::SkeletalMeshVertex, position); // Normal. vertex_attribute[1].location = 1; vertex_attribute[1].binding = 0; vertex_attribute[1].format = VK_FORMAT_R32G32B32_SFLOAT; - vertex_attribute[1].offset = offsetof(BluCat::SkeletalMeshVertex, normal); + vertex_attribute[1].offset = offsetof(BluCat::GRA::SkeletalMeshVertex, normal); // Texture coordinate. vertex_attribute[2].location = 2; vertex_attribute[2].binding = 0; vertex_attribute[2].format = VK_FORMAT_R32G32_SFLOAT; - vertex_attribute[2].offset = offsetof(BluCat::SkeletalMeshVertex, texture_coord); + vertex_attribute[2].offset = offsetof(BluCat::GRA::SkeletalMeshVertex, texture_coord); // Bones ids. vertex_attribute[3].location = 3; vertex_attribute[3].binding = 0; vertex_attribute[3].format = VK_FORMAT_R32G32B32A32_SINT; - vertex_attribute[3].offset = offsetof(BluCat::SkeletalMeshVertex, bone_ids); + vertex_attribute[3].offset = offsetof(BluCat::GRA::SkeletalMeshVertex, bone_ids); // Bones weights. vertex_attribute[4].location = 4; vertex_attribute[4].binding = 0; vertex_attribute[4].format = VK_FORMAT_R32G32B32A32_SFLOAT; - vertex_attribute[4].offset = offsetof(BluCat::SkeletalMeshVertex, bone_weights); + vertex_attribute[4].offset = offsetof(BluCat::GRA::SkeletalMeshVertex, bone_weights); VkPipelineVertexInputStateCreateInfo vertex_input_info = {}; vertex_input_info.sType = @@ -112,14 +112,14 @@ load_pipeline(void *obj) VkViewport viewport = {}; viewport.x = 0; viewport.y = 0; - viewport.width = BluCat::core.display_width; - viewport.height = BluCat::core.display_height; + viewport.width = BluCat::INT::core.display_width; + viewport.height = BluCat::INT::core.display_height; viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor = {}; scissor.offset = {0, 0}; - scissor.extent = {BluCat::core.display_width, BluCat::core.display_height}; + scissor.extent = {BluCat::INT::core.display_width, BluCat::INT::core.display_height}; VkPipelineViewportStateCreateInfo viewport_state = {}; viewport_state.sType = @@ -222,14 +222,14 @@ load_pipeline(void *obj) pipeline_info.pDepthStencilState = &depth_stencil; pipeline_info.pColorBlendState = &color_blending; pipeline_info.pDynamicState = &dynamic_state_info; - pipeline_info.layout = BluCat::core.vk_graphics_pipeline_3d_layout->pipeline; - pipeline_info.renderPass = BluCat::core.vk_render_pass->pipeline_3d; + pipeline_info.layout = BluCat::INT::core.vk_graphics_pipeline_3d_layout->pipeline; + pipeline_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_3d; pipeline_info.subpass = 0; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; pipeline_info.basePipelineIndex = -1; if(vkCreateGraphicsPipelines( - BluCat::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, + BluCat::INT::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &self->graphic_pipeline) != VK_SUCCESS) throw CommandError{"Failed to create graphics pipeline."}; @@ -238,10 +238,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipeline3DSkeletal*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipeline3DSkeletal*>(obj); vkDestroyPipeline( - BluCat::core.vk_device_with_swapchain->device, self->graphic_pipeline, + BluCat::INT::core.vk_device_with_swapchain->device, self->graphic_pipeline, nullptr); } @@ -251,7 +251,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipeline3DSkeletal::GraphicsPipeline3DSkeletal() @@ -275,7 +275,7 @@ GraphicsPipeline3DSkeletal::draw( // Draw models for(auto& [skeletal_mesh, instances]: - core.vk_renderer->skeletal_models_to_draw[current_frame]) + INT::core.vk_renderer->skeletal_models_to_draw[current_frame]) { VkBuffer vertex_buffers[]{skeletal_mesh->vertex_buffer->buffer}; VkDeviceSize offsets[]{0}; @@ -294,21 +294,21 @@ GraphicsPipeline3DSkeletal::draw( glm::mat4 rotation_matrix{glm::toMat4(*instance->orientation)}; std::array<VkDescriptorSet, 4> vk_descriptor_sets{ - core.vk_light->descriptor_sets_world[image_index], + INT::core.vk_light->descriptor_sets_world[image_index], view->descriptor_sets_3d[image_index], instance->descriptor_sets[image_index], instance->texture->descriptor_sets[image_index]}; vkCmdBindDescriptorSets( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - core.vk_graphics_pipeline_3d_layout->pipeline, 0, + INT::core.vk_graphics_pipeline_3d_layout->pipeline, 0, vk_descriptor_sets.size(), vk_descriptor_sets.data(), 0, nullptr); vkCmdDrawIndexed( draw_command_buffer, skeletal_mesh->index_count, 1, 0, 0, 0); - BluCat::UDOSkeletalModel udo_skeletal_model{}; - instance->tick(core.delta_time); + BluCat::GRA::UDOSkeletalModel udo_skeletal_model{}; + instance->tick(INT::core.delta_time); udo_skeletal_model.base_matrix = translation_matrix * rotation_matrix; std::copy(instance->bone_transforms.begin(), instance->bone_transforms.end(), diff --git a/src/blucat/graphics_pipeline_3d_skeletal.hpp b/src/blu_cat/gra/graphics_pipeline_3d_skeletal.hpp index 52810f6..bad117d 100644 --- a/src/blucat/graphics_pipeline_3d_skeletal.hpp +++ b/src/blu_cat/gra/graphics_pipeline_3d_skeletal.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_SKELETAL_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_3D_SKELETAL_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_SKELETAL_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_3D_SKELETAL_H 1 #include <memory> @@ -23,7 +23,7 @@ #include "command_pool.hpp" #include "view_3d.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipeline3DSkeletal @@ -40,4 +40,4 @@ struct GraphicsPipeline3DSkeletal } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_SKELETAL_3D_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_SKELETAL_3D_H */ diff --git a/src/blucat/graphics_pipeline_sprite_3d.cpp b/src/blu_cat/gra/graphics_pipeline_sprite_3d.cpp index f87b7e1..14796d3 100644 --- a/src/blucat/graphics_pipeline_sprite_3d.cpp +++ b/src/blu_cat/gra/graphics_pipeline_sprite_3d.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "sprite.hpp" #include "uniform_data_object.hpp" @@ -27,7 +27,7 @@ namespace struct Sprite3DOrder { - std::shared_ptr<BluCat::Sprite3D> sprite_3d; + std::shared_ptr<BluCat::GRA::Sprite3D> sprite_3d; float distance; }; @@ -46,7 +46,7 @@ operator>(const Sprite3DOrder &a, const Sprite3DOrder &b) void load_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipelineSprite3D*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipelineSprite3D*>(obj); VkPipelineShaderStageCreateInfo vert_shader_stage_info{}; vert_shader_stage_info.sType = @@ -55,7 +55,7 @@ load_pipeline(void *obj) vert_shader_stage_info.flags = 0; vert_shader_stage_info.stage = VK_SHADER_STAGE_VERTEX_BIT; vert_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->vert_sprite_3d_shader_module; + BluCat::INT::core.vk_device_with_swapchain->vert_sprite_3d_shader_module; vert_shader_stage_info.pName = "main"; vert_shader_stage_info.pSpecializationInfo = nullptr; @@ -66,7 +66,7 @@ load_pipeline(void *obj) frag_shader_stage_info.flags = 0; frag_shader_stage_info.stage = VK_SHADER_STAGE_FRAGMENT_BIT; frag_shader_stage_info.module = - BluCat::core.vk_device_with_swapchain->frag_sprite_3d_shader_module; + BluCat::INT::core.vk_device_with_swapchain->frag_sprite_3d_shader_module; frag_shader_stage_info.pName = "main"; frag_shader_stage_info.pSpecializationInfo = nullptr; @@ -109,14 +109,14 @@ load_pipeline(void *obj) VkViewport viewport = {}; viewport.x = 0; viewport.y = 0; - viewport.width = BluCat::core.display_width; - viewport.height = BluCat::core.display_height; + viewport.width = BluCat::INT::core.display_width; + viewport.height = BluCat::INT::core.display_height; viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor = {}; scissor.offset = {0, 0}; - scissor.extent = {BluCat::core.display_width, BluCat::core.display_height}; + scissor.extent = {BluCat::INT::core.display_width, BluCat::INT::core.display_height}; VkPipelineViewportStateCreateInfo viewport_state = {}; viewport_state.sType = @@ -221,14 +221,14 @@ load_pipeline(void *obj) pipeline_info.pDepthStencilState = &depth_stencil; pipeline_info.pColorBlendState = &color_blending; pipeline_info.pDynamicState = &dynamic_state_info; - pipeline_info.layout = BluCat::core.vk_graphics_pipeline_3d_layout->pipeline; - pipeline_info.renderPass = BluCat::core.vk_render_pass->pipeline_3d; + pipeline_info.layout = BluCat::INT::core.vk_graphics_pipeline_3d_layout->pipeline; + pipeline_info.renderPass = BluCat::INT::core.vk_render_pass->pipeline_3d; pipeline_info.subpass = 0; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; pipeline_info.basePipelineIndex = -1; if(vkCreateGraphicsPipelines( - BluCat::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, + BluCat::INT::core.vk_device_with_swapchain->device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &self->graphic_pipeline) != VK_SUCCESS) throw CommandError{"Failed to create graphics pipeline sprite 3d."}; @@ -237,10 +237,10 @@ load_pipeline(void *obj) void unload_pipeline(void *obj) { - auto self = static_cast<BluCat::GraphicsPipelineSprite3D*>(obj); + auto self = static_cast<BluCat::GRA::GraphicsPipelineSprite3D*>(obj); vkDestroyPipeline( - BluCat::core.vk_device_with_swapchain->device, self->graphic_pipeline, + BluCat::INT::core.vk_device_with_swapchain->device, self->graphic_pipeline, nullptr); } @@ -250,7 +250,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { GraphicsPipelineSprite3D::GraphicsPipelineSprite3D() @@ -275,10 +275,10 @@ GraphicsPipelineSprite3D::draw( std::vector<Sprite3DOrder> sprite_3d_order; { // Sort sprites 3D sprite_3d_order.reserve( - core.vk_renderer->sprites_3d_to_draw[current_frame].size()); + INT::core.vk_renderer->sprites_3d_to_draw[current_frame].size()); - for(std::shared_ptr<BluCat::Sprite3D> sprite: - core.vk_renderer->sprites_3d_to_draw[current_frame]) + for(std::shared_ptr<BluCat::GRA::Sprite3D> sprite: + INT::core.vk_renderer->sprites_3d_to_draw[current_frame]) sprite_3d_order.emplace_back( sprite, glm::distance(*view->camera_position, *sprite->position)); @@ -289,7 +289,7 @@ GraphicsPipelineSprite3D::draw( for(auto& sprite: sprite_3d_order) { std::array<VkDescriptorSet, 4> vk_descriptor_sets{ - core.vk_light->descriptor_sets_world[image_index], + INT::core.vk_light->descriptor_sets_world[image_index], view->descriptor_sets_3d[image_index], sprite.sprite_3d->descriptor_sets[image_index], sprite.sprite_3d->sprite->texture->descriptor_sets[image_index]}; @@ -300,7 +300,7 @@ GraphicsPipelineSprite3D::draw( &sprite.sprite_3d->sprite->vertex_buffer->buffer, offsets); vkCmdBindDescriptorSets( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - core.vk_graphics_pipeline_3d_layout->pipeline, 0, + INT::core.vk_graphics_pipeline_3d_layout->pipeline, 0, vk_descriptor_sets.size(), vk_descriptor_sets.data(), 0, nullptr); UDOSprite3D ubo_sprite_3d{}; diff --git a/src/blucat/graphics_pipeline_sprite_3d.hpp b/src/blu_cat/gra/graphics_pipeline_sprite_3d.hpp index 237094d..325d943 100644 --- a/src/blucat/graphics_pipeline_sprite_3d.hpp +++ b/src/blu_cat/gra/graphics_pipeline_sprite_3d.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_SPRITE_3D_H -#define CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_SPRITE_3D_H 1 +#ifndef BLU_CAT_GRA_GRAPHICS_PIPELINE_SPRITE_3D_H +#define BLU_CAT_GRA_GRAPHICS_PIPELINE_SPRITE_3D_H 1 #include <memory> @@ -24,7 +24,7 @@ #include "sprite_3d.hpp" #include "view_3d.hpp" -namespace BluCat +namespace BluCat::GRA { struct GraphicsPipelineSprite3D @@ -41,4 +41,4 @@ struct GraphicsPipelineSprite3D } -#endif /* CANDY_GEAR_BLUCAT_GRAPHICS_PIPELINE_SPRITE_3D_H */ +#endif /* BLU_CAT_GRA_GRAPHICS_PIPELINE_SPRITE_3D_H */ diff --git a/src/blucat/image.cpp b/src/blu_cat/gra/image.cpp index 81b1563..76e4f9d 100644 --- a/src/blucat/image.cpp +++ b/src/blu_cat/gra/image.cpp @@ -16,9 +16,9 @@ #include "image.hpp" -#include "core.hpp" +#include "../int/core.hpp" -namespace BluCat::Image +namespace BluCat::GRA::Image { Error::Error(const std::string &m): @@ -39,7 +39,7 @@ Error::what() const noexcept void create( - BluCat::Device *device, + BluCat::GRA::Device *device, VkImage *image, VkDeviceMemory *image_memory, VkFormat format, @@ -117,7 +117,7 @@ void move_image_state( } void create_view( - BluCat::Device *device, + BluCat::GRA::Device *device, VkImageView *image_view, const VkImage &image, VkFormat format, diff --git a/src/blucat/image.hpp b/src/blu_cat/gra/image.hpp index 67c1933..ba64b76 100644 --- a/src/blucat/image.hpp +++ b/src/blu_cat/gra/image.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BLUE_KITTY_BLUCAT_IMAGE_H -#define BLUE_KITTY_BLUCAT_IMAGE_H 1 +#ifndef BLU_CAT_GRA_IMAGE_H +#define BLU_CAT_GRA_IMAGE_H 1 #include <memory> #include <string> @@ -23,7 +23,7 @@ #include "vulkan.hpp" #include "device.hpp" -namespace BluCat::Image +namespace BluCat::GRA::Image { struct Error: public std::exception @@ -40,7 +40,7 @@ private: void create( - BluCat::Device *device, + BluCat::GRA::Device *device, VkImage *image, VkDeviceMemory *image_memory, VkFormat format, @@ -63,11 +63,11 @@ move_image_state( void create_view( - BluCat::Device *device, + BluCat::GRA::Device *device, VkImageView *image_view, const VkImage &image, VkFormat format, VkImageAspectFlags image_aspect_flags); } -#endif /* CANDY_GEAR_BLUCAT_IMAGE_H */ +#endif /* BLU_CAT_GRA_IMAGE_H */ diff --git a/src/blucat/light.cpp b/src/blu_cat/gra/light.cpp index 43611a1..403dcf4 100644 --- a/src/blucat/light.cpp +++ b/src/blu_cat/gra/light.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -27,14 +27,14 @@ namespace void load_world_vert_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); try { - self->ub_world_vert.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->ub_world_vert.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->ub_world_vert.emplace_back( - BluCat::core.vk_device_with_swapchain, sizeof(BluCat::UDOWorld3D_Vert)); + BluCat::INT::core.vk_device_with_swapchain, sizeof(BluCat::GRA::UDOWorld3D_Vert)); } catch(const std::exception& e) { @@ -45,7 +45,7 @@ load_world_vert_uniform_buffer(void *obj) void unload_world_vert_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); self->ub_world_vert.clear(); } @@ -53,14 +53,14 @@ unload_world_vert_uniform_buffer(void *obj) void load_world_frag_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); try { - self->ub_world_frag.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->ub_world_frag.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->ub_world_frag.emplace_back( - BluCat::core.vk_device_with_swapchain, sizeof(BluCat::UDOWorld3D_Frag)); + BluCat::INT::core.vk_device_with_swapchain, sizeof(BluCat::GRA::UDOWorld3D_Frag)); } catch(const std::exception& e) { @@ -71,7 +71,7 @@ load_world_frag_uniform_buffer(void *obj) void unload_world_frag_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); self->ub_world_frag.clear(); } @@ -79,7 +79,7 @@ unload_world_frag_uniform_buffer(void *obj) void load_descriptor_pool(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); uint32_t uniform_buffers_count = self->ub_world_vert.size() + self->ub_world_vert.size(); @@ -97,7 +97,7 @@ load_descriptor_pool(void *obj) pool_info.pPoolSizes = &descriptor_pool_size; if(vkCreateDescriptorPool( - BluCat::core.vk_device_with_swapchain->device, &pool_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &pool_info, nullptr, &self->descriptor_pool) != VK_SUCCESS) throw CommandError{"Failed to create a Vulkan descriptor pool."}; } @@ -105,21 +105,21 @@ load_descriptor_pool(void *obj) void unload_descriptor_pool(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); vkDestroyDescriptorPool( - BluCat::core.vk_device_with_swapchain->device, self->descriptor_pool, + BluCat::INT::core.vk_device_with_swapchain->device, self->descriptor_pool, nullptr); } void load_descriptor_sets_world(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->world); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->world); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -129,7 +129,7 @@ load_descriptor_sets_world(void *obj) self->descriptor_sets_world.resize(layouts.size()); if(vkAllocateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, &alloc_info, + BluCat::INT::core.vk_device_with_swapchain->device, &alloc_info, self->descriptor_sets_world.data()) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan world descriptor set."}; } @@ -137,19 +137,19 @@ load_descriptor_sets_world(void *obj) void load_resources_to_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::Light*>(obj); + auto self = static_cast<BluCat::GRA::Light*>(obj); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) { VkDescriptorBufferInfo world_vert_info{}; world_vert_info.buffer = self->ub_world_vert[i].buffer; world_vert_info.offset = 0; - world_vert_info.range = sizeof(BluCat::UDOWorld3D_Vert); + world_vert_info.range = sizeof(BluCat::GRA::UDOWorld3D_Vert); VkDescriptorBufferInfo world_frag_info{}; world_frag_info.buffer = self->ub_world_frag[i].buffer; world_frag_info.offset = 0; - world_frag_info.range = sizeof(BluCat::UDOWorld3D_Frag); + world_frag_info.range = sizeof(BluCat::GRA::UDOWorld3D_Frag); std::array<VkWriteDescriptorSet, 2> write_descriptors{}; write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -173,7 +173,7 @@ load_resources_to_descriptor_sets(void *obj) write_descriptors[1].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); } } @@ -189,7 +189,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Light::Light() diff --git a/src/blucat/light.hpp b/src/blu_cat/gra/light.hpp index f5f153e..22a9e2d 100644 --- a/src/blucat/light.hpp +++ b/src/blu_cat/gra/light.hpp @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_LIGHT_H -#define CANDY_GEAR_BLUCAT_LIGHT_H 1 +#ifndef BLU_CAT_GRA_LIGHT_H +#define BLU_CAT_GRA_LIGHT_H 1 #include "vulkan.hpp" #include "uniform_buffer.hpp" -namespace BluCat +namespace BluCat::GRA { struct Light @@ -38,4 +38,4 @@ struct Light } -#endif /* CANDY_GEAR_BLUCAT_LIGHT_H */ +#endif /* BLU_CAT_GRA_LIGHT_H */ diff --git a/src/blucat/log.cpp b/src/blu_cat/gra/log.cpp index 78044c4..78044c4 100644 --- a/src/blucat/log.cpp +++ b/src/blu_cat/gra/log.cpp diff --git a/src/blucat/log.hpp b/src/blu_cat/gra/log.hpp index 2856f20..2856f20 100644 --- a/src/blucat/log.hpp +++ b/src/blu_cat/gra/log.hpp diff --git a/src/blucat/qoi.cpp b/src/blu_cat/gra/qoi.cpp index 3169ecc..790516d 100644 --- a/src/blucat/qoi.cpp +++ b/src/blu_cat/gra/qoi.cpp @@ -92,7 +92,7 @@ color_hash(const RGBA &colors) } -namespace BluCat::QOI +namespace BluCat::GRA::QOI { Image::Image(const char *file_path, uint8_t channels): diff --git a/src/blucat/qoi.hpp b/src/blu_cat/gra/qoi.hpp index cd33205..f8be4ec 100644 --- a/src/blucat/qoi.hpp +++ b/src/blu_cat/gra/qoi.hpp @@ -16,7 +16,7 @@ #include <cstdint> -namespace BluCat::QOI +namespace BluCat::GRA::QOI { struct Header { diff --git a/src/blucat/queue.cpp b/src/blu_cat/gra/queue.cpp index c00d874..3f47a19 100644 --- a/src/blucat/queue.cpp +++ b/src/blu_cat/gra/queue.cpp @@ -18,11 +18,11 @@ #include "queue_family.hpp" -namespace BluCat +namespace BluCat::GRA { Queue::Queue( - BluCat::QueueFamily *queue_family, VkQueue queue, int queue_index): + BluCat::GRA::QueueFamily *queue_family, VkQueue queue, int queue_index): queue_family{queue_family}, queue{queue}, queue_index{queue_index} diff --git a/src/blucat/queue.hpp b/src/blu_cat/gra/queue.hpp index 3be1a94..3dc9833 100644 --- a/src/blucat/queue.hpp +++ b/src/blu_cat/gra/queue.hpp @@ -14,18 +14,18 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_QUEUE_H -#define CANDY_GEAR_BLUCAT_QUEUE_H 1 +#ifndef BLU_CAT_GRA_QUEUE_H +#define BLU_CAT_GRA_QUEUE_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { class QueueFamily; struct Queue { - friend class BluCat::QueueFamily; + friend class BluCat::GRA::QueueFamily; Queue(const Queue &t) = delete; Queue& operator=(const Queue &t) = delete; @@ -42,10 +42,10 @@ struct Queue ~Queue(); private: - BluCat::QueueFamily *queue_family; + BluCat::GRA::QueueFamily *queue_family; int queue_index; - Queue(BluCat::QueueFamily *queue_family, VkQueue queue, int queue_index); + Queue(BluCat::GRA::QueueFamily *queue_family, VkQueue queue, int queue_index); }; template<typename T> void @@ -79,4 +79,4 @@ Queue::submit_one_time_command( } -#endif /* CANDY_GEAR_BLUCAT_QUEUE_H */ +#endif /* BLU_CAT_GRA_QUEUE_H */ diff --git a/src/blucat/queue_family.cpp b/src/blu_cat/gra/queue_family.cpp index da799c0..59086b5 100644 --- a/src/blucat/queue_family.cpp +++ b/src/blu_cat/gra/queue_family.cpp @@ -20,13 +20,13 @@ #include <sstream> #endif -#include "core.hpp" +#include "../int/core.hpp" -namespace BluCat +namespace BluCat::GRA { QueueFamily::QueueFamily( - BluCat::Device *device, uint32_t family_index, + BluCat::GRA::Device *device, uint32_t family_index, const VkQueueFamilyProperties &queue_family_properties): queue_mutex{} { @@ -47,7 +47,7 @@ QueueFamily::QueueFamily( message << "Sparse Binding: " << (queue_family_properties.queueFlags & VK_QUEUE_SPARSE_BINDING_BIT ? "true" : "false") << std::endl; - core.log.message(Log::Level::Trace, message.str()); + INT::core.log.message(Log::Level::Trace, message.str()); #endif this->device = device; diff --git a/src/blucat/queue_family.hpp b/src/blu_cat/gra/queue_family.hpp index 988748f..4673058 100644 --- a/src/blucat/queue_family.hpp +++ b/src/blu_cat/gra/queue_family.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_QUEUE_FAMILY_H -#define CANDY_GEAR_BLUCAT_QUEUE_FAMILY_H 1 +#ifndef BLU_CAT_GRA_QUEUE_FAMILY_H +#define BLU_CAT_GRA_QUEUE_FAMILY_H 1 #include <mutex> #include <vector> @@ -23,7 +23,7 @@ #include "vulkan.hpp" #include "queue.hpp" -namespace BluCat +namespace BluCat::GRA { class Device; @@ -41,12 +41,12 @@ class QueueFamily std::vector<QueueState> queue_states; public: - BluCat::Device *device; + BluCat::GRA::Device *device; uint32_t family_index; VkQueueFamilyProperties family_properties; - QueueFamily(BluCat::Device *device, uint32_t family_index, + QueueFamily(BluCat::GRA::Device *device, uint32_t family_index, const VkQueueFamilyProperties &queue_family_properties); Queue @@ -55,4 +55,4 @@ public: } -#endif /* CANDY_GEAR_BLUCAT_QUEUE_FAMILY_H */ +#endif /* BLU_CAT_GRA_QUEUE_FAMILY_H */ diff --git a/src/blucat/rectangle.cpp b/src/blu_cat/gra/rectangle.cpp index 34f844d..ea01a04 100644 --- a/src/blucat/rectangle.cpp +++ b/src/blu_cat/gra/rectangle.cpp @@ -16,7 +16,7 @@ #include "rectangle.hpp" -namespace BluCat +namespace BluCat::GRA { const int Rectangle::VertexCount{4}; diff --git a/src/blucat/rectangle.hpp b/src/blu_cat/gra/rectangle.hpp index 57c9d4f..cd09239 100644 --- a/src/blucat/rectangle.hpp +++ b/src/blu_cat/gra/rectangle.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_RECTANGLE_H -#define CANDY_GEAR_BLUCAT_RECTANGLE_H 1 +#ifndef BLU_CAT_GRA_RECTANGLE_H +#define BLU_CAT_GRA_RECTANGLE_H 1 #include <vector> @@ -24,7 +24,7 @@ #include "queue_family.hpp" #include "uniform_buffer.hpp" -namespace BluCat +namespace BluCat::GRA { struct Rectangle @@ -39,4 +39,4 @@ struct Rectangle } -#endif /* CANDY_GEAR_BLUCAT_RECTANGLE_H */ +#endif /* BLU_CAT_GRA_RECTANGLE_H */ diff --git a/src/blucat/render_pass.cpp b/src/blu_cat/gra/render_pass.cpp index 2effe6b..64fdf56 100644 --- a/src/blucat/render_pass.cpp +++ b/src/blu_cat/gra/render_pass.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" namespace { @@ -26,12 +26,12 @@ namespace void load_3d(void *obj) { - auto self = static_cast<BluCat::RenderPass*>(obj); + auto self = static_cast<BluCat::GRA::RenderPass*>(obj); std::array<VkAttachmentDescription, 2> attachments{}; // Color attachment. attachments[0].flags = 0; - attachments[0].format = BluCat::core.vk_swapchain->image_format; + attachments[0].format = BluCat::INT::core.vk_swapchain->image_format; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -95,7 +95,7 @@ load_3d(void *obj) render_pass_info.pDependencies = &dependency; if(vkCreateRenderPass( - BluCat::core.vk_device_with_swapchain->device, &render_pass_info, + BluCat::INT::core.vk_device_with_swapchain->device, &render_pass_info, nullptr, &self->pipeline_3d) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan Render Pass 3D."}; } @@ -103,21 +103,21 @@ load_3d(void *obj) void unload_3d(void *obj) { - auto self = static_cast<BluCat::RenderPass*>(obj); + auto self = static_cast<BluCat::GRA::RenderPass*>(obj); vkDestroyRenderPass( - BluCat::core.vk_device_with_swapchain->device, self->pipeline_3d, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->pipeline_3d, nullptr); } void load_2d(void *obj) { - auto self = static_cast<BluCat::RenderPass*>(obj); + auto self = static_cast<BluCat::GRA::RenderPass*>(obj); std::array<VkAttachmentDescription, 1> attachments{}; // Color attachment. attachments[0].flags = 0; - attachments[0].format = BluCat::core.vk_swapchain->image_format; + attachments[0].format = BluCat::INT::core.vk_swapchain->image_format; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -166,7 +166,7 @@ load_2d(void *obj) render_pass_info.pDependencies = &dependency; if(vkCreateRenderPass( - BluCat::core.vk_device_with_swapchain->device, &render_pass_info, + BluCat::INT::core.vk_device_with_swapchain->device, &render_pass_info, nullptr, &self->pipeline_2d) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan Render Pass 2D."}; } @@ -174,10 +174,10 @@ load_2d(void *obj) void unload_2d(void *obj) { - auto self = static_cast<BluCat::RenderPass*>(obj); + auto self = static_cast<BluCat::GRA::RenderPass*>(obj); vkDestroyRenderPass( - BluCat::core.vk_device_with_swapchain->device, self->pipeline_2d, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->pipeline_2d, nullptr); } const CommandChain loader{ @@ -187,7 +187,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { RenderPass::RenderPass() diff --git a/src/blucat/render_pass.hpp b/src/blu_cat/gra/render_pass.hpp index d55f908..4187261 100644 --- a/src/blucat/render_pass.hpp +++ b/src/blu_cat/gra/render_pass.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_RENDER_PASS_H -#define CANDY_GEAR_BLUCAT_RENDER_PASS_H 1 +#ifndef BLU_CAT_GRA_RENDER_PASS_H +#define BLU_CAT_GRA_RENDER_PASS_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct RenderPass @@ -33,4 +33,4 @@ struct RenderPass } -#endif /* CANDY_GEAR_BLUCAT_RENDER_PASS_H */ +#endif /* BLU_CAT_GRA_RENDER_PASS_H */ diff --git a/src/blucat/renderer.cpp b/src/blu_cat/gra/renderer.cpp index 18d3976..ad66003 100644 --- a/src/blucat/renderer.cpp +++ b/src/blu_cat/gra/renderer.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -27,7 +27,7 @@ namespace void load_descriptor_pool(void *obj) { - auto self = static_cast<BluCat::Renderer*>(obj); + auto self = static_cast<BluCat::GRA::Renderer*>(obj); uint32_t uniform_buffer_count = 0; for(auto &view : self->views_3d) @@ -48,7 +48,7 @@ load_descriptor_pool(void *obj) pool_info.pPoolSizes = &descriptor_pool_size; if(vkCreateDescriptorPool( - BluCat::core.vk_device_with_swapchain->device, &pool_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &pool_info, nullptr, &self->descriptor_pool) != VK_SUCCESS) throw CommandError{"Failed to create a Vulkan descriptor pool."}; @@ -61,29 +61,29 @@ load_descriptor_pool(void *obj) void unload_descriptor_pool(void *obj) { - auto self = static_cast<BluCat::Renderer*>(obj); + auto self = static_cast<BluCat::GRA::Renderer*>(obj); for(auto &view : self->views_3d) view->unload_descriptor_sets(); for(auto &view : self->views_2d) view->unload_descriptor_sets(); vkDestroyDescriptorPool( - BluCat::core.vk_device_with_swapchain->device, self->descriptor_pool, + BluCat::INT::core.vk_device_with_swapchain->device, self->descriptor_pool, nullptr); } void load_queue_family(void *obj) { - auto self = static_cast<BluCat::Renderer*>(obj); + auto self = static_cast<BluCat::GRA::Renderer*>(obj); self->queue_family = - BluCat::core.vk_device_with_swapchain->get_queue_family_with_presentation(); + BluCat::INT::core.vk_device_with_swapchain->get_queue_family_with_presentation(); } void load_command_pool(void *obj) { - auto self = static_cast<BluCat::Renderer*>(obj); + auto self = static_cast<BluCat::GRA::Renderer*>(obj); VkCommandPoolCreateInfo create_info{}; create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; @@ -99,7 +99,7 @@ load_command_pool(void *obj) void unload_command_pool(void *obj) { - auto self = static_cast<BluCat::Renderer*>(obj); + auto self = static_cast<BluCat::GRA::Renderer*>(obj); self->wait_frame(); vkDestroyCommandPool( @@ -109,7 +109,7 @@ unload_command_pool(void *obj) void load_draw_command_buffer(void *obj) { - auto self = static_cast<BluCat::Renderer*>(obj); + auto self = static_cast<BluCat::GRA::Renderer*>(obj); // FIXME: 3 is a magical number, triple buffering. self->draw_command_buffers.resize(3); @@ -136,14 +136,14 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Renderer::Renderer(std::vector<std::shared_ptr<View2D>> views_2d, std::vector<std::shared_ptr<View3D>> views_3d): - skeletal_models_to_draw{BluCat::core.vk_swapchain->images_count}, - static_models_to_draw{BluCat::core.vk_swapchain->images_count}, - sprites_3d_to_draw{BluCat::core.vk_swapchain->images_count}, + skeletal_models_to_draw{BluCat::INT::core.vk_swapchain->images_count}, + static_models_to_draw{BluCat::INT::core.vk_swapchain->images_count}, + sprites_3d_to_draw{BluCat::INT::core.vk_swapchain->images_count}, views_2d{views_2d}, views_3d{views_3d} { @@ -166,9 +166,9 @@ Renderer::~Renderer() void Renderer::wait_frame() { - vkWaitForFences(BluCat::core.vk_device_with_swapchain->device, - BluCat::Swapchain::max_frames_in_flight, - BluCat::core.vk_swapchain->in_flight_fences.data(), VK_TRUE, + vkWaitForFences(BluCat::INT::core.vk_device_with_swapchain->device, + BluCat::GRA::Swapchain::max_frames_in_flight, + BluCat::INT::core.vk_swapchain->in_flight_fences.data(), VK_TRUE, std::numeric_limits<uint64_t>::max()); } @@ -176,29 +176,29 @@ void Renderer::draw() { auto fence_status = vkGetFenceStatus( - BluCat::core.vk_device_with_swapchain->device, - BluCat::core.vk_swapchain->in_flight_fences[ - BluCat::core.vk_swapchain->current_frame]); + BluCat::INT::core.vk_device_with_swapchain->device, + BluCat::INT::core.vk_swapchain->in_flight_fences[ + BluCat::INT::core.vk_swapchain->current_frame]); if(fence_status == VK_SUCCESS) { - auto next_frame = BluCat::core.vk_swapchain->current_frame + 1; + auto next_frame = BluCat::INT::core.vk_swapchain->current_frame + 1; if(next_frame == Swapchain::max_frames_in_flight) next_frame = 0; - vkResetFences(core.vk_device_with_swapchain->device, 1, - &BluCat::core.vk_swapchain->in_flight_fences[ - BluCat::core.vk_swapchain->current_frame]); + vkResetFences(INT::core.vk_device_with_swapchain->device, 1, + &BluCat::INT::core.vk_swapchain->in_flight_fences[ + BluCat::INT::core.vk_swapchain->current_frame]); uint32_t image_index; vkAcquireNextImageKHR( - BluCat::core.vk_device_with_swapchain->device, - BluCat::core.vk_swapchain->swapchain, + BluCat::INT::core.vk_device_with_swapchain->device, + BluCat::INT::core.vk_swapchain->swapchain, std::numeric_limits<uint64_t>::max(), - BluCat::core.vk_swapchain->image_available_semaphores[ - BluCat::core.vk_swapchain->current_frame], VK_NULL_HANDLE, &image_index); + BluCat::INT::core.vk_swapchain->image_available_semaphores[ + BluCat::INT::core.vk_swapchain->current_frame], VK_NULL_HANDLE, &image_index); VkCommandBuffer draw_command_buffer = - this->draw_command_buffers[BluCat::core.vk_swapchain->current_frame]; + this->draw_command_buffers[BluCat::INT::core.vk_swapchain->current_frame]; vkResetCommandBuffer(draw_command_buffer, 0); // Begin command buffer. @@ -222,7 +222,7 @@ Renderer::draw() UDOWorld3D_Vert ubo_world_3d_vert{}; ubo_world_3d_vert.ambient_light_color = glm::vec4{0.25, 0.25, 0.25, 1.0}; - BluCat::core.vk_light->ub_world_vert[image_index].copy_data( + BluCat::INT::core.vk_light->ub_world_vert[image_index].copy_data( &ubo_world_3d_vert); UDOWorld3D_Frag ubo_world_3d_frag{}; @@ -230,20 +230,20 @@ Renderer::draw() glm::vec3{-0.57735, 0.57735, -0.57735}; ubo_world_3d_frag.directional_light_color = glm::vec4{0.8, 0.8, 0.8, 1.0}; - BluCat::core.vk_light->ub_world_frag[image_index].copy_data( + BluCat::INT::core.vk_light->ub_world_frag[image_index].copy_data( &ubo_world_3d_frag); } VkRenderPassBeginInfo render_pass_begin{}; render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; render_pass_begin.pNext = nullptr; - render_pass_begin.renderPass = BluCat::core.vk_render_pass->pipeline_3d; + render_pass_begin.renderPass = BluCat::INT::core.vk_render_pass->pipeline_3d; render_pass_begin.framebuffer = - BluCat::core.vk_framebuffer->pipeline_3d[image_index]; + BluCat::INT::core.vk_framebuffer->pipeline_3d[image_index]; render_pass_begin.renderArea.offset = {0, 0}; render_pass_begin.renderArea.extent = { - static_cast<uint32_t>(BluCat::core.display_width), - static_cast<uint32_t>(BluCat::core.display_height)}; + static_cast<uint32_t>(BluCat::INT::core.display_width), + static_cast<uint32_t>(BluCat::INT::core.display_height)}; render_pass_begin.clearValueCount = clear_values.size(); render_pass_begin.pClearValues = clear_values.data(); @@ -271,20 +271,20 @@ Renderer::draw() vkCmdSetScissor(draw_command_buffer, 0, 1, &vk_scissor); } - BluCat::core.vk_graphics_pipeline_3d->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_3d->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, image_index); - BluCat::core.vk_graphics_pipeline_sprite_3d->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_sprite_3d->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, image_index); - BluCat::core.vk_graphics_pipeline_3d_skeletal->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_3d_skeletal->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, image_index); { // Update view uniform buffers - BluCat::UDOView3D ubo_view_3d{}; + BluCat::GRA::UDOView3D ubo_view_3d{}; // View matrix. glm::mat4 translation_matrix{1.0f}; @@ -309,13 +309,13 @@ Renderer::draw() VkRenderPassBeginInfo render_pass_begin{}; render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; render_pass_begin.pNext = nullptr; - render_pass_begin.renderPass = BluCat::core.vk_render_pass->pipeline_2d; + render_pass_begin.renderPass = BluCat::INT::core.vk_render_pass->pipeline_2d; render_pass_begin.framebuffer = - BluCat::core.vk_framebuffer->pipeline_2d[image_index]; + BluCat::INT::core.vk_framebuffer->pipeline_2d[image_index]; render_pass_begin.renderArea.offset = {0, 0}; render_pass_begin.renderArea.extent = { - static_cast<uint32_t>(BluCat::core.display_width), - static_cast<uint32_t>(BluCat::core.display_height)}; + static_cast<uint32_t>(BluCat::INT::core.display_width), + static_cast<uint32_t>(BluCat::INT::core.display_height)}; render_pass_begin.clearValueCount = 0; render_pass_begin.pClearValues = nullptr; @@ -326,25 +326,25 @@ Renderer::draw() { // 2D solid drawing for(auto &view: this->views_2d) - BluCat::core.vk_graphics_pipeline_2d_solid->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_2d_solid->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, next_frame, image_index); for(auto &view: this->views_3d) - BluCat::core.vk_graphics_pipeline_2d_solid->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_2d_solid->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, next_frame, image_index); } { // 2D wired drawing for(auto &view: this->views_2d) - BluCat::core.vk_graphics_pipeline_2d_wired->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_2d_wired->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, next_frame, image_index); for(auto &view: this->views_3d) - BluCat::core.vk_graphics_pipeline_2d_wired->draw( - view, draw_command_buffer, BluCat::core.vk_swapchain->current_frame, + BluCat::INT::core.vk_graphics_pipeline_2d_wired->draw( + view, draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, next_frame, image_index); } @@ -359,13 +359,13 @@ Renderer::draw() auto queue{this->queue_family->get_queue()}; VkSemaphore wait_semaphores[]{ - BluCat::core.vk_swapchain->image_available_semaphores[ - BluCat::core.vk_swapchain->current_frame]}; + BluCat::INT::core.vk_swapchain->image_available_semaphores[ + BluCat::INT::core.vk_swapchain->current_frame]}; VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT}; VkSemaphore signal_semaphores[]{ - BluCat::core.vk_swapchain->render_finished_semaphores[ - BluCat::core.vk_swapchain->current_frame]}; + BluCat::INT::core.vk_swapchain->render_finished_semaphores[ + BluCat::INT::core.vk_swapchain->current_frame]}; VkSubmitInfo submit_info{}; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; @@ -379,11 +379,11 @@ Renderer::draw() submit_info.pSignalSemaphores = signal_semaphores; if(vkQueueSubmit( - queue.queue, 1, &submit_info, BluCat::core.vk_swapchain->in_flight_fences[ - BluCat::core.vk_swapchain->current_frame]) != VK_SUCCESS) + queue.queue, 1, &submit_info, BluCat::INT::core.vk_swapchain->in_flight_fences[ + BluCat::INT::core.vk_swapchain->current_frame]) != VK_SUCCESS) throw std::runtime_error{"Failed to submit draw command buffer."}; - VkSwapchainKHR swap_chains[]{BluCat::core.vk_swapchain->swapchain}; + VkSwapchainKHR swap_chains[]{BluCat::INT::core.vk_swapchain->swapchain}; VkPresentInfoKHR present_info{}; present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; @@ -403,22 +403,22 @@ Renderer::draw() this->skeletal_models_to_draw[next_frame].clear(); this->static_models_to_draw[next_frame].clear(); this->sprites_3d_to_draw[next_frame].clear(); - BluCat::core.vk_swapchain->current_frame = next_frame; + BluCat::INT::core.vk_swapchain->current_frame = next_frame; } } else { // Clear images for the current frame because we are skipping this frame. this->skeletal_models_to_draw[ - BluCat::core.vk_swapchain->current_frame].clear(); + BluCat::INT::core.vk_swapchain->current_frame].clear(); this->static_models_to_draw[ - BluCat::core.vk_swapchain->current_frame].clear(); + BluCat::INT::core.vk_swapchain->current_frame].clear(); this->sprites_3d_to_draw[ - BluCat::core.vk_swapchain->current_frame].clear(); + BluCat::INT::core.vk_swapchain->current_frame].clear(); for(auto &view: this->views_2d) - view->sprites_to_draw[BluCat::core.vk_swapchain->current_frame].clear(); + view->sprites_to_draw[BluCat::INT::core.vk_swapchain->current_frame].clear(); for(auto &view: this->views_3d) - view->sprites_to_draw[BluCat::core.vk_swapchain->current_frame].clear(); + view->sprites_to_draw[BluCat::INT::core.vk_swapchain->current_frame].clear(); } } diff --git a/src/blucat/renderer.hpp b/src/blu_cat/gra/renderer.hpp index 55b0727..0a3d15f 100644 --- a/src/blucat/renderer.hpp +++ b/src/blu_cat/gra/renderer.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_RENDERER_H -#define CANDY_GEAR_BLUCAT_RENDERER_H 1 +#ifndef BLU_CAT_GRA_RENDERER_H +#define BLU_CAT_GRA_RENDERER_H 1 #include <initializer_list> #include <memory> @@ -31,7 +31,7 @@ #include "view_2d.hpp" #include "view_3d.hpp" -namespace BluCat +namespace BluCat::GRA { struct Renderer @@ -72,4 +72,4 @@ struct Renderer } -#endif /* CANDY_GEAR_BLUCAT_RENDERER_H */ +#endif /* BLU_CAT_GRA_RENDERER_H */ diff --git a/src/blucat/skeletal_mesh.cpp b/src/blu_cat/gra/skeletal_mesh.cpp index d4fbfe7..89d701b 100644 --- a/src/blucat/skeletal_mesh.cpp +++ b/src/blu_cat/gra/skeletal_mesh.cpp @@ -17,8 +17,8 @@ #include "skeletal_mesh.hpp" #include "binary_reader.hpp" -#include "command.hpp" -#include "core.hpp" +#include "../com/command.hpp" +#include "../int/core.hpp" #include "skeletal_mesh_vertex.hpp" namespace @@ -29,19 +29,19 @@ namespace struct MeshBuilder { std::string mesh_path; - BluCat::SkeletalMesh *mesh; + BluCat::GRA::SkeletalMesh *mesh; - MeshBuilder(BluCat::SkeletalMesh *m, std::string mp); - MeshBuilder(BluCat::SkeletalMesh *m, const char* mp); + MeshBuilder(BluCat::GRA::SkeletalMesh *m, std::string mp); + MeshBuilder(BluCat::GRA::SkeletalMesh *m, const char* mp); }; -MeshBuilder::MeshBuilder(BluCat::SkeletalMesh *m, std::string mp): +MeshBuilder::MeshBuilder(BluCat::GRA::SkeletalMesh *m, std::string mp): mesh{m}, mesh_path{mp} { } -MeshBuilder::MeshBuilder(BluCat::SkeletalMesh *m, const char *mp): +MeshBuilder::MeshBuilder(BluCat::GRA::SkeletalMesh *m, const char *mp): MeshBuilder{m, std::string(mp)} { } @@ -54,11 +54,11 @@ load_mesh(void *obj) BinaryReader input{self->mesh_path}; self->mesh->queue_family = - BluCat::core.vk_device_with_swapchain->get_queue_family_with_graphics(); + BluCat::INT::core.vk_device_with_swapchain->get_queue_family_with_graphics(); { // Load vertexes. auto vertex_count{input.read_ui32()}; - std::vector<BluCat::SkeletalMeshVertex> vertexes{vertex_count}; + std::vector<BluCat::GRA::SkeletalMeshVertex> vertexes{vertex_count}; for(auto i{0}; i < vertex_count; i++) { @@ -66,20 +66,20 @@ load_mesh(void *obj) vertexes[i].normal = input.read_vec3(); vertexes[i].texture_coord = input.read_vec2(); - for(auto ii{0}; ii < BluCat::SKELETAL_MESH_MAX_NUM_OF_INFLUENCING_BONES; + for(auto ii{0}; ii < BluCat::GRA::SKELETAL_MESH_MAX_NUM_OF_INFLUENCING_BONES; ii++) vertexes[i].bone_ids[ii] = input.read_ui32(); - for(auto ii{0}; ii < BluCat::SKELETAL_MESH_MAX_NUM_OF_INFLUENCING_BONES; + for(auto ii{0}; ii < BluCat::GRA::SKELETAL_MESH_MAX_NUM_OF_INFLUENCING_BONES; ii++) vertexes[i].bone_weights[ii] = input.read_float(); } void *vertexes_data{vertexes.data()}; size_t vertexes_size = sizeof(vertexes[0]) * vertexes.size(); - self->mesh->source_vertex_buffer = new BluCat::SourceBuffer{ + self->mesh->source_vertex_buffer = new BluCat::GRA::SourceBuffer{ self->mesh->queue_family->device, vertexes_data, vertexes_size}; - self->mesh->vertex_buffer = new BluCat::DestinationBuffer{ + self->mesh->vertex_buffer = new BluCat::GRA::DestinationBuffer{ self->mesh->queue_family, self->mesh->source_vertex_buffer, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT}; } @@ -93,9 +93,9 @@ load_mesh(void *obj) void *indexes_data{indexes.data()}; size_t indexes_size{sizeof(indexes[0]) * indexes.size()}; - BluCat::SourceBuffer source_index_buffer{ + BluCat::GRA::SourceBuffer source_index_buffer{ self->mesh->queue_family->device, indexes_data, indexes_size}; - self->mesh->index_buffer = new BluCat::DestinationBuffer{ + self->mesh->index_buffer = new BluCat::GRA::DestinationBuffer{ self->mesh->queue_family, &source_index_buffer, VK_BUFFER_USAGE_INDEX_BUFFER_BIT}; } @@ -118,7 +118,7 @@ load_mesh(void *obj) auto ticks_per_second{input.read_double()}; auto num_bone_transforms{input.read_ui32()}; - std::vector<BluCat::BoneTransform> *bone_transforms = + std::vector<BluCat::GRA::BoneTransform> *bone_transforms = &(self->mesh->animations[i].bone_transforms); bone_transforms->resize(num_bone_transforms); for(uint32_t bone_transform_index{0}; @@ -127,7 +127,7 @@ load_mesh(void *obj) auto bone_id{input.read_ui32()}; auto num_positions{input.read_ui32()}; - BluCat::Channel<glm::vec3> *positions = + BluCat::GRA::Channel<glm::vec3> *positions = &((*bone_transforms)[bone_transform_index].positions); for(auto position_key_index{0}; position_key_index < num_positions; position_key_index++) @@ -139,7 +139,7 @@ load_mesh(void *obj) } auto num_rotations{input.read_ui32()}; - BluCat::Channel<glm::quat> *rotations = + BluCat::GRA::Channel<glm::quat> *rotations = &((*bone_transforms)[bone_transform_index].rotations); for(auto rotation_key_index{0}; rotation_key_index < num_rotations; rotation_key_index++) @@ -151,7 +151,7 @@ load_mesh(void *obj) } auto num_scales{input.read_ui32()}; - BluCat::Channel<glm::vec3> *scales = + BluCat::GRA::Channel<glm::vec3> *scales = &((*bone_transforms)[bone_transform_index].scales); for(auto scaling_key_index{0}; scaling_key_index < num_scales; scaling_key_index++) @@ -181,7 +181,7 @@ static const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { SkeletalMesh::SkeletalMesh(std::string mesh_path) diff --git a/src/blucat/skeletal_mesh.hpp b/src/blu_cat/gra/skeletal_mesh.hpp index 98506d7..f586ea3 100644 --- a/src/blucat/skeletal_mesh.hpp +++ b/src/blu_cat/gra/skeletal_mesh.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SKELETAL_MESH_H -#define CANDY_GEAR_BLUCAT_SKELETAL_MESH_H 1 +#ifndef BLU_CAT_GRA_SKELETAL_MESH_H +#define BLU_CAT_GRA_SKELETAL_MESH_H 1 #include <string> #include <vector> @@ -27,7 +27,7 @@ #include "uniform_buffer.hpp" #include "texture.hpp" -namespace BluCat +namespace BluCat::GRA { struct SkeletalMesh @@ -49,4 +49,4 @@ struct SkeletalMesh } -#endif /* CANDY_GEAR_BLUCAT_SKELETAL_MESH_H */ +#endif /* BLU_CAT_GRA_SKELETAL_MESH_H */ diff --git a/src/blucat/skeletal_mesh_vertex.hpp b/src/blu_cat/gra/skeletal_mesh_vertex.hpp index 2e8a56f..1bd70ad 100644 --- a/src/blucat/skeletal_mesh_vertex.hpp +++ b/src/blu_cat/gra/skeletal_mesh_vertex.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SKELETAL_MESH_VERTEX_H -#define CANDY_GEAR_BLUCAT_SKELETAL_MESH_VERTEX_H 1 +#ifndef BLU_CAT_GRA_SKELETAL_MESH_VERTEX_H +#define BLU_CAT_GRA_SKELETAL_MESH_VERTEX_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { // This variable define the maximum ammount of bones that can influence a @@ -39,4 +39,4 @@ struct SkeletalMeshVertex } -#endif /* CANDY_GEAR_BLUCAT_SKELETAL_MESH_VERTEX_H */ +#endif /* BLU_CAT_GRA_SKELETAL_MESH_VERTEX_H */ diff --git a/src/blucat/skeletal_model.cpp b/src/blu_cat/gra/skeletal_model.cpp index fa46044..b58982d 100644 --- a/src/blucat/skeletal_model.cpp +++ b/src/blu_cat/gra/skeletal_model.cpp @@ -16,7 +16,7 @@ #include "skeletal_model.hpp" -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -25,15 +25,15 @@ namespace void load_uniform_buffers(void *obj) { - auto self = static_cast<BluCat::SkeletalModel*>(obj); + auto self = static_cast<BluCat::GRA::SkeletalModel*>(obj); try { - self->uniform_buffers.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->uniform_buffers.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->uniform_buffers.emplace_back( - BluCat::core.vk_device_with_swapchain, - sizeof(BluCat::UDOSkeletalModel)); + BluCat::INT::core.vk_device_with_swapchain, + sizeof(BluCat::GRA::UDOSkeletalModel)); } catch(const std::exception& e) { @@ -44,7 +44,7 @@ load_uniform_buffers(void *obj) void unload_uniform_buffers(void *obj) { - auto self = static_cast<BluCat::SkeletalModel*>(obj); + auto self = static_cast<BluCat::GRA::SkeletalModel*>(obj); self->uniform_buffers.clear(); } @@ -52,7 +52,7 @@ unload_uniform_buffers(void *obj) void load_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::SkeletalModel*>(obj); + auto self = static_cast<BluCat::GRA::SkeletalModel*>(obj); std::array<VkDescriptorPoolSize, 1> descriptor_pool_sizes{}; descriptor_pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; @@ -76,7 +76,7 @@ load_descriptor_set_pool(void *obj) void unload_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::SkeletalModel*>(obj); + auto self = static_cast<BluCat::GRA::SkeletalModel*>(obj); vkDestroyDescriptorPool( self->skeletal_mesh->queue_family->device->device, self->descriptor_pool, @@ -86,11 +86,11 @@ unload_descriptor_set_pool(void *obj) void load_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::SkeletalModel*>(obj); + auto self = static_cast<BluCat::GRA::SkeletalModel*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->model); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->model); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -108,14 +108,14 @@ load_descriptor_sets(void *obj) void load_buffers_to_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::SkeletalModel*>(obj); + auto self = static_cast<BluCat::GRA::SkeletalModel*>(obj); for(auto i{0}; i < self->uniform_buffers.size(); i++) { VkDescriptorBufferInfo buffer_info{}; buffer_info.buffer = self->uniform_buffers[i].buffer; buffer_info.offset = 0; - buffer_info.range = sizeof(BluCat::UDOSkeletalModel); + buffer_info.range = sizeof(BluCat::GRA::UDOSkeletalModel); std::array<VkWriteDescriptorSet, 1> write_descriptors{}; write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -129,7 +129,7 @@ load_buffers_to_descriptor_sets(void *obj) write_descriptors[0].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); } } @@ -143,7 +143,7 @@ static const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { SkeletalModel::SkeletalModel( @@ -172,7 +172,7 @@ SkeletalModel::~SkeletalModel() void SkeletalModel::tick(float delta) { - BluCat::Animation *current_animation = + BluCat::GRA::Animation *current_animation = &this->skeletal_mesh->animations[this->animation_index]; { // update time @@ -180,7 +180,7 @@ SkeletalModel::tick(float delta) if(this->animation_time > current_animation->final_time) { this->animation_time -= current_animation->final_time; - for(BluCat::BoneTransform &bone_transform: + for(BluCat::GRA::BoneTransform &bone_transform: current_animation->bone_transforms) { bone_transform.positions.current_index = 0; @@ -192,7 +192,7 @@ SkeletalModel::tick(float delta) for(int i{0}; i < current_animation->bone_transforms.size(); i++) { - BluCat::BoneTransform *bone_transform = ¤t_animation->bone_transforms[i]; + BluCat::GRA::BoneTransform *bone_transform = ¤t_animation->bone_transforms[i]; auto position{bone_transform->positions.interpolate( this->animation_time, diff --git a/src/blucat/skeletal_model.hpp b/src/blu_cat/gra/skeletal_model.hpp index 03be8e5..73998cb 100644 --- a/src/blucat/skeletal_model.hpp +++ b/src/blu_cat/gra/skeletal_model.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SKELETAL_MODEL_H -#define CANDY_GEAR_BLUCAT_SKELETAL_MODEL_H 1 +#ifndef BLU_CAT_GRA_SKELETAL_MODEL_H +#define BLU_CAT_GRA_SKELETAL_MODEL_H 1 #include <memory> #include <vector> @@ -23,7 +23,7 @@ #include "vulkan.hpp" #include "skeletal_mesh.hpp" -namespace BluCat +namespace BluCat::GRA { struct SkeletalModel @@ -52,4 +52,4 @@ struct SkeletalModel } -#endif /* CANDY_GEAR_BLUCAT_SKELETAL_MODEL_H */ +#endif /* BLU_CAT_GRA_SKELETAL_MODEL_H */ diff --git a/src/blucat/source_buffer.cpp b/src/blu_cat/gra/source_buffer.cpp index 41c40b9..18f263f 100644 --- a/src/blucat/source_buffer.cpp +++ b/src/blu_cat/gra/source_buffer.cpp @@ -18,7 +18,7 @@ #include <cstring> -namespace BluCat +namespace BluCat::GRA { SourceBuffer::SourceBuffer(Device *device, void *data, size_t data_size) @@ -31,7 +31,7 @@ SourceBuffer::SourceBuffer(Device *device, void *data, size_t data_size) try { - BluCat::BaseBuffer::loader.execute(static_cast<BluCat::BaseBuffer*>(this)); + BluCat::GRA::BaseBuffer::loader.execute(static_cast<BluCat::GRA::BaseBuffer*>(this)); } catch(const CommandError &command_error) { @@ -71,7 +71,7 @@ SourceBuffer::operator=(SourceBuffer &&that) SourceBuffer::~SourceBuffer() { - BluCat::BaseBuffer::loader.revert(static_cast<BluCat::BaseBuffer*>(this)); + BluCat::GRA::BaseBuffer::loader.revert(static_cast<BluCat::GRA::BaseBuffer*>(this)); } void diff --git a/src/blucat/source_buffer.hpp b/src/blu_cat/gra/source_buffer.hpp index dd52acc..4eecec9 100644 --- a/src/blucat/source_buffer.hpp +++ b/src/blu_cat/gra/source_buffer.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SOURCE_BUFFER_H -#define CANDY_GEAR_BLUCAT_SOURCE_BUFFER_H 1 +#ifndef BLU_CAT_GRA_SOURCE_BUFFER_H +#define BLU_CAT_GRA_SOURCE_BUFFER_H 1 #include "base_buffer.hpp" -namespace BluCat +namespace BluCat::GRA { struct SourceBuffer: public BaseBuffer @@ -42,4 +42,4 @@ struct SourceBuffer: public BaseBuffer } -#endif /* CANDY_GEAR_BLUCAT_SOURCE_BUFFER_H */ +#endif /* BLU_CAT_GRA_SOURCE_BUFFER_H */ diff --git a/src/blucat/sprite.cpp b/src/blu_cat/gra/sprite.cpp index 0c66a27..ee64efe 100644 --- a/src/blucat/sprite.cpp +++ b/src/blu_cat/gra/sprite.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "sprite.hpp" #include "uniform_data_object.hpp" @@ -27,13 +27,13 @@ namespace struct SpriteBuilder { - BluCat::Sprite *sprite; + BluCat::GRA::Sprite *sprite; const glm::vec4 ▭ - SpriteBuilder(BluCat::Sprite *sprite, const glm::vec4 &rect); + SpriteBuilder(BluCat::GRA::Sprite *sprite, const glm::vec4 &rect); }; -SpriteBuilder::SpriteBuilder(BluCat::Sprite *sprite, const glm::vec4 &rect): +SpriteBuilder::SpriteBuilder(BluCat::GRA::Sprite *sprite, const glm::vec4 &rect): sprite{sprite}, rect{rect} { @@ -45,9 +45,9 @@ load_mesh(void *obj) auto self = static_cast<SpriteBuilder*>(obj); self->sprite->queue_family = - BluCat::core.vk_device_with_swapchain->get_queue_family_with_graphics(); + BluCat::INT::core.vk_device_with_swapchain->get_queue_family_with_graphics(); - glm::vec2 rect[BluCat::Sprite::vertex_count]{ + glm::vec2 rect[BluCat::GRA::Sprite::vertex_count]{ glm::vec2{self->rect.x, self->rect.y}, glm::vec2{self->rect.x, self->rect.w}, glm::vec2{self->rect.z, self->rect.y}, @@ -56,10 +56,10 @@ load_mesh(void *obj) void *vertexes_data{&rect}; static const size_t vertexes_size = - sizeof(glm::vec2) * BluCat::Sprite::vertex_count; - self->sprite->source_buffer = new BluCat::SourceBuffer{ + sizeof(glm::vec2) * BluCat::GRA::Sprite::vertex_count; + self->sprite->source_buffer = new BluCat::GRA::SourceBuffer{ self->sprite->queue_family->device, vertexes_data, vertexes_size}; - self->sprite->vertex_buffer = new BluCat::DestinationBuffer{ + self->sprite->vertex_buffer = new BluCat::GRA::DestinationBuffer{ self->sprite->queue_family, self->sprite->source_buffer, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT}; } @@ -79,7 +79,7 @@ static const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Sprite::Sprite(std::shared_ptr<Texture> texture, const glm::vec4 &rect): diff --git a/src/blucat/sprite.hpp b/src/blu_cat/gra/sprite.hpp index 303beca..1834b22 100644 --- a/src/blucat/sprite.hpp +++ b/src/blu_cat/gra/sprite.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SPRITE_H -#define CANDY_GEAR_BLUCAT_SPRITE_H 1 +#ifndef BLU_CAT_GRA_SPRITE_H +#define BLU_CAT_GRA_SPRITE_H 1 #include <memory> #include <unordered_map> @@ -27,7 +27,7 @@ #include "uniform_buffer.hpp" #include "texture.hpp" -namespace BluCat +namespace BluCat::GRA { struct Sprite @@ -47,4 +47,4 @@ struct Sprite } -#endif /* CANDY_GEAR_BLUCAT_SPRITE_H */ +#endif /* BLU_CAT_GRA_SPRITE_H */ diff --git a/src/blucat/sprite_3d.cpp b/src/blu_cat/gra/sprite_3d.cpp index dab97e2..fc994a6 100644 --- a/src/blucat/sprite_3d.cpp +++ b/src/blu_cat/gra/sprite_3d.cpp @@ -16,7 +16,7 @@ #include "sprite_3d.hpp" -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -25,14 +25,14 @@ namespace void load_uniform_buffers(void *obj) { - auto self = static_cast<BluCat::Sprite3D*>(obj); + auto self = static_cast<BluCat::GRA::Sprite3D*>(obj); try { - self->uniform_buffers.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->uniform_buffers.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->uniform_buffers.emplace_back( - BluCat::core.vk_device_with_swapchain, sizeof(BluCat::UDOSprite3D)); + BluCat::INT::core.vk_device_with_swapchain, sizeof(BluCat::GRA::UDOSprite3D)); } catch(const std::exception& e) { @@ -43,7 +43,7 @@ load_uniform_buffers(void *obj) void unload_uniform_buffers(void *obj) { - auto self = static_cast<BluCat::Sprite3D*>(obj); + auto self = static_cast<BluCat::GRA::Sprite3D*>(obj); self->uniform_buffers.clear(); } @@ -51,7 +51,7 @@ unload_uniform_buffers(void *obj) void load_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::Sprite3D*>(obj); + auto self = static_cast<BluCat::GRA::Sprite3D*>(obj); std::array<VkDescriptorPoolSize, 1> descriptor_pool_sizes{}; descriptor_pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; @@ -75,7 +75,7 @@ load_descriptor_set_pool(void *obj) void unload_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::Sprite3D*>(obj); + auto self = static_cast<BluCat::GRA::Sprite3D*>(obj); vkDestroyDescriptorPool( self->queue_family->device->device, self->descriptor_pool, nullptr); @@ -83,11 +83,11 @@ unload_descriptor_set_pool(void *obj) void load_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::Sprite3D*>(obj); + auto self = static_cast<BluCat::GRA::Sprite3D*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->model); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->model); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -105,14 +105,14 @@ load_descriptor_sets(void *obj) void load_buffers_to_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::Sprite3D*>(obj); + auto self = static_cast<BluCat::GRA::Sprite3D*>(obj); for(auto i{0}; i < self->uniform_buffers.size(); i++) { VkDescriptorBufferInfo buffer_info{}; buffer_info.buffer = self->uniform_buffers[i].buffer; buffer_info.offset = 0; - buffer_info.range = sizeof(BluCat::UDOSprite3D); + buffer_info.range = sizeof(BluCat::GRA::UDOSprite3D); VkDescriptorImageInfo image_info{}; image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -131,7 +131,7 @@ load_buffers_to_descriptor_sets(void *obj) write_descriptors[0].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); } } @@ -145,18 +145,18 @@ static const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Sprite3D::Sprite3D( - std::shared_ptr<BluCat::Sprite> sprite, std::shared_ptr<glm::vec3> position, + std::shared_ptr<BluCat::GRA::Sprite> sprite, std::shared_ptr<glm::vec3> position, glm::vec2 size): sprite{sprite}, position{position}, size{size} { this->queue_family = - BluCat::core.vk_device_with_swapchain->get_queue_family_with_graphics(); + BluCat::INT::core.vk_device_with_swapchain->get_queue_family_with_graphics(); loader.execute(this); } diff --git a/src/blucat/sprite_3d.hpp b/src/blu_cat/gra/sprite_3d.hpp index 03a13f4..0cd8c04 100644 --- a/src/blucat/sprite_3d.hpp +++ b/src/blu_cat/gra/sprite_3d.hpp @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SPRITE_3D_H -#define CANDY_GEAR_BLUCAT_SPRITE_3D_H 1 +#ifndef BLU_CAT_GRA_SPRITE_3D_H +#define BLU_CAT_GRA_SPRITE_3D_H 1 #include "vulkan.hpp" #include "sprite.hpp" -namespace BluCat +namespace BluCat::GRA { struct Sprite3D @@ -43,4 +43,4 @@ struct Sprite3D } -#endif /* CANDY_GEAR_BLUCAT_SPRITE_3D_H */ +#endif /* BLU_CAT_GRA_SPRITE_3D_H */ diff --git a/src/blucat/sprite_to_draw.cpp b/src/blu_cat/gra/sprite_to_draw.cpp index 9013adb..7645d73 100644 --- a/src/blucat/sprite_to_draw.cpp +++ b/src/blu_cat/gra/sprite_to_draw.cpp @@ -16,7 +16,7 @@ #include "sprite_to_draw.hpp" -namespace BluCat +namespace BluCat::GRA { SpriteToDraw::SpriteToDraw( std::shared_ptr<Sprite> sprite, const glm::vec4 &position, float z_index): diff --git a/src/blucat/sprite_to_draw.hpp b/src/blu_cat/gra/sprite_to_draw.hpp index c122437..e7a23c4 100644 --- a/src/blucat/sprite_to_draw.hpp +++ b/src/blu_cat/gra/sprite_to_draw.hpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SPRITES_TO_DRAW_H -#define CANDY_GEAR_BLUCAT_SPRITES_TO_DRAW_H 1 +#ifndef BLU_CAT_GRA_SPRITES_TO_DRAW_H +#define BLU_CAT_GRA_SPRITES_TO_DRAW_H 1 #include <memory> #include "vulkan.hpp" #include "sprite.hpp" -namespace BluCat +namespace BluCat::GRA { struct SpriteToDraw { @@ -41,4 +41,4 @@ namespace BluCat operator>(const SpriteToDraw &a, const SpriteToDraw &b); } -#endif /* CANDY_GEAR_BLUCAT_SPRITES_TO_DRAW_H */ +#endif /* BLU_CAT_GRA_SPRITES_TO_DRAW_H */ diff --git a/src/blucat/static_mesh.cpp b/src/blu_cat/gra/static_mesh.cpp index a7c1c53..db3a6ee 100644 --- a/src/blucat/static_mesh.cpp +++ b/src/blu_cat/gra/static_mesh.cpp @@ -17,8 +17,8 @@ #include "static_mesh.hpp" #include "binary_reader.hpp" -#include "command.hpp" -#include "core.hpp" +#include "../com/command.hpp" +#include "../int/core.hpp" #include "static_mesh_vertex.hpp" namespace @@ -29,19 +29,19 @@ namespace struct MeshBuilder { std::string mesh_path; - BluCat::StaticMesh *mesh; + BluCat::GRA::StaticMesh *mesh; - MeshBuilder(BluCat::StaticMesh *m, std::string mp); - MeshBuilder(BluCat::StaticMesh *m, const char* mp); + MeshBuilder(BluCat::GRA::StaticMesh *m, std::string mp); + MeshBuilder(BluCat::GRA::StaticMesh *m, const char* mp); }; -MeshBuilder::MeshBuilder(BluCat::StaticMesh *m, std::string mp): +MeshBuilder::MeshBuilder(BluCat::GRA::StaticMesh *m, std::string mp): mesh{m}, mesh_path{mp} { } -MeshBuilder::MeshBuilder(BluCat::StaticMesh *m, const char *mp): +MeshBuilder::MeshBuilder(BluCat::GRA::StaticMesh *m, const char *mp): MeshBuilder{m, std::string(mp)} { } @@ -54,11 +54,11 @@ load_mesh(void *obj) BinaryReader input{self->mesh_path}; self->mesh->queue_family = - BluCat::core.vk_device_with_swapchain->get_queue_family_with_graphics(); + BluCat::INT::core.vk_device_with_swapchain->get_queue_family_with_graphics(); { // Load vertexes. auto vertex_count{input.read_ui32()}; - std::vector<BluCat::StaticMeshVertex> vertexes{vertex_count}; + std::vector<BluCat::GRA::StaticMeshVertex> vertexes{vertex_count}; for(auto i{0}; i < vertex_count; i++) { @@ -69,9 +69,9 @@ load_mesh(void *obj) void *vertexes_data{vertexes.data()}; size_t vertexes_size = sizeof(vertexes[0]) * vertexes.size(); - self->mesh->source_vertex_buffer = new BluCat::SourceBuffer{ + self->mesh->source_vertex_buffer = new BluCat::GRA::SourceBuffer{ self->mesh->queue_family->device, vertexes_data, vertexes_size}; - self->mesh->vertex_buffer = new BluCat::DestinationBuffer{ + self->mesh->vertex_buffer = new BluCat::GRA::DestinationBuffer{ self->mesh->queue_family, self->mesh->source_vertex_buffer, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT}; } @@ -85,9 +85,9 @@ load_mesh(void *obj) void *indexes_data{indexes.data()}; size_t indexes_size{sizeof(indexes[0]) * indexes.size()}; - BluCat::SourceBuffer source_index_buffer{ + BluCat::GRA::SourceBuffer source_index_buffer{ self->mesh->queue_family->device, indexes_data, indexes_size}; - self->mesh->index_buffer = new BluCat::DestinationBuffer{ + self->mesh->index_buffer = new BluCat::GRA::DestinationBuffer{ self->mesh->queue_family, &source_index_buffer, VK_BUFFER_USAGE_INDEX_BUFFER_BIT}; } @@ -109,7 +109,7 @@ static const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { StaticMesh::StaticMesh(std::string mesh_path) diff --git a/src/blucat/static_mesh.hpp b/src/blu_cat/gra/static_mesh.hpp index 04c5e3b..2b059fe 100644 --- a/src/blucat/static_mesh.hpp +++ b/src/blu_cat/gra/static_mesh.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_STATIC_MESH_H -#define CANDY_GEAR_BLUCAT_STATIC_MESH_H 1 +#ifndef BLU_CAT_GRA_STATIC_MESH_H +#define BLU_CAT_GRA_STATIC_MESH_H 1 #include <string> #include <vector> @@ -26,7 +26,7 @@ #include "uniform_buffer.hpp" #include "texture.hpp" -namespace BluCat +namespace BluCat::GRA { struct StaticMesh @@ -45,4 +45,4 @@ struct StaticMesh } -#endif /* CANDY_GEAR_BLUCAT_STATIC_MESH_H */ +#endif /* BLU_CAT_GRA_STATIC_MESH_H */ diff --git a/src/blucat/static_mesh_vertex.hpp b/src/blu_cat/gra/static_mesh_vertex.hpp index 4f7c6d4..510ce40 100644 --- a/src/blucat/static_mesh_vertex.hpp +++ b/src/blu_cat/gra/static_mesh_vertex.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_STATIC_MESH_VERTEX_H -#define CANDY_GEAR_BLUCAT_STATIC_MESH_VERTEX_H 1 +#ifndef BLU_CAT_GRA_STATIC_MESH_VERTEX_H +#define BLU_CAT_GRA_STATIC_MESH_VERTEX_H 1 #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct StaticMeshVertex @@ -31,4 +31,4 @@ struct StaticMeshVertex } -#endif /* CANDY_GEAR_BLUCAT_STATIC_MESH_VERTEX_H */ +#endif /* BLU_CAT_GRA_STATIC_MESH_VERTEX_H */ diff --git a/src/blucat/static_model.cpp b/src/blu_cat/gra/static_model.cpp index 60c2536..50dc94d 100644 --- a/src/blucat/static_model.cpp +++ b/src/blu_cat/gra/static_model.cpp @@ -16,7 +16,7 @@ #include "static_model.hpp" -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -25,14 +25,14 @@ namespace void load_uniform_buffers(void *obj) { - auto self = static_cast<BluCat::StaticModel*>(obj); + auto self = static_cast<BluCat::GRA::StaticModel*>(obj); try { - self->uniform_buffers.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->uniform_buffers.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->uniform_buffers.emplace_back( - BluCat::core.vk_device_with_swapchain, sizeof(BluCat::UDOStaticModel)); + BluCat::INT::core.vk_device_with_swapchain, sizeof(BluCat::GRA::UDOStaticModel)); } catch(const std::exception& e) { @@ -43,7 +43,7 @@ load_uniform_buffers(void *obj) void unload_uniform_buffers(void *obj) { - auto self = static_cast<BluCat::StaticModel*>(obj); + auto self = static_cast<BluCat::GRA::StaticModel*>(obj); self->uniform_buffers.clear(); } @@ -51,7 +51,7 @@ unload_uniform_buffers(void *obj) void load_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::StaticModel*>(obj); + auto self = static_cast<BluCat::GRA::StaticModel*>(obj); std::array<VkDescriptorPoolSize, 1> descriptor_pool_sizes{}; descriptor_pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; @@ -75,7 +75,7 @@ load_descriptor_set_pool(void *obj) void unload_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::StaticModel*>(obj); + auto self = static_cast<BluCat::GRA::StaticModel*>(obj); vkDestroyDescriptorPool( self->static_mesh->queue_family->device->device, self->descriptor_pool, @@ -85,11 +85,11 @@ unload_descriptor_set_pool(void *obj) void load_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::StaticModel*>(obj); + auto self = static_cast<BluCat::GRA::StaticModel*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->model); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->model); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -107,14 +107,14 @@ load_descriptor_sets(void *obj) void load_buffers_to_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::StaticModel*>(obj); + auto self = static_cast<BluCat::GRA::StaticModel*>(obj); for(auto i{0}; i < self->uniform_buffers.size(); i++) { VkDescriptorBufferInfo buffer_info{}; buffer_info.buffer = self->uniform_buffers[i].buffer; buffer_info.offset = 0; - buffer_info.range = sizeof(BluCat::UDOStaticModel); + buffer_info.range = sizeof(BluCat::GRA::UDOStaticModel); std::array<VkWriteDescriptorSet, 1> write_descriptors{}; write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -128,7 +128,7 @@ load_buffers_to_descriptor_sets(void *obj) write_descriptors[0].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); } } @@ -142,7 +142,7 @@ static const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { StaticModel::StaticModel( diff --git a/src/blucat/static_model.hpp b/src/blu_cat/gra/static_model.hpp index c300c8f..0d689d0 100644 --- a/src/blucat/static_model.hpp +++ b/src/blu_cat/gra/static_model.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_STATIC_MODEL_H -#define CANDY_GEAR_BLUCAT_STATIC_MODEL_H 1 +#ifndef BLU_CAT_GRA_STATIC_MODEL_H +#define BLU_CAT_GRA_STATIC_MODEL_H 1 #include <memory> #include <vector> @@ -23,7 +23,7 @@ #include "vulkan.hpp" #include "static_mesh.hpp" -namespace BluCat +namespace BluCat::GRA { struct StaticModel @@ -46,4 +46,4 @@ struct StaticModel } -#endif /* CANDY_GEAR_BLUCAT_STATIC_MODEL_H */ +#endif /* BLU_CAT_GRA_STATIC_MODEL_H */ diff --git a/src/blucat/swapchain.cpp b/src/blu_cat/gra/swapchain.cpp index 613cf9b..f57e3c2 100644 --- a/src/blucat/swapchain.cpp +++ b/src/blu_cat/gra/swapchain.cpp @@ -16,7 +16,7 @@ #include "swapchain.hpp" -#include "core.hpp" +#include "../int/core.hpp" #include <vector> @@ -26,25 +26,25 @@ namespace void load_swapchain(void *obj) { - auto self = static_cast<BluCat::Swapchain*>(obj); + auto self = static_cast<BluCat::GRA::Swapchain*>(obj); // Surface formats. uint32_t vk_surface_format_count; std::vector<VkSurfaceFormatKHR> vk_surface_formats; vkGetPhysicalDeviceSurfaceFormatsKHR( - BluCat::core.vk_device_with_swapchain->physical_device, - BluCat::core.window_surface, &vk_surface_format_count, nullptr); + BluCat::INT::core.vk_device_with_swapchain->physical_device, + BluCat::INT::core.window_surface, &vk_surface_format_count, nullptr); vk_surface_formats.resize(vk_surface_format_count); vkGetPhysicalDeviceSurfaceFormatsKHR( - BluCat::core.vk_device_with_swapchain->physical_device, - BluCat::core.window_surface, &vk_surface_format_count, + BluCat::INT::core.vk_device_with_swapchain->physical_device, + BluCat::INT::core.window_surface, &vk_surface_format_count, vk_surface_formats.data()); VkSwapchainCreateInfoKHR swapchain_create_info = {}; swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; swapchain_create_info.pNext = nullptr; swapchain_create_info.flags = 0; - swapchain_create_info.surface = BluCat::core.window_surface; + swapchain_create_info.surface = BluCat::INT::core.window_surface; swapchain_create_info.minImageCount = 3; // triple buffering. self->image_format = vk_surface_formats[0].format; @@ -52,7 +52,7 @@ load_swapchain(void *obj) swapchain_create_info.imageColorSpace = vk_surface_formats[0].colorSpace; swapchain_create_info.imageExtent = { - BluCat::core.display_width, BluCat::core.display_height}; + BluCat::INT::core.display_width, BluCat::INT::core.display_height}; swapchain_create_info.imageArrayLayers = 1; swapchain_create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; @@ -65,33 +65,33 @@ load_swapchain(void *obj) swapchain_create_info.oldSwapchain = VK_NULL_HANDLE; if(vkCreateSwapchainKHR( - BluCat::core.vk_device_with_swapchain->device, &swapchain_create_info, + BluCat::INT::core.vk_device_with_swapchain->device, &swapchain_create_info, nullptr, &self->swapchain) != VK_SUCCESS) throw CommandError{"Vulkan failed to create swapchain."}; vkGetSwapchainImagesKHR( - BluCat::core.vk_device_with_swapchain->device, self->swapchain, + BluCat::INT::core.vk_device_with_swapchain->device, self->swapchain, &self->images_count, nullptr); self->images = new VkImage[self->images_count]; vkGetSwapchainImagesKHR( - BluCat::core.vk_device_with_swapchain->device, self->swapchain, + BluCat::INT::core.vk_device_with_swapchain->device, self->swapchain, &self->images_count, self->images); } void unload_swapchain(void *obj) { - auto self = static_cast<BluCat::Swapchain*>(obj); + auto self = static_cast<BluCat::GRA::Swapchain*>(obj); delete[] self->images; vkDestroySwapchainKHR( - BluCat::core.vk_device_with_swapchain->device, self->swapchain, nullptr); + BluCat::INT::core.vk_device_with_swapchain->device, self->swapchain, nullptr); } void load_image_view(void *obj) { - auto self = static_cast<BluCat::Swapchain*>(obj); + auto self = static_cast<BluCat::GRA::Swapchain*>(obj); self->image_views = new VkImageView[self->images_count]; for(auto i{0}; i < self->images_count; i++) @@ -112,7 +112,7 @@ load_image_view(void *obj) create_info.subresourceRange.layerCount = 1; if(vkCreateImageView( - BluCat::core.vk_device_with_swapchain->device, &create_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &create_info, nullptr, &self->image_views[i])) throw CommandError{"Could no create Image View for swapchain."}; } @@ -121,18 +121,18 @@ load_image_view(void *obj) void unload_image_view(void *obj) { - auto self = static_cast<BluCat::Swapchain*>(obj); + auto self = static_cast<BluCat::GRA::Swapchain*>(obj); for(auto i{0}; i < self->images_count; i++) vkDestroyImageView( - BluCat::core.vk_device_with_swapchain->device, self->image_views[i], + BluCat::INT::core.vk_device_with_swapchain->device, self->image_views[i], nullptr); } void load_frame_sync(void *obj) { - auto self = static_cast<BluCat::Swapchain*>(obj); + auto self = static_cast<BluCat::GRA::Swapchain*>(obj); self->image_available_semaphores.resize(self->max_frames_in_flight); self->render_finished_semaphores.resize(self->max_frames_in_flight); @@ -152,13 +152,13 @@ load_frame_sync(void *obj) for(auto i{0}; i < self->max_frames_in_flight; i++) { if(vkCreateSemaphore( - BluCat::core.vk_device_with_swapchain->device, &semaphore_info, + BluCat::INT::core.vk_device_with_swapchain->device, &semaphore_info, nullptr, &self->image_available_semaphores[i]) != VK_SUCCESS || vkCreateSemaphore( - BluCat::core.vk_device_with_swapchain->device, &semaphore_info, + BluCat::INT::core.vk_device_with_swapchain->device, &semaphore_info, nullptr, &self->render_finished_semaphores[i]) != VK_SUCCESS || vkCreateFence( - BluCat::core.vk_device_with_swapchain->device, &fence_info, + BluCat::INT::core.vk_device_with_swapchain->device, &fence_info, nullptr, &self->in_flight_fences[i]) != VK_SUCCESS) throw CommandError{"Failed to create semaphores."}; } @@ -167,17 +167,17 @@ load_frame_sync(void *obj) void unload_frame_sync(void *obj) { - auto self = static_cast<BluCat::Swapchain*>(obj); + auto self = static_cast<BluCat::GRA::Swapchain*>(obj); - vkDeviceWaitIdle(BluCat::core.vk_device_with_swapchain->device); + vkDeviceWaitIdle(BluCat::INT::core.vk_device_with_swapchain->device); for(auto i{0}; i < self->max_frames_in_flight; i++) { - vkDestroySemaphore(BluCat::core.vk_device_with_swapchain->device, + vkDestroySemaphore(BluCat::INT::core.vk_device_with_swapchain->device, self->render_finished_semaphores[i], nullptr); - vkDestroySemaphore(BluCat::core.vk_device_with_swapchain->device, + vkDestroySemaphore(BluCat::INT::core.vk_device_with_swapchain->device, self->image_available_semaphores[i], nullptr); - vkDestroyFence(BluCat::core.vk_device_with_swapchain->device, + vkDestroyFence(BluCat::INT::core.vk_device_with_swapchain->device, self->in_flight_fences[i], nullptr); } } @@ -190,7 +190,7 @@ const CommandChain loader{ } -namespace BluCat +namespace BluCat::GRA { Swapchain::Swapchain(): diff --git a/src/blucat/swapchain.hpp b/src/blu_cat/gra/swapchain.hpp index a6f588d..2b52dd6 100644 --- a/src/blucat/swapchain.hpp +++ b/src/blu_cat/gra/swapchain.hpp @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_SWAPCHAIN_H -#define CANDY_GEAR_BLUCAT_SWAPCHAIN_H 1 +#ifndef BLU_CAT_GRA_SWAPCHAIN_H +#define BLU_CAT_GRA_SWAPCHAIN_H 1 -#include "command.hpp" +#include "../com/command.hpp" #include "vulkan.hpp" -namespace BluCat +namespace BluCat::GRA { struct Swapchain @@ -44,4 +44,4 @@ struct Swapchain } -#endif /* CANDY_GEAR_BLUCAT_SWAPCHAIN_H */ +#endif /* BLU_CAT_GRA_SWAPCHAIN_H */ diff --git a/src/blucat/texture.cpp b/src/blu_cat/gra/texture.cpp index afab950..5abf751 100644 --- a/src/blucat/texture.cpp +++ b/src/blu_cat/gra/texture.cpp @@ -16,8 +16,8 @@ #include "texture.hpp" -#include "command.hpp" -#include "core.hpp" +#include "../com/command.hpp" +#include "../int/core.hpp" #include "image.hpp" #include "qoi.hpp" #include "source_buffer.hpp" @@ -35,8 +35,8 @@ create_vulkan_image( vk_extent3d.height = height; vk_extent3d.depth = 1; - BluCat::Image::create( - BluCat::core.vk_device_with_swapchain, + BluCat::GRA::Image::create( + BluCat::INT::core.vk_device_with_swapchain, image, device_memory, VK_FORMAT_R8G8B8A8_UNORM, @@ -48,25 +48,25 @@ create_vulkan_image( struct ImageBuilder { - BluCat::Texture *texture; + BluCat::GRA::Texture *texture; }; struct ImageTextureBuilder: public ImageBuilder { std::string texture_path; - ImageTextureBuilder(BluCat::Texture *t, const std::string &tp); - ImageTextureBuilder(BluCat::Texture *t, const char* tp); + ImageTextureBuilder(BluCat::GRA::Texture *t, const std::string &tp); + ImageTextureBuilder(BluCat::GRA::Texture *t, const char* tp); }; ImageTextureBuilder::ImageTextureBuilder( - BluCat::Texture *t, const std::string &tp): + BluCat::GRA::Texture *t, const std::string &tp): texture_path{tp} { this->texture = t; } -ImageTextureBuilder::ImageTextureBuilder(BluCat::Texture *t, const char* tp): +ImageTextureBuilder::ImageTextureBuilder(BluCat::GRA::Texture *t, const char* tp): ImageTextureBuilder{t, std::string(tp)} { } @@ -77,7 +77,7 @@ load_image(void *obj) auto self = static_cast<ImageTextureBuilder*>(obj); const int num_channels = 4; // all images are converted to RGBA - BluCat::QOI::Image qoi_image(self->texture_path.c_str(), num_channels); + BluCat::GRA::QOI::Image qoi_image(self->texture_path.c_str(), num_channels); uint8_t *pixels; { // Load file image from file. @@ -91,8 +91,8 @@ load_image(void *obj) // Load file image into a vulkan buffer. size_t image_size{static_cast<size_t>( qoi_image.header.width * qoi_image.header.height * num_channels)}; - BluCat::SourceBuffer source_image_buffer{ - BluCat::core.vk_device_with_swapchain, pixels, image_size}; + BluCat::GRA::SourceBuffer source_image_buffer{ + BluCat::INT::core.vk_device_with_swapchain, pixels, image_size}; { // Create vulkan image. try @@ -104,7 +104,7 @@ load_image(void *obj) self->texture->height, self->texture->mip_levels); } - catch(BluCat::Image::Error error) + catch(BluCat::GRA::Image::Error error) { throw CommandError{error.what()}; } @@ -114,11 +114,11 @@ load_image(void *obj) { auto queue_family = self->texture->queue_family; auto queue{queue_family->get_queue()}; - BluCat::CommandPool command_pool{queue_family, 1}; + BluCat::GRA::CommandPool command_pool{queue_family, 1}; VkCommandBuffer vk_command_buffer{command_pool.command_buffers[0]}; queue.submit_one_time_command(vk_command_buffer, [&](){ - BluCat::Image::move_image_state( + BluCat::GRA::Image::move_image_state( vk_command_buffer, self->texture->image, VK_FORMAT_R8G8B8A8_UNORM, 0, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -140,7 +140,7 @@ load_image(void *obj) vk_command_buffer, source_image_buffer.buffer, self->texture->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &image_copy); - BluCat::Image::move_image_state( + BluCat::GRA::Image::move_image_state( vk_command_buffer, self->texture->image, VK_FORMAT_R8G8B8A8_UNORM, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -157,10 +157,10 @@ unload_image(void *obj) auto self = static_cast<ImageBuilder*>(obj); vkDestroyImage( - BluCat::core.vk_device_with_swapchain->device, self->texture->image, + BluCat::INT::core.vk_device_with_swapchain->device, self->texture->image, nullptr); vkFreeMemory( - BluCat::core.vk_device_with_swapchain->device, + BluCat::INT::core.vk_device_with_swapchain->device, self->texture->device_memory, nullptr); } @@ -190,7 +190,7 @@ load_sampler(void *obj) sampler_info.unnormalizedCoordinates = VK_FALSE; if(vkCreateSampler( - BluCat::core.vk_device_with_swapchain->device, &sampler_info, nullptr, + BluCat::INT::core.vk_device_with_swapchain->device, &sampler_info, nullptr, &self->texture->sampler) != VK_SUCCESS) throw CommandError{"Failed to create texture sampler."}; } @@ -201,7 +201,7 @@ unload_sampler(void *obj) auto self = static_cast<ImageBuilder*>(obj); vkDestroySampler( - BluCat::core.vk_device_with_swapchain->device, self->texture->sampler, + BluCat::INT::core.vk_device_with_swapchain->device, self->texture->sampler, nullptr); } @@ -212,12 +212,12 @@ load_view(void *obj) try { - BluCat::Image::create_view( - BluCat::core.vk_device_with_swapchain, &self->texture->view, + BluCat::GRA::Image::create_view( + BluCat::INT::core.vk_device_with_swapchain, &self->texture->view, self->texture->image, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT); } - catch(BluCat::Image::Error error) + catch(BluCat::GRA::Image::Error error) { throw CommandError{error.what()}; } @@ -229,7 +229,7 @@ unload_view(void *obj) auto self = static_cast<ImageBuilder*>(obj); vkDestroyImageView( - BluCat::core.vk_device_with_swapchain->device, self->texture->view, + BluCat::INT::core.vk_device_with_swapchain->device, self->texture->view, nullptr); } @@ -242,9 +242,9 @@ const CommandChain image_loader{ struct CharacterToDraw { int pos_x; - std::shared_ptr<BluCat::Character> character; + std::shared_ptr<BluCat::GRA::Character> character; - CharacterToDraw(int x, std::shared_ptr<BluCat::Character> character): + CharacterToDraw(int x, std::shared_ptr<BluCat::GRA::Character> character): pos_x{x}, character{character} {}; @@ -252,12 +252,12 @@ struct CharacterToDraw struct TextTextureBuilder: public ImageBuilder { - BluCat::Font *font; + BluCat::GRA::Font *font; const char* str; uint32_t max_bearing_y; std::vector<CharacterToDraw> chars_to_draw; - TextTextureBuilder(BluCat::Texture *texture, BluCat::Font *font, const char* str): + TextTextureBuilder(BluCat::GRA::Texture *texture, BluCat::GRA::Font *font, const char* str): font{font}, str{str} { @@ -271,7 +271,7 @@ load_text_proportions(void *obj) auto self = static_cast<TextTextureBuilder*>(obj); uint32_t texture_width{0}, texture_descender{0}; - auto unicode_text{BluCat::Character::str_to_unicode(self->str)}; + auto unicode_text{BluCat::GRA::Character::str_to_unicode(self->str)}; auto first_image{self->font->character(unicode_text[0])}; if(first_image->bearing_x < 0) texture_width = - first_image->bearing_x; @@ -281,7 +281,7 @@ load_text_proportions(void *obj) // FIXME: I need to test several different fonts to find all bugs in this // code. - std::shared_ptr<BluCat::Character> char_image{}; + std::shared_ptr<BluCat::GRA::Character> char_image{}; { // Calculate image size int max_height; for(auto char_code : unicode_text) @@ -334,8 +334,8 @@ load_text_image(void *obj) pixels[image_coord + 3] = 0; // Alpha } } - BluCat::SourceBuffer source_image_buffer{ - BluCat::core.vk_device_with_swapchain, pixels.data(), image_size}; + BluCat::GRA::SourceBuffer source_image_buffer{ + BluCat::INT::core.vk_device_with_swapchain, pixels.data(), image_size}; { // Create vulkan image. try @@ -347,7 +347,7 @@ load_text_image(void *obj) self->texture->height, self->texture->mip_levels); } - catch(BluCat::Image::Error error) + catch(BluCat::GRA::Image::Error error) { throw CommandError{error.what()}; } @@ -355,14 +355,14 @@ load_text_image(void *obj) { // Render text auto queue_family{ - BluCat::core.vk_device_with_swapchain-> + BluCat::INT::core.vk_device_with_swapchain-> get_queue_family_with_presentation()}; auto queue{queue_family->get_queue()}; - BluCat::CommandPool command_pool{queue_family, 1}; + BluCat::GRA::CommandPool command_pool{queue_family, 1}; VkCommandBuffer vk_command_buffer{command_pool.command_buffers[0]}; queue.submit_one_time_command(vk_command_buffer, [&](){ - BluCat::Image::move_image_state( + BluCat::GRA::Image::move_image_state( vk_command_buffer, self->texture->image, VK_FORMAT_R8G8B8A8_UNORM, 0, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -415,7 +415,7 @@ load_text_image(void *obj) 1, &image_copy); } - BluCat::Image::move_image_state( + BluCat::GRA::Image::move_image_state( vk_command_buffer, self->texture->image, VK_FORMAT_R8G8B8A8_UNORM, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -436,18 +436,18 @@ const CommandChain text_loader{ void load_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::Texture*>(obj); + auto self = static_cast<BluCat::GRA::Texture*>(obj); std::array<VkDescriptorPoolSize, 1> descriptor_pool_sizes{}; descriptor_pool_sizes[0].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; descriptor_pool_sizes[0].descriptorCount = - BluCat::core.vk_swapchain->images_count; + BluCat::INT::core.vk_swapchain->images_count; VkDescriptorPoolCreateInfo pool_info{}; pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; pool_info.pNext = nullptr; pool_info.flags = 0; - pool_info.maxSets = BluCat::core.vk_swapchain->images_count; + pool_info.maxSets = BluCat::INT::core.vk_swapchain->images_count; pool_info.poolSizeCount = descriptor_pool_sizes.size(); pool_info.pPoolSizes = descriptor_pool_sizes.data(); @@ -460,7 +460,7 @@ load_descriptor_set_pool(void *obj) void unload_descriptor_set_pool(void *obj) { - auto self = static_cast<BluCat::Texture*>(obj); + auto self = static_cast<BluCat::GRA::Texture*>(obj); vkDestroyDescriptorPool( self->queue_family->device->device, self->descriptor_pool, nullptr); @@ -469,11 +469,11 @@ unload_descriptor_set_pool(void *obj) void load_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::Texture*>(obj); + auto self = static_cast<BluCat::GRA::Texture*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->texture); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->texture); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -491,9 +491,9 @@ load_descriptor_sets(void *obj) void load_data_to_descriptor_sets(void *obj) { - auto self = static_cast<BluCat::Texture*>(obj); + auto self = static_cast<BluCat::GRA::Texture*>(obj); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) { VkDescriptorImageInfo image_info{}; image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -513,7 +513,7 @@ load_data_to_descriptor_sets(void *obj) write_descriptors[0].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); } } @@ -526,13 +526,13 @@ const CommandChain descriptor_loader{ } -namespace BluCat +namespace BluCat::GRA { Texture::Texture(Font *font, const char* str) { this->queue_family = - BluCat::core.vk_device_with_swapchain-> + BluCat::INT::core.vk_device_with_swapchain-> get_queue_family_with_presentation(); TextTextureBuilder text_builder(this, font, str); @@ -543,7 +543,7 @@ Texture::Texture(Font *font, const char* str) Texture::Texture(const std::string &texture_path) { this->queue_family = - BluCat::core.vk_device_with_swapchain-> + BluCat::INT::core.vk_device_with_swapchain-> get_queue_family_with_presentation(); ImageTextureBuilder texture_builder(this, texture_path); diff --git a/src/blucat/texture.hpp b/src/blu_cat/gra/texture.hpp index 4bf0350..c3da8cf 100644 --- a/src/blucat/texture.hpp +++ b/src/blu_cat/gra/texture.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_TEXTURE_H -#define CANDY_GEAR_BLUCAT_TEXTURE_H 1 +#ifndef BLU_CAT_GRA_TEXTURE_H +#define BLU_CAT_GRA_TEXTURE_H 1 #include <string> @@ -23,7 +23,7 @@ #include "font.hpp" #include "queue_family.hpp" -namespace BluCat +namespace BluCat::GRA { struct Texture @@ -48,4 +48,4 @@ struct Texture } -#endif /* CANDY_GEAR_TEXTURE_H */ +#endif /* BLU_CAT_GRA_TEXTURE_H */ diff --git a/src/blucat/uniform_buffer.cpp b/src/blu_cat/gra/uniform_buffer.cpp index 4b6194a..b176365 100644 --- a/src/blucat/uniform_buffer.cpp +++ b/src/blu_cat/gra/uniform_buffer.cpp @@ -19,7 +19,7 @@ #include <cstring> #include <stdexcept> -namespace BluCat +namespace BluCat::GRA { UniformBuffer::UniformBuffer(Device *device, VkDeviceSize data_size) diff --git a/src/blucat/uniform_buffer.hpp b/src/blu_cat/gra/uniform_buffer.hpp index 1dd7788..f37e100 100644 --- a/src/blucat/uniform_buffer.hpp +++ b/src/blu_cat/gra/uniform_buffer.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_UNIFORM_BUFFER_H -#define CANDY_GEAR_BLUCAT_UNIFORM_BUFFER_H 1 +#ifndef BLU_CAT_GRA_UNIFORM_BUFFER_H +#define BLU_CAT_GRA_UNIFORM_BUFFER_H 1 #include <memory> @@ -23,7 +23,7 @@ #include "base_buffer.hpp" -namespace BluCat +namespace BluCat::GRA { // FIXME: this class need to delete or create custom copy constructors! @@ -46,4 +46,4 @@ public: } -#endif /* CANDY_GEAR_BLUCAT_UNIFORM_BUFFER_H */ +#endif /* BLU_CAT_GRA_UNIFORM_BUFFER_H */ diff --git a/src/blucat/uniform_data_object.hpp b/src/blu_cat/gra/uniform_data_object.hpp index 0549e4e..68a3fbe 100644 --- a/src/blucat/uniform_data_object.hpp +++ b/src/blu_cat/gra/uniform_data_object.hpp @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_UNIFORM_DATA_OBJECT_H -#define CANDY_GEAR_BLUCAT_UNIFORM_DATA_OBJECT_H 1 +#ifndef BLU_CAT_GRA_UNIFORM_DATA_OBJECT_H +#define BLU_CAT_GRA_UNIFORM_DATA_OBJECT_H 1 #include "vulkan.hpp" #include "skeletal_mesh_vertex.hpp" -namespace BluCat +namespace BluCat::GRA { // UDO = "uniform data object" @@ -77,4 +77,4 @@ struct UDOSprite3D } -#endif /* CANDY_GEAR_BLUCAT_UNIFORM_DATA_OBJECT_H */ +#endif /* BLU_CAT_GRA_UNIFORM_DATA_OBJECT_H */ diff --git a/src/blucat/view_2d.cpp b/src/blu_cat/gra/view_2d.cpp index de764ce..948b145 100644 --- a/src/blucat/view_2d.cpp +++ b/src/blu_cat/gra/view_2d.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -27,14 +27,14 @@ namespace void load_2d_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::View2D*>(obj); + auto self = static_cast<BluCat::GRA::View2D*>(obj); try { - self->ub_2d.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->ub_2d.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->ub_2d.emplace_back( - BluCat::core.vk_device_with_swapchain, sizeof(BluCat::UDOView2D)); + BluCat::INT::core.vk_device_with_swapchain, sizeof(BluCat::GRA::UDOView2D)); } catch(const std::exception& e) { @@ -45,7 +45,7 @@ load_2d_uniform_buffer(void *obj) void unload_2d_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::View2D*>(obj); + auto self = static_cast<BluCat::GRA::View2D*>(obj); self->ub_2d.clear(); } @@ -53,11 +53,11 @@ unload_2d_uniform_buffer(void *obj) void load_descriptor_sets_2d(void *obj) { - auto self = static_cast<BluCat::View2D*>(obj); + auto self = static_cast<BluCat::GRA::View2D*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->view); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->view); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -67,7 +67,7 @@ load_descriptor_sets_2d(void *obj) self->descriptor_sets_2d.resize(layouts.size()); if(vkAllocateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, &alloc_info, + BluCat::INT::core.vk_device_with_swapchain->device, &alloc_info, self->descriptor_sets_2d.data()) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan descriptor sets for view."}; } @@ -75,14 +75,14 @@ load_descriptor_sets_2d(void *obj) void load_resources_to_descriptor_sets_2d(void *obj) { - auto self = static_cast<BluCat::View2D*>(obj); + auto self = static_cast<BluCat::GRA::View2D*>(obj); for(auto i{0}; i < self->ub_2d.size(); i++) { VkDescriptorBufferInfo view_2d_info{}; view_2d_info.buffer = self->ub_2d[i].buffer; view_2d_info.offset = 0; - view_2d_info.range = sizeof(BluCat::UDOView2D); + view_2d_info.range = sizeof(BluCat::GRA::UDOView2D); std::array<VkWriteDescriptorSet, 1> write_descriptors{}; write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -96,10 +96,10 @@ load_resources_to_descriptor_sets_2d(void *obj) write_descriptors[0].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); - BluCat::UDOView2D ubo_view_2d; + BluCat::GRA::UDOView2D ubo_view_2d; ubo_view_2d.proj = glm::ortho( 0.0f, self->projection_width, 0.0f, self->projection_height, @@ -110,7 +110,7 @@ load_resources_to_descriptor_sets_2d(void *obj) } -namespace BluCat +namespace BluCat::GRA { const CommandChain View2D::loader{ @@ -128,8 +128,8 @@ View2D::View2D( projection_height{projection_height}, region{region}, descriptor_pool{VK_NULL_HANDLE}, - rectangles_to_draw{BluCat::core.vk_swapchain->images_count}, - sprites_to_draw{BluCat::core.vk_swapchain->images_count} + rectangles_to_draw{BluCat::INT::core.vk_swapchain->images_count}, + sprites_to_draw{BluCat::INT::core.vk_swapchain->images_count} { loader.execute(this); } diff --git a/src/blucat/view_2d.hpp b/src/blu_cat/gra/view_2d.hpp index b798f19..84b9f09 100644 --- a/src/blucat/view_2d.hpp +++ b/src/blu_cat/gra/view_2d.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_VIEW_2D_H -#define CANDY_GEAR_BLUCAT_VIEW_2D_H 1 +#ifndef BLU_CAT_GRA_VIEW_2D_H +#define BLU_CAT_GRA_VIEW_2D_H 1 #include <memory> #include <unordered_map> @@ -25,7 +25,7 @@ #include "sprite_to_draw.hpp" #include "rectangle.hpp" -namespace BluCat +namespace BluCat::GRA { struct View2D @@ -57,4 +57,4 @@ protected: } -#endif /* CANDY_GEAR_BLUCAT_VIEW_2D_H */ +#endif /* BLU_CAT_GRA_VIEW_2D_H */ diff --git a/src/blucat/view_3d.cpp b/src/blu_cat/gra/view_3d.cpp index be9970c..dc310e3 100644 --- a/src/blucat/view_3d.cpp +++ b/src/blu_cat/gra/view_3d.cpp @@ -18,7 +18,7 @@ #include <array> -#include "core.hpp" +#include "../int/core.hpp" #include "uniform_data_object.hpp" namespace @@ -27,14 +27,14 @@ namespace void load_3d_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::View3D*>(obj); + auto self = static_cast<BluCat::GRA::View3D*>(obj); try { - self->ub_3d.reserve(BluCat::core.vk_swapchain->images_count); - for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++) + self->ub_3d.reserve(BluCat::INT::core.vk_swapchain->images_count); + for(auto i{0}; i < BluCat::INT::core.vk_swapchain->images_count; i++) self->ub_3d.emplace_back( - BluCat::core.vk_device_with_swapchain, sizeof(BluCat::UDOView3D)); + BluCat::INT::core.vk_device_with_swapchain, sizeof(BluCat::GRA::UDOView3D)); } catch(const std::exception& e) { @@ -45,7 +45,7 @@ load_3d_uniform_buffer(void *obj) void unload_3d_uniform_buffer(void *obj) { - auto self = static_cast<BluCat::View3D*>(obj); + auto self = static_cast<BluCat::GRA::View3D*>(obj); self->ub_3d.clear(); } @@ -53,11 +53,11 @@ unload_3d_uniform_buffer(void *obj) void load_descriptor_sets_3d(void *obj) { - auto self = static_cast<BluCat::View3D*>(obj); + auto self = static_cast<BluCat::GRA::View3D*>(obj); std::vector<VkDescriptorSetLayout> layouts( - BluCat::core.vk_swapchain->images_count, - BluCat::core.vk_descriptor_set_layout->view); + BluCat::INT::core.vk_swapchain->images_count, + BluCat::INT::core.vk_descriptor_set_layout->view); VkDescriptorSetAllocateInfo alloc_info{}; alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -67,7 +67,7 @@ load_descriptor_sets_3d(void *obj) self->descriptor_sets_3d.resize(layouts.size()); if(vkAllocateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, &alloc_info, + BluCat::INT::core.vk_device_with_swapchain->device, &alloc_info, self->descriptor_sets_3d.data()) != VK_SUCCESS) throw CommandError{"Failed to create Vulkan descriptor sets for view."}; } @@ -75,14 +75,14 @@ load_descriptor_sets_3d(void *obj) void load_resources_to_descriptor_sets_3d(void *obj) { - auto self = static_cast<BluCat::View3D*>(obj); + auto self = static_cast<BluCat::GRA::View3D*>(obj); for(auto i{0}; i < self->ub_3d.size(); i++) { VkDescriptorBufferInfo view_3d_info{}; view_3d_info.buffer = self->ub_3d[i].buffer; view_3d_info.offset = 0; - view_3d_info.range = sizeof(BluCat::UDOView3D); + view_3d_info.range = sizeof(BluCat::GRA::UDOView3D); std::array<VkWriteDescriptorSet, 1> write_descriptors{}; write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -96,7 +96,7 @@ load_resources_to_descriptor_sets_3d(void *obj) write_descriptors[0].pTexelBufferView = nullptr; vkUpdateDescriptorSets( - BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(), + BluCat::INT::core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); } } @@ -112,7 +112,7 @@ const CommandChain descriptor_sets_loader{ } -namespace BluCat +namespace BluCat::GRA { View3D::View3D( @@ -135,7 +135,7 @@ View3D::load_descriptor_sets(VkDescriptorPool descriptor_pool) { if(this->descriptor_pool != VK_NULL_HANDLE) return; - auto parent = dynamic_cast<BluCat::View2D*>(this); + auto parent = dynamic_cast<BluCat::GRA::View2D*>(this); this->descriptor_pool = descriptor_pool; View2D::descriptor_sets_loader.execute(parent); ::descriptor_sets_loader.execute(this); @@ -146,7 +146,7 @@ View3D::unload_descriptor_sets() { if(this->descriptor_pool == VK_NULL_HANDLE) return; - auto parent = dynamic_cast<BluCat::View2D*>(this); + auto parent = dynamic_cast<BluCat::GRA::View2D*>(this); this->descriptor_pool = VK_NULL_HANDLE; ::descriptor_sets_loader.revert(this); View2D::descriptor_sets_loader.revert(parent); diff --git a/src/blucat/view_3d.hpp b/src/blu_cat/gra/view_3d.hpp index 05cae6b..f09c70f 100644 --- a/src/blucat/view_3d.hpp +++ b/src/blu_cat/gra/view_3d.hpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef CANDY_GEAR_BLUCAT_VIEW_3D_H -#define CANDY_GEAR_BLUCAT_VIEW_3D_H 1 +#ifndef BLU_CAT_GRA_VIEW_3D_H +#define BLU_CAT_GRA_VIEW_3D_H 1 #include "view_2d.hpp" -namespace BluCat +namespace BluCat::GRA { struct View3D: public View2D @@ -45,4 +45,4 @@ struct View3D: public View2D } -#endif /* CANDY_GEAR_BLUCAT_VIEW_3D_H */ +#endif /* BLU_CAT_GRA_VIEW_3D_H */ diff --git a/src/blucat/vulkan.hpp b/src/blu_cat/gra/vulkan.hpp index 24c35f5..fcf6628 100644 --- a/src/blucat/vulkan.hpp +++ b/src/blu_cat/gra/vulkan.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BLU_CAT_VULKAN_H -#define BLU_CAT_VULKAN_H 1 +#ifndef BLU_CAT_GRA_VULKAN_H +#define BLU_CAT_GRA_VULKAN_H 1 // GLM uses some definitions to control their behavior, so you should not // include it directly. Instead, use this header. @@ -31,4 +31,4 @@ #include <vulkan/vulkan.h> -#endif /* BLU_CAT_VULKAN_H */ +#endif /* BLU_CAT_GRA_VULKAN_H */ diff --git a/src/blucat/core.cpp b/src/blu_cat/int/core.cpp index 8478f86..eafdab7 100644 --- a/src/blucat/core.cpp +++ b/src/blu_cat/int/core.cpp @@ -47,7 +47,7 @@ vk_debug_callback( } // Log message. - BluCat::core.log.message(log_level, callback_data->pMessage); + BluCat::INT::core.log.message(log_level, callback_data->pMessage); return VK_FALSE; } @@ -58,15 +58,15 @@ load_threads(void *obj) { auto num_threads{std::thread::hardware_concurrency() - 1}; for(auto i{0}; i < num_threads; i++) - BluCat::core.threads.emplace_back( - BluCat::core.workers.emplace_back(&BluCat::core.job_queue)); + BluCat::INT::core.threads.emplace_back( + BluCat::INT::core.workers.emplace_back(&BluCat::INT::core.job_queue)); } void unload_threads(void *obj) { - BluCat::core.job_queue.stop(); - for(auto &t: BluCat::core.threads) t.join(); + BluCat::INT::core.job_queue.stop(); + for(auto &t: BluCat::INT::core.threads) t.join(); } void @@ -74,23 +74,23 @@ load_fps(void *obj) { using namespace std::chrono; - BluCat::core.max_frame_duration = - duration<long long, std::milli>(1000 / BluCat::core.fps); + BluCat::INT::core.max_frame_duration = + duration<long long, std::milli>(1000 / BluCat::INT::core.fps); // FIXME: actually calculates the real delta time. - BluCat::core.delta_time = 1.0f / BluCat::core.fps; + BluCat::INT::core.delta_time = 1.0f / BluCat::INT::core.fps; } void load_font_library(void *obj) { - FT_Error error{FT_Init_FreeType(&BluCat::core.font_library)}; + FT_Error error{FT_Init_FreeType(&BluCat::INT::core.font_library)}; if(error) throw CommandError{"Failed to open the FreeType library."}; } void unload_font_library(void *obj) { - FT_Done_FreeType(BluCat::core.font_library); + FT_Done_FreeType(BluCat::INT::core.font_library); } #ifdef DEBUG @@ -119,11 +119,11 @@ load_vk_debug_callback(void *obj) create_info.flags = 0; debug_messenger = (PFN_vkCreateDebugUtilsMessengerEXT) - vkGetInstanceProcAddr(BluCat::core.vk_instance, + vkGetInstanceProcAddr(BluCat::INT::core.vk_instance, "vkCreateDebugUtilsMessengerEXT"); - if(debug_messenger(BluCat::core.vk_instance, &create_info, nullptr, - &BluCat::core.vk_callback) != VK_SUCCESS) + if(debug_messenger(BluCat::INT::core.vk_instance, &create_info, nullptr, + &BluCat::INT::core.vk_callback) != VK_SUCCESS) CommandError{"Failed to setup debug callback for Vulkan."}; } @@ -133,10 +133,10 @@ unload_vk_debug_callback(void *obj) PFN_vkDestroyDebugUtilsMessengerEXT debug_messenger; debug_messenger = (PFN_vkDestroyDebugUtilsMessengerEXT) - vkGetInstanceProcAddr(BluCat::core.vk_instance, + vkGetInstanceProcAddr(BluCat::INT::core.vk_instance, "vkDestroyDebugUtilsMessengerEXT"); - debug_messenger(BluCat::core.vk_instance, BluCat::core.vk_callback, nullptr); + debug_messenger(BluCat::INT::core.vk_instance, BluCat::INT::core.vk_callback, nullptr); } #endif @@ -149,42 +149,42 @@ load_devices(void *obj) // Enumerate physical devices { vkEnumeratePhysicalDevices( - BluCat::core.vk_instance, &devices_count, nullptr); + BluCat::INT::core.vk_instance, &devices_count, nullptr); if(devices_count < 1) CommandError{"Failed to find GPUs with Vulkan support."}; vk_physical_devices.resize(devices_count); vkEnumeratePhysicalDevices( - BluCat::core.vk_instance, &devices_count, vk_physical_devices.data()); + BluCat::INT::core.vk_instance, &devices_count, vk_physical_devices.data()); } #ifdef DEBUG - BluCat::core.log.message(Log::Level::Trace, "Physical devices properties"); + BluCat::INT::core.log.message(Log::Level::Trace, "Physical devices properties"); #endif - BluCat::core.vk_devices.reserve(devices_count); + BluCat::INT::core.vk_devices.reserve(devices_count); for(auto i = 0; i < devices_count; i++) { // Use swapchain on first device. if(i == 0) { - BluCat::core.vk_devices.emplace_back(vk_physical_devices[i], true); - BluCat::core.vk_device_with_swapchain = &BluCat::core.vk_devices[i]; + BluCat::INT::core.vk_devices.emplace_back(vk_physical_devices[i], true); + BluCat::INT::core.vk_device_with_swapchain = &BluCat::INT::core.vk_devices[i]; } else - BluCat::core.vk_devices.emplace_back(vk_physical_devices[i], false); + BluCat::INT::core.vk_devices.emplace_back(vk_physical_devices[i], false); } } void unload_devices(void *obj) { - BluCat::core.vk_devices.clear(); + BluCat::INT::core.vk_devices.clear(); } static void load_swapchain(void *obj) { - try { BluCat::core.vk_swapchain = new BluCat::Swapchain(); } + try { BluCat::INT::core.vk_swapchain = new BluCat::GRA::Swapchain(); } catch(const CommandError &error) { std::string error_message{"Failed to create swapchain → "}; @@ -196,7 +196,7 @@ load_swapchain(void *obj) void unload_swapchain(void *obj) { - delete BluCat::core.vk_swapchain; + delete BluCat::INT::core.vk_swapchain; } void @@ -204,7 +204,7 @@ load_framebuffer(void *obj) { try { - BluCat::core.vk_framebuffer = new BluCat::Framebuffer(); + BluCat::INT::core.vk_framebuffer = new BluCat::GRA::Framebuffer(); } catch(const CommandError &e) { @@ -215,7 +215,7 @@ load_framebuffer(void *obj) void unload_framebuffer(void *obj) { - delete BluCat::core.vk_framebuffer; + delete BluCat::INT::core.vk_framebuffer; } void @@ -223,7 +223,7 @@ load_render_pass(void *obj) { try { - BluCat::core.vk_render_pass = new BluCat::RenderPass(); + BluCat::INT::core.vk_render_pass = new BluCat::GRA::RenderPass(); } catch(const CommandError &e) { @@ -234,7 +234,7 @@ load_render_pass(void *obj) void unload_render_pass(void *obj) { - delete BluCat::core.vk_render_pass; + delete BluCat::INT::core.vk_render_pass; } void @@ -242,7 +242,7 @@ load_descriptor_set_layout(void *obj) { try { - BluCat::core.vk_descriptor_set_layout = new BluCat::DescriptorSetLayout(); + BluCat::INT::core.vk_descriptor_set_layout = new BluCat::GRA::DescriptorSetLayout(); } catch(const CommandError &e) { @@ -253,7 +253,7 @@ load_descriptor_set_layout(void *obj) void unload_descriptor_set_layout(void *obj) { - delete BluCat::core.vk_descriptor_set_layout; + delete BluCat::INT::core.vk_descriptor_set_layout; } void @@ -261,8 +261,8 @@ load_graphics_pipeline_3d_layout(void *obj) { try { - BluCat::core.vk_graphics_pipeline_3d_layout = - new BluCat::GraphicsPipeline3DLayout(); + BluCat::INT::core.vk_graphics_pipeline_3d_layout = + new BluCat::GRA::GraphicsPipeline3DLayout(); } catch(const CommandError &e) { @@ -273,7 +273,7 @@ load_graphics_pipeline_3d_layout(void *obj) void unload_graphics_pipeline_3d_layout(void *obj) { - delete BluCat::core.vk_graphics_pipeline_3d_layout; + delete BluCat::INT::core.vk_graphics_pipeline_3d_layout; } void @@ -281,8 +281,8 @@ load_graphics_pipeline_2d_solid_layout(void *obj) { try { - BluCat::core.vk_graphics_pipeline_2d_solid_layout = - new BluCat::GraphicsPipeline2DSolidLayout(); + BluCat::INT::core.vk_graphics_pipeline_2d_solid_layout = + new BluCat::GRA::GraphicsPipeline2DSolidLayout(); } catch(const CommandError &e) { @@ -293,7 +293,7 @@ load_graphics_pipeline_2d_solid_layout(void *obj) void unload_graphics_pipeline_2d_solid_layout(void *obj) { - delete BluCat::core.vk_graphics_pipeline_2d_solid_layout; + delete BluCat::INT::core.vk_graphics_pipeline_2d_solid_layout; } void @@ -301,8 +301,8 @@ load_graphics_pipeline_2d_wired_layout(void *obj) { try { - BluCat::core.vk_graphics_pipeline_2d_wired_layout = - new BluCat::GraphicsPipeline2DWiredLayout(); + BluCat::INT::core.vk_graphics_pipeline_2d_wired_layout = + new BluCat::GRA::GraphicsPipeline2DWiredLayout(); } catch(const CommandError &e) { @@ -313,7 +313,7 @@ load_graphics_pipeline_2d_wired_layout(void *obj) void unload_graphics_pipeline_2d_wired_layout(void *obj) { - delete BluCat::core.vk_graphics_pipeline_2d_wired_layout; + delete BluCat::INT::core.vk_graphics_pipeline_2d_wired_layout; } void @@ -321,7 +321,7 @@ load_light(void *obj) { try { - BluCat::core.vk_light = new BluCat::Light(); + BluCat::INT::core.vk_light = new BluCat::GRA::Light(); } catch(const CommandError &e) { @@ -332,7 +332,7 @@ load_light(void *obj) void unload_light(void *obj) { - delete BluCat::core.vk_light; + delete BluCat::INT::core.vk_light; } void @@ -340,8 +340,8 @@ load_graphics_pipeline_3d(void *obj) { try { - BluCat::core.vk_graphics_pipeline_3d = - std::make_unique<BluCat::GraphicsPipeline3D>(); + BluCat::INT::core.vk_graphics_pipeline_3d = + std::make_unique<BluCat::GRA::GraphicsPipeline3D>(); } catch(const CommandError &e) { @@ -352,7 +352,7 @@ load_graphics_pipeline_3d(void *obj) void unload_graphics_pipeline_3d(void *obj) { - BluCat::core.vk_graphics_pipeline_3d = nullptr; + BluCat::INT::core.vk_graphics_pipeline_3d = nullptr; } void @@ -360,8 +360,8 @@ load_graphics_pipeline_3d_skeletal(void *obj) { try { - BluCat::core.vk_graphics_pipeline_3d_skeletal = - std::make_unique<BluCat::GraphicsPipeline3DSkeletal>(); + BluCat::INT::core.vk_graphics_pipeline_3d_skeletal = + std::make_unique<BluCat::GRA::GraphicsPipeline3DSkeletal>(); } catch(const CommandError &e) { @@ -372,7 +372,7 @@ load_graphics_pipeline_3d_skeletal(void *obj) void unload_graphics_pipeline_3d_skeletal(void *obj) { - BluCat::core.vk_graphics_pipeline_3d_skeletal = nullptr; + BluCat::INT::core.vk_graphics_pipeline_3d_skeletal = nullptr; } void @@ -380,8 +380,8 @@ load_graphics_pipeline_sprite_3d(void *obj) { try { - BluCat::core.vk_graphics_pipeline_sprite_3d = - std::make_unique<BluCat::GraphicsPipelineSprite3D>(); + BluCat::INT::core.vk_graphics_pipeline_sprite_3d = + std::make_unique<BluCat::GRA::GraphicsPipelineSprite3D>(); } catch(const CommandError &e) { @@ -392,7 +392,7 @@ load_graphics_pipeline_sprite_3d(void *obj) void unload_graphics_pipeline_sprite_3d(void *obj) { - BluCat::core.vk_graphics_pipeline_sprite_3d = nullptr; + BluCat::INT::core.vk_graphics_pipeline_sprite_3d = nullptr; } void @@ -400,8 +400,8 @@ load_graphics_pipeline_2d_solid(void *obj) { try { - BluCat::core.vk_graphics_pipeline_2d_solid = - std::make_unique<BluCat::GraphicsPipeline2DSolid>(); + BluCat::INT::core.vk_graphics_pipeline_2d_solid = + std::make_unique<BluCat::GRA::GraphicsPipeline2DSolid>(); } catch(const CommandError &e) { @@ -412,7 +412,7 @@ load_graphics_pipeline_2d_solid(void *obj) void unload_graphics_pipeline_2d_solid(void *obj) { - BluCat::core.vk_graphics_pipeline_2d_solid = nullptr; + BluCat::INT::core.vk_graphics_pipeline_2d_solid = nullptr; } void @@ -420,8 +420,8 @@ load_graphics_pipeline_2d_wired(void *obj) { try { - BluCat::core.vk_graphics_pipeline_2d_wired = - std::make_unique<BluCat::GraphicsPipeline2DWired>(); + BluCat::INT::core.vk_graphics_pipeline_2d_wired = + std::make_unique<BluCat::GRA::GraphicsPipeline2DWired>(); } catch(const CommandError &e) { @@ -432,7 +432,7 @@ load_graphics_pipeline_2d_wired(void *obj) void unload_graphics_pipeline_2d_wired(void *obj) { - BluCat::core.vk_graphics_pipeline_2d_wired = nullptr; + BluCat::INT::core.vk_graphics_pipeline_2d_wired = nullptr; } void @@ -442,11 +442,11 @@ load_renderer(void *obj) { glm::vec4 region( 0.f, 0.f, - static_cast<float>(BluCat::core.display_width), - static_cast<float>(BluCat::core.display_height)); - BluCat::core.vk_renderer = new BluCat::Renderer( + static_cast<float>(BluCat::INT::core.display_width), + static_cast<float>(BluCat::INT::core.display_height)); + BluCat::INT::core.vk_renderer = new BluCat::GRA::Renderer( {}, - {std::make_shared<BluCat::View3D>(region, region.z, region.w)}); + {std::make_shared<BluCat::GRA::View3D>(region, region.z, region.w)}); } catch(const CommandError &e) { @@ -457,12 +457,12 @@ load_renderer(void *obj) void unload_renderer(void *obj) { - delete BluCat::core.vk_renderer; + delete BluCat::INT::core.vk_renderer; } } -namespace BluCat +namespace BluCat::INT { std::random_device random_seed; diff --git a/src/blu_cat/int/core.hpp b/src/blu_cat/int/core.hpp new file mode 100644 index 0000000..0900b81 --- /dev/null +++ b/src/blu_cat/int/core.hpp @@ -0,0 +1,123 @@ +/* + * Copyright 2022-2024 Frederico de Oliveira Linhares + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BLU_CAT_INT_CORE_H +#define BLU_CAT_INT_CORE_H 1 + +#define BLU_CAT_VERSION_MAJOR 0 +#define BLU_CAT_VERSION_MINOR 1 +#define BLU_CAT_VERSION_PATCH 0 + +#include <chrono> +#include <cstdint> +#include <memory> +#include <random> + +#include "../com/command.hpp" +#include "../com/job_queue.hpp" +#include "../com/worker.hpp" +#include "../gra/device.hpp" +#include "../gra/descriptor_set_layout.hpp" +#include "../gra/framebuffer.hpp" +#include "../gra/graphics_pipeline_2d_solid_layout.hpp" +#include "../gra/graphics_pipeline_2d_wired_layout.hpp" +#include "../gra/graphics_pipeline_2d_solid.hpp" +#include "../gra/graphics_pipeline_2d_wired.hpp" +#include "../gra/graphics_pipeline_3d_layout.hpp" +#include "../gra/graphics_pipeline_3d.hpp" +#include "../gra/graphics_pipeline_3d_skeletal.hpp" +#include "../gra/graphics_pipeline_sprite_3d.hpp" +#include "../gra/light.hpp" +#include "../gra/log.hpp" +#include "../gra/render_pass.hpp" +#include "../gra/renderer.hpp" +#include "../gra/swapchain.hpp" +#include "../gra/vulkan.hpp" + +namespace BluCat::INT +{ + +extern std::random_device random_seed; +extern std::mt19937 random_number_generator; + +struct Core +{ + static const CommandChain loader; + + Log::Logger log; + + COM::JobQueue job_queue; + std::vector<COM::Worker> workers; + std::vector<std::thread> threads; + + /// Text displayed in the game window. + std::string game_name; + + /** + * @{ + * This is the ammount of pixel that the games uses when rendering to the + * screen. + */ + uint32_t display_width, display_height; + /// @} + + int game_version_major, game_version_minor, game_version_patch; + + uint32_t fps; + std::chrono::duration<long long, std::milli> max_frame_duration; + float delta_time; + + FT_Library font_library; + + VkSurfaceKHR window_surface; + VkInstance vk_instance; + +#ifdef DEBUG + VkDebugUtilsMessengerEXT vk_callback; +#endif + + // Vulkan devices. + std::vector<BluCat::GRA::Device> vk_devices; + BluCat::GRA::Device *vk_device_with_swapchain; + BluCat::GRA::Swapchain *vk_swapchain; + + BluCat::GRA::Framebuffer *vk_framebuffer; + BluCat::GRA::RenderPass *vk_render_pass; + BluCat::GRA::DescriptorSetLayout *vk_descriptor_set_layout; + BluCat::GRA::GraphicsPipeline3DLayout *vk_graphics_pipeline_3d_layout; + BluCat::GRA::GraphicsPipeline2DSolidLayout + *vk_graphics_pipeline_2d_solid_layout; + BluCat::GRA::GraphicsPipeline2DWiredLayout + *vk_graphics_pipeline_2d_wired_layout; + BluCat::GRA::Light *vk_light; + std::unique_ptr<BluCat::GRA::GraphicsPipeline3D> vk_graphics_pipeline_3d; + std::unique_ptr<BluCat::GRA::GraphicsPipeline3DSkeletal> + vk_graphics_pipeline_3d_skeletal; + std::unique_ptr<BluCat::GRA::GraphicsPipelineSprite3D> + vk_graphics_pipeline_sprite_3d; + std::unique_ptr<BluCat::GRA::GraphicsPipeline2DSolid> + vk_graphics_pipeline_2d_solid; + std::unique_ptr<BluCat::GRA::GraphicsPipeline2DWired> + vk_graphics_pipeline_2d_wired; + + BluCat::GRA::Renderer *vk_renderer; +}; + +extern Core core; + +} + +#endif /* BLU_CAT_INT_CORE_H */ diff --git a/src/blucat/core.hpp b/src/blucat/core.hpp deleted file mode 100644 index decf319..0000000 --- a/src/blucat/core.hpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2022-2024 Frederico de Oliveira Linhares - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CANDY_GEAR_BLUCAT_CORE_H -#define CANDY_GEAR_BLUCAT_CORE_H 1 - -#define BLU_CAT_VERSION_MAJOR 0 -#define BLU_CAT_VERSION_MINOR 1 -#define BLU_CAT_VERSION_PATCH 0 - -#include <chrono> -#include <cstdint> -#include <memory> -#include <random> - -#include "command.hpp" -#include "device.hpp" -#include "descriptor_set_layout.hpp" -#include "framebuffer.hpp" -#include "graphics_pipeline_2d_solid_layout.hpp" -#include "graphics_pipeline_2d_wired_layout.hpp" -#include "graphics_pipeline_2d_solid.hpp" -#include "graphics_pipeline_2d_wired.hpp" -#include "graphics_pipeline_3d_layout.hpp" -#include "graphics_pipeline_3d.hpp" -#include "graphics_pipeline_3d_skeletal.hpp" -#include "graphics_pipeline_sprite_3d.hpp" -#include "job_queue.hpp" -#include "light.hpp" -#include "log.hpp" -#include "render_pass.hpp" -#include "renderer.hpp" -#include "swapchain.hpp" -#include "vulkan.hpp" -#include "worker.hpp" - -namespace BluCat -{ - -extern std::random_device random_seed; -extern std::mt19937 random_number_generator; - -struct Core -{ - static const CommandChain loader; - - Log::Logger log; - - JobQueue job_queue; - std::vector<Worker> workers; - std::vector<std::thread> threads; - - /// Text displayed in the game window. - std::string game_name; - - /** - * @{ - * This is the ammount of pixel that the games uses when rendering to the - * screen. - */ - uint32_t display_width, display_height; - /// @} - - int game_version_major, game_version_minor, game_version_patch; - - uint32_t fps; - std::chrono::duration<long long, std::milli> max_frame_duration; - float delta_time; - - FT_Library font_library; - - VkSurfaceKHR window_surface; - VkInstance vk_instance; - -#ifdef DEBUG - VkDebugUtilsMessengerEXT vk_callback; -#endif - - // Vulkan devices. - std::vector<Device> vk_devices; - Device *vk_device_with_swapchain; - Swapchain *vk_swapchain; - - Framebuffer *vk_framebuffer; - RenderPass *vk_render_pass; - DescriptorSetLayout *vk_descriptor_set_layout; - GraphicsPipeline3DLayout *vk_graphics_pipeline_3d_layout; - GraphicsPipeline2DSolidLayout *vk_graphics_pipeline_2d_solid_layout; - GraphicsPipeline2DWiredLayout *vk_graphics_pipeline_2d_wired_layout; - Light *vk_light; - std::unique_ptr<GraphicsPipeline3D> vk_graphics_pipeline_3d; - std::unique_ptr<GraphicsPipeline3DSkeletal> - vk_graphics_pipeline_3d_skeletal; - std::unique_ptr<GraphicsPipelineSprite3D> vk_graphics_pipeline_sprite_3d; - std::unique_ptr<GraphicsPipeline2DSolid> vk_graphics_pipeline_2d_solid; - std::unique_ptr<GraphicsPipeline2DWired> vk_graphics_pipeline_2d_wired; - - Renderer *vk_renderer; -}; - -extern Core core; - -} - -#endif /* CANDY_GEAR_BLUCAT_CORE_H */ diff --git a/src/candy_gear.cpp b/src/candy_gear/candy_gear.cpp index e8add70..b1758a4 100644 --- a/src/candy_gear.cpp +++ b/src/candy_gear/candy_gear.cpp @@ -30,7 +30,7 @@ cg_mCandyGear_set_game_name(mrb_state *mrb, mrb_value self) mrb_value name; mrb_get_args(mrb, "S", &name); - BluCat::core.game_name = RSTRING_PTR(name); + BluCat::INT::core.game_name = RSTRING_PTR(name); return self; } @@ -42,8 +42,8 @@ cg_mCandyGear_set_views(mrb_state *mrb, mrb_value self) mrb_value *array; mrb_int array_len; - std::vector<std::shared_ptr<BluCat::View2D>> views_2d; - std::vector<std::shared_ptr<BluCat::View3D>> views_3d; + std::vector<std::shared_ptr<BluCat::GRA::View2D>> views_2d; + std::vector<std::shared_ptr<BluCat::GRA::View3D>> views_3d; cg_m = mrb_module_get(mrb, "CandyGear"); cg_cView2D = mrb_class_get_under(mrb, cg_m, "View2D"); @@ -54,12 +54,12 @@ cg_mCandyGear_set_views(mrb_state *mrb, mrb_value self) { if(mrb_obj_is_kind_of(mrb, array[i], cg_cView2D)) { - auto v = (std::shared_ptr<BluCat::View2D>*)DATA_PTR(array[i]); + auto v = (std::shared_ptr<BluCat::GRA::View2D>*)DATA_PTR(array[i]); views_2d.push_back(*v); } else if(mrb_obj_is_kind_of(mrb, array[i], cg_cView3D)) { - auto v = (std::shared_ptr<BluCat::View3D>*)DATA_PTR(array[i]); + auto v = (std::shared_ptr<BluCat::GRA::View3D>*)DATA_PTR(array[i]); views_3d.push_back(*v); } } @@ -67,8 +67,8 @@ cg_mCandyGear_set_views(mrb_state *mrb, mrb_value self) // A Renderer need at least one view to work. if(views_2d.size() > 0 || views_3d.size() > 0) { - delete BluCat::core.vk_renderer; - BluCat::core.vk_renderer = new BluCat::Renderer({views_2d, views_3d}); + delete BluCat::INT::core.vk_renderer; + BluCat::INT::core.vk_renderer = new BluCat::GRA::Renderer({views_2d, views_3d}); } return self; @@ -96,7 +96,7 @@ cg_mCandyGear_log(mrb_state *mrb, mrb_value self) else log_lvl = Log::Level::Fatal; - BluCat::core.log.message(log_lvl, message); + BluCat::INT::core.log.message(log_lvl, message); return self; } diff --git a/src/candy_gear.hpp b/src/candy_gear/candy_gear.hpp index 3ec92b3..3ec92b3 100644 --- a/src/candy_gear.hpp +++ b/src/candy_gear/candy_gear.hpp diff --git a/src/core.cpp b/src/candy_gear/core.cpp index dd68edb..28f5a15 100644 --- a/src/core.cpp +++ b/src/candy_gear/core.cpp @@ -64,16 +64,16 @@ load_game(void *obj) FILE *fp; mrb_value main_obj{mrb_top_self(cg_core.mrb)}; - BluCat::core.game_name = "CandyGear Game"; + BluCat::INT::core.game_name = "CandyGear Game"; - BluCat::core.display_width = 800; - BluCat::core.display_height = 600; + BluCat::INT::core.display_width = 800; + BluCat::INT::core.display_height = 600; - BluCat::core.game_version_major = 0; - BluCat::core.game_version_minor = 1; - BluCat::core.game_version_patch = 0; + BluCat::INT::core.game_version_major = 0; + BluCat::INT::core.game_version_minor = 1; + BluCat::INT::core.game_version_patch = 0; - BluCat::core.fps = 30; + BluCat::INT::core.fps = 30; mrb_define_module(cg_core.mrb, "CandyGear"); cg_candy_gear_init_config(cg_core.mrb); @@ -166,9 +166,9 @@ load_window(void *obj) { cg_core.window = NULL; cg_core.window = SDL_CreateWindow( - BluCat::core.game_name.c_str(), + BluCat::INT::core.game_name.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - BluCat::core.display_width, BluCat::core.display_height, + BluCat::INT::core.display_width, BluCat::INT::core.display_height, SDL_WINDOW_VULKAN); if(cg_core.window == NULL) { @@ -230,12 +230,12 @@ load_vk_instance(void *obj) } #ifdef DEBUG - BluCat::core.log.message(Log::Level::Trace, "Enabled VK extensions."); + BluCat::INT::core.log.message(Log::Level::Trace, "Enabled VK extensions."); for(auto vk_extension: vk_extensions) { std::string message{"Extension name: "}; message += vk_extension; - BluCat::core.log.message(Log::Level::Trace, message); + BluCat::INT::core.log.message(Log::Level::Trace, message); } #endif } @@ -252,7 +252,7 @@ load_vk_instance(void *obj) vk_available_layers.data()); vk_available_layers_names.resize(vk_available_layers_count); #ifdef DEBUG - BluCat::core.log.message( + BluCat::INT::core.log.message( Log::Level::Trace, "Available VK instance layers."); #endif for(uint32_t i = 0; i < vk_available_layers_count; i++) @@ -266,7 +266,7 @@ load_vk_instance(void *obj) std::endl; message << "Implementation version: " << vk_available_layers[i].implementationVersion << std::endl; - BluCat::core.log.message(Log::Level::Trace, message.str()); + BluCat::INT::core.log.message(Log::Level::Trace, message.str()); #endif vk_available_layers_names[i] = vk_available_layers[i].layerName; @@ -283,12 +283,12 @@ load_vk_instance(void *obj) VkApplicationInfo app_info; app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; app_info.pNext = nullptr; - app_info.pApplicationName = BluCat::core.game_name.c_str(); + app_info.pApplicationName = BluCat::INT::core.game_name.c_str(); app_info.applicationVersion = VK_MAKE_VERSION( - BluCat::core.game_version_major, - BluCat::core.game_version_minor, - BluCat::core.game_version_patch); - app_info.pEngineName = "BluCat"; + BluCat::INT::core.game_version_major, + BluCat::INT::core.game_version_minor, + BluCat::INT::core.game_version_patch); + app_info.pEngineName = "BluCat::GRA"; app_info.engineVersion = VK_MAKE_VERSION( BLU_CAT_VERSION_MAJOR, BLU_CAT_VERSION_MINOR, @@ -306,7 +306,7 @@ load_vk_instance(void *obj) create_info.ppEnabledLayerNames = vk_required_layers_names.data(); VkResult result = - vkCreateInstance(&create_info, nullptr, &BluCat::core.vk_instance); + vkCreateInstance(&create_info, nullptr, &BluCat::INT::core.vk_instance); if(result != VK_SUCCESS) { std::string error{""}; @@ -327,14 +327,14 @@ load_vk_instance(void *obj) void unload_vk_instance(void *obj) { - vkDestroyInstance(BluCat::core.vk_instance, nullptr); + vkDestroyInstance(BluCat::INT::core.vk_instance, nullptr); } void load_window_surface(void *obj) { if(!SDL_Vulkan_CreateSurface( - cg_core.window, BluCat::core.vk_instance, &BluCat::core.window_surface)) + cg_core.window, BluCat::INT::core.vk_instance, &BluCat::INT::core.window_surface)) { std::string error{"Failed to create a window surface → "}; error += SDL_GetError(); @@ -346,19 +346,19 @@ void unload_window_surface(void *obj) { vkDestroySurfaceKHR( - BluCat::core.vk_instance, BluCat::core.window_surface, nullptr); + BluCat::INT::core.vk_instance, BluCat::INT::core.window_surface, nullptr); } void load_blucat(void *obj) { - BluCat::core.loader.execute(nullptr); + BluCat::INT::core.loader.execute(nullptr); } void unload_blucat(void *obj) { - BluCat::core.loader.revert(nullptr); + BluCat::INT::core.loader.revert(nullptr); } void diff --git a/src/core.hpp b/src/candy_gear/core.hpp index e7caf8b..60d8339 100644 --- a/src/core.hpp +++ b/src/candy_gear/core.hpp @@ -17,10 +17,6 @@ #ifndef CANDY_GEAR_CORE_H #define CANDY_GEAR_CORE_H 1 -#define CANDY_GEAR_VERSION_MAJOR 0 -#define CANDY_GEAR_VERSION_MINOR 1 -#define CANDY_GEAR_VERSION_PATCH 0 - #include <mruby.h> #include <mruby/class.h> #include <mruby/compile.h> @@ -41,7 +37,7 @@ #include <ft2build.h> #include FT_FREETYPE_H -#include "blucat/core.hpp" +#include "../blu_cat/int/core.hpp" /** * The Core class stores all global states that the engine needs to work. diff --git a/src/font.cpp b/src/candy_gear/font.cpp index 919d271..f9cbf44 100644 --- a/src/font.cpp +++ b/src/candy_gear/font.cpp @@ -16,12 +16,12 @@ #include "font.hpp" -#include "blucat/font.hpp" +#include "../blu_cat/gra/font.hpp" void cg_free_font(mrb_state *mrb, void *obj) { - auto ptr = static_cast<BluCat::Font*>(obj); + auto ptr = static_cast<BluCat::GRA::Font*>(obj); ptr->~Font(); mrb_free(mrb, ptr); @@ -33,18 +33,18 @@ cg_font_type = {"CG_Font", cg_free_font}; static mrb_value cg_cFont_initialize(mrb_state *mrb, mrb_value self) { - BluCat::Font *ptr; + BluCat::GRA::Font *ptr; const char *font_path; mrb_int font_size; mrb_get_args(mrb, "zi", &font_path, &font_size); - ptr = (BluCat::Font*)DATA_PTR(self); + ptr = (BluCat::GRA::Font*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (BluCat::Font*)mrb_malloc(mrb, sizeof(BluCat::Font)); + ptr = (BluCat::GRA::Font*)mrb_malloc(mrb, sizeof(BluCat::GRA::Font)); try { - new(ptr)BluCat::Font(font_path, font_size); + new(ptr)BluCat::GRA::Font(font_path, font_size); } catch(const std::invalid_argument &e) { diff --git a/src/font.hpp b/src/candy_gear/font.hpp index 0128ea0..0128ea0 100644 --- a/src/font.hpp +++ b/src/candy_gear/font.hpp diff --git a/src/graphic.cpp b/src/candy_gear/graphic.cpp index a991130..ad701d1 100644 --- a/src/graphic.cpp +++ b/src/candy_gear/graphic.cpp @@ -24,7 +24,7 @@ cg_mCandyGear_set_display_width(mrb_state *mrb, mrb_value self) mrb_int width; mrb_get_args(mrb, "i", &width); - BluCat::core.display_width = width; + BluCat::INT::core.display_width = width; return self; } @@ -35,7 +35,7 @@ cg_mCandyGear_set_display_height(mrb_state *mrb, mrb_value self) mrb_int height; mrb_get_args(mrb, "i", &height); - BluCat::core.display_height = height; + BluCat::INT::core.display_height = height; return self; } @@ -46,7 +46,7 @@ cg_mCandyGear_set_fps(mrb_state *mrb, mrb_value self) mrb_int fps; mrb_get_args(mrb, "i", &fps); - BluCat::core.fps = fps; + BluCat::INT::core.fps = fps; return self; } diff --git a/src/graphic.hpp b/src/candy_gear/graphic.hpp index fbd9df8..fbd9df8 100644 --- a/src/graphic.hpp +++ b/src/candy_gear/graphic.hpp diff --git a/src/key.cpp b/src/candy_gear/key.cpp index 615119c..615119c 100644 --- a/src/key.cpp +++ b/src/candy_gear/key.cpp diff --git a/src/key.hpp b/src/candy_gear/key.hpp index d3f4f5f..d3f4f5f 100644 --- a/src/key.hpp +++ b/src/candy_gear/key.hpp diff --git a/src/main.cpp b/src/candy_gear/main.cpp index 3627c9c..353b6bf 100644 --- a/src/main.cpp +++ b/src/candy_gear/main.cpp @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) SDL_Event event; // Random numbers - BluCat::random_number_generator.seed(BluCat::random_seed()); + BluCat::INT::random_number_generator.seed(BluCat::INT::random_seed()); cg_core.game_file = argv[1]; cg_core.mrb = mrb_open(); @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) try{ cg_sCore::loader.execute(nullptr); } catch(const CommandError &error) { - BluCat::core.log.message(Log::Level::Fatal, error.what()); + BluCat::INT::core.log.message(Log::Level::Fatal, error.what()); mrb_close(cg_core.mrb); return 1; } @@ -93,15 +93,15 @@ int main(int argc, char *argv[]) } else { - BluCat::core.vk_renderer->draw(); + BluCat::INT::core.vk_renderer->draw(); { // Timer auto frame_stop = steady_clock::now(); auto frame_duration = frame_stop - frame_start; // If frame take less time than maximum allowed. - if(BluCat::core.max_frame_duration > frame_duration) - sleep_for(BluCat::core.max_frame_duration - frame_duration); + if(BluCat::INT::core.max_frame_duration > frame_duration) + sleep_for(BluCat::INT::core.max_frame_duration - frame_duration); frame_start = frame_stop; } diff --git a/src/orientation_3d.cpp b/src/candy_gear/orientation_3d.cpp index cb42984..cb42984 100644 --- a/src/orientation_3d.cpp +++ b/src/candy_gear/orientation_3d.cpp diff --git a/src/orientation_3d.hpp b/src/candy_gear/orientation_3d.hpp index 45a8ab2..45a8ab2 100644 --- a/src/orientation_3d.hpp +++ b/src/candy_gear/orientation_3d.hpp diff --git a/src/skeletal_mesh.cpp b/src/candy_gear/skeletal_mesh.cpp index 90cbeee..4af4419 100644 --- a/src/skeletal_mesh.cpp +++ b/src/candy_gear/skeletal_mesh.cpp @@ -18,12 +18,12 @@ #include "orientation_3d.hpp" #include "vector_3d.hpp" -#include "blucat/skeletal_mesh.hpp" +#include "../blu_cat/gra/skeletal_mesh.hpp" void cg_free_skeletal_mesh(mrb_state *mrb, void* obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::SkeletalMesh>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::SkeletalMesh>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -37,16 +37,16 @@ cg_cSkeletalMesh_initialize(mrb_state *mrb, mrb_value self) { const char *file_path; - std::shared_ptr<BluCat::SkeletalMesh> *ptr; + std::shared_ptr<BluCat::GRA::SkeletalMesh> *ptr; mrb_get_args(mrb, "z", &file_path); - ptr = (std::shared_ptr<BluCat::SkeletalMesh>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::SkeletalMesh>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::SkeletalMesh>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::SkeletalMesh>)); + ptr = (std::shared_ptr<BluCat::GRA::SkeletalMesh>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::SkeletalMesh>)); - new(ptr)std::shared_ptr<BluCat::SkeletalMesh>( - std::make_shared<BluCat::SkeletalMesh>(file_path)); + new(ptr)std::shared_ptr<BluCat::GRA::SkeletalMesh>( + std::make_shared<BluCat::GRA::SkeletalMesh>(file_path)); mrb_data_init(self, ptr, &cg_skeletal_mesh_type); return self; diff --git a/src/skeletal_mesh.hpp b/src/candy_gear/skeletal_mesh.hpp index 476aa9b..476aa9b 100644 --- a/src/skeletal_mesh.hpp +++ b/src/candy_gear/skeletal_mesh.hpp diff --git a/src/skeletal_model.cpp b/src/candy_gear/skeletal_model.cpp index f42306b..41d0c9a 100644 --- a/src/skeletal_model.cpp +++ b/src/candy_gear/skeletal_model.cpp @@ -20,12 +20,12 @@ #include "vector_3d.hpp" #include "skeletal_mesh.hpp" #include "texture.hpp" -#include "blucat/skeletal_model.hpp" +#include "../blu_cat/gra/skeletal_model.hpp" void cg_free_skeletal_model(mrb_state *mrb, void *obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::SkeletalModel>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::SkeletalModel>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -37,23 +37,23 @@ const struct mrb_data_type cg_skeletal_model_type = { static mrb_value cg_cSkeletalModel_initialize(mrb_state *mrb, mrb_value self) { - std::shared_ptr<BluCat::SkeletalMesh> *skeletal_mesh; - std::shared_ptr<BluCat::Texture> *texture; + std::shared_ptr<BluCat::GRA::SkeletalMesh> *skeletal_mesh; + std::shared_ptr<BluCat::GRA::Texture> *texture; std::shared_ptr<glm::vec3> *position; std::shared_ptr<glm::quat> *orientation; - std::shared_ptr<BluCat::SkeletalModel> *ptr; + std::shared_ptr<BluCat::GRA::SkeletalModel> *ptr; mrb_get_args( mrb, "dddd", &skeletal_mesh, &cg_skeletal_mesh_type, &texture, &cg_texture_type, &position, &cg_vector_3d_type, &orientation, &cg_orientation_3d_type); - ptr = (std::shared_ptr<BluCat::SkeletalModel>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::SkeletalModel>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::SkeletalModel>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::SkeletalModel>)); + ptr = (std::shared_ptr<BluCat::GRA::SkeletalModel>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::SkeletalModel>)); - new(ptr)std::shared_ptr<BluCat::SkeletalModel>( - std::make_shared<BluCat::SkeletalModel>( + new(ptr)std::shared_ptr<BluCat::GRA::SkeletalModel>( + std::make_shared<BluCat::GRA::SkeletalModel>( *skeletal_mesh, *texture, *position, *orientation)); mrb_data_init(self, ptr, &cg_skeletal_model_type); @@ -63,7 +63,7 @@ cg_cSkeletalModel_initialize(mrb_state *mrb, mrb_value self) static mrb_value cg_cSkeletalModel_set_orientation(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::SkeletalModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::SkeletalModel>*)DATA_PTR(self); std::shared_ptr<glm::quat> *orientation; mrb_get_args(mrb, "d", &orientation, &cg_orientation_3d_type); @@ -75,7 +75,7 @@ cg_cSkeletalModel_set_orientation(mrb_state *mrb, mrb_value self) static mrb_value cg_cSkeletalModel_set_position(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::SkeletalModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::SkeletalModel>*)DATA_PTR(self); std::shared_ptr<glm::vec3> *position; mrb_get_args(mrb, "d", &position, &cg_vector_3d_type); @@ -87,7 +87,7 @@ cg_cSkeletalModel_set_position(mrb_state *mrb, mrb_value self) static mrb_value cg_cSkeletalModel_set_animation(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::SkeletalModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::SkeletalModel>*)DATA_PTR(self); mrb_int animation_index; mrb_get_args(mrb, "i", &animation_index); @@ -99,10 +99,10 @@ cg_cSkeletalModel_set_animation(mrb_state *mrb, mrb_value self) static mrb_value cg_cSkeletalModel_draw(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::SkeletalModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::SkeletalModel>*)DATA_PTR(self); - auto &instances = BluCat::core.vk_renderer->skeletal_models_to_draw[ - BluCat::core.vk_swapchain->current_frame][(*ptr)->skeletal_mesh]; + auto &instances = BluCat::INT::core.vk_renderer->skeletal_models_to_draw[ + BluCat::INT::core.vk_swapchain->current_frame][(*ptr)->skeletal_mesh]; instances.push_back(*ptr); return self; diff --git a/src/skeletal_model.hpp b/src/candy_gear/skeletal_model.hpp index 05f9c2e..05f9c2e 100644 --- a/src/skeletal_model.hpp +++ b/src/candy_gear/skeletal_model.hpp diff --git a/src/sound.cpp b/src/candy_gear/sound.cpp index 0b3518f..0b3518f 100644 --- a/src/sound.cpp +++ b/src/candy_gear/sound.cpp diff --git a/src/sound.hpp b/src/candy_gear/sound.hpp index 2f483e3..2f483e3 100644 --- a/src/sound.hpp +++ b/src/candy_gear/sound.hpp diff --git a/src/sprite.cpp b/src/candy_gear/sprite.cpp index 0041107..daf96a8 100644 --- a/src/sprite.cpp +++ b/src/candy_gear/sprite.cpp @@ -19,12 +19,12 @@ #include "texture.hpp" #include "vector_4d.hpp" #include "view_2d.hpp" -#include "blucat/sprite.hpp" +#include "../blu_cat/gra/sprite.hpp" void cg_free_sprite(mrb_state *mrb, void* obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::Sprite>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::Sprite>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -37,22 +37,22 @@ cg_cSprite_initialize(mrb_state *mrb, mrb_value self) { mrb_float x, y, w, h; glm::vec4 vector_4d; - std::shared_ptr<BluCat::Texture> *texture; - std::shared_ptr<BluCat::Sprite> *ptr; + std::shared_ptr<BluCat::GRA::Texture> *texture; + std::shared_ptr<BluCat::GRA::Sprite> *ptr; mrb_get_args( mrb, "dffff", &texture, &cg_texture_type, &x, &y, &w, &h); - ptr = (std::shared_ptr<BluCat::Sprite>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::Sprite>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::Sprite>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::Sprite>)); + ptr = (std::shared_ptr<BluCat::GRA::Sprite>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::Sprite>)); vector_4d.x = x; vector_4d.y = y; vector_4d.z = w; vector_4d.w = h; - new(ptr)std::shared_ptr<BluCat::Sprite>( - std::make_shared<BluCat::Sprite>(*texture, vector_4d)); + new(ptr)std::shared_ptr<BluCat::GRA::Sprite>( + std::make_shared<BluCat::GRA::Sprite>(*texture, vector_4d)); mrb_data_init(self, ptr, &cg_sprite_type); return self; @@ -62,9 +62,9 @@ static mrb_value cg_cSprite_draw(mrb_state *mrb, mrb_value self) { mrb_value view_value; - BluCat::View2D *view_2d; + BluCat::GRA::View2D *view_2d; mrb_float x, y, w, h, z_index{0.0}; - auto ptr = (std::shared_ptr<BluCat::Sprite>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::Sprite>*)DATA_PTR(self); mrb_get_args(mrb, "offff|f", &view_value, &x, &y, &w, &h, &z_index); @@ -72,7 +72,7 @@ cg_cSprite_draw(mrb_state *mrb, mrb_value self) glm::vec4 rect(x, y, x + w, y + h); auto &sprites_to_draw = view_2d->sprites_to_draw[ - BluCat::core.vk_swapchain->current_frame]; + BluCat::INT::core.vk_swapchain->current_frame]; sprites_to_draw.emplace_back(*ptr, rect, z_index); return self; diff --git a/src/sprite.hpp b/src/candy_gear/sprite.hpp index 528f2f7..528f2f7 100644 --- a/src/sprite.hpp +++ b/src/candy_gear/sprite.hpp diff --git a/src/sprite_3d.cpp b/src/candy_gear/sprite_3d.cpp index 6e6759f..d03b585 100644 --- a/src/sprite_3d.cpp +++ b/src/candy_gear/sprite_3d.cpp @@ -22,7 +22,7 @@ void cg_free_sprite_3d(mrb_state *mrb, void *obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::Sprite3D>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::Sprite3D>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -34,21 +34,21 @@ const struct mrb_data_type cg_sprite_3d_type = { static mrb_value cg_cSprite3D_initialize(mrb_state *mrb, mrb_value self) { - std::shared_ptr<BluCat::Sprite> *sprite; + std::shared_ptr<BluCat::GRA::Sprite> *sprite; std::shared_ptr<glm::vec3> *position; mrb_float w, h; - std::shared_ptr<BluCat::Sprite3D> *ptr; + std::shared_ptr<BluCat::GRA::Sprite3D> *ptr; mrb_get_args(mrb, "ddff", &sprite, &cg_sprite_type, &position, &cg_vector_3d_type, &w, &h); - ptr = (std::shared_ptr<BluCat::Sprite3D>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::Sprite3D>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::Sprite3D>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::Sprite3D>)); + ptr = (std::shared_ptr<BluCat::GRA::Sprite3D>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::Sprite3D>)); glm::vec3 size{w, h, 0.0}; - new(ptr)std::shared_ptr<BluCat::Sprite3D>( - std::make_shared<BluCat::Sprite3D>(*sprite, *position, size)); + new(ptr)std::shared_ptr<BluCat::GRA::Sprite3D>( + std::make_shared<BluCat::GRA::Sprite3D>(*sprite, *position, size)); mrb_data_init(self, ptr, &cg_sprite_3d_type); return self; @@ -57,10 +57,10 @@ cg_cSprite3D_initialize(mrb_state *mrb, mrb_value self) static mrb_value cg_cSprite3D_draw(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::Sprite3D>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::Sprite3D>*)DATA_PTR(self); - auto &sprites_3d_to_draw = BluCat::core.vk_renderer->sprites_3d_to_draw[ - BluCat::core.vk_swapchain->current_frame]; + auto &sprites_3d_to_draw = BluCat::INT::core.vk_renderer->sprites_3d_to_draw[ + BluCat::INT::core.vk_swapchain->current_frame]; sprites_3d_to_draw.emplace_back(*ptr); return self; diff --git a/src/sprite_3d.hpp b/src/candy_gear/sprite_3d.hpp index 526c23a..526c23a 100644 --- a/src/sprite_3d.hpp +++ b/src/candy_gear/sprite_3d.hpp diff --git a/src/static_mesh.cpp b/src/candy_gear/static_mesh.cpp index 3ae616e..9cb79ef 100644 --- a/src/static_mesh.cpp +++ b/src/candy_gear/static_mesh.cpp @@ -18,12 +18,12 @@ #include "orientation_3d.hpp" #include "vector_3d.hpp" -#include "blucat/static_mesh.hpp" +#include "../blu_cat/gra/static_mesh.hpp" void cg_free_static_mesh(mrb_state *mrb, void* obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::StaticMesh>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::StaticMesh>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -37,16 +37,16 @@ cg_cStaticMesh_initialize(mrb_state *mrb, mrb_value self) { const char *file_path; - std::shared_ptr<BluCat::StaticMesh> *ptr; + std::shared_ptr<BluCat::GRA::StaticMesh> *ptr; mrb_get_args(mrb, "z", &file_path); - ptr = (std::shared_ptr<BluCat::StaticMesh>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::StaticMesh>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::StaticMesh>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::StaticMesh>)); + ptr = (std::shared_ptr<BluCat::GRA::StaticMesh>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::StaticMesh>)); - new(ptr)std::shared_ptr<BluCat::StaticMesh>( - std::make_shared<BluCat::StaticMesh>(file_path)); + new(ptr)std::shared_ptr<BluCat::GRA::StaticMesh>( + std::make_shared<BluCat::GRA::StaticMesh>(file_path)); mrb_data_init(self, ptr, &cg_static_mesh_type); return self; diff --git a/src/static_mesh.hpp b/src/candy_gear/static_mesh.hpp index 8f3b2d6..8f3b2d6 100644 --- a/src/static_mesh.hpp +++ b/src/candy_gear/static_mesh.hpp diff --git a/src/static_model.cpp b/src/candy_gear/static_model.cpp index f9a1039..1a6eabe 100644 --- a/src/static_model.cpp +++ b/src/candy_gear/static_model.cpp @@ -20,12 +20,12 @@ #include "static_mesh.hpp" #include "texture.hpp" #include "vector_3d.hpp" -#include "blucat/static_model.hpp" +#include "../blu_cat/gra/static_model.hpp" void cg_free_static_model(mrb_state *mrb, void *obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::StaticModel>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::StaticModel>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -37,23 +37,23 @@ const struct mrb_data_type cg_static_model_type = { static mrb_value cg_cStaticModel_initialize(mrb_state *mrb, mrb_value self) { - std::shared_ptr<BluCat::StaticMesh> *static_mesh; - std::shared_ptr<BluCat::Texture> *texture; + std::shared_ptr<BluCat::GRA::StaticMesh> *static_mesh; + std::shared_ptr<BluCat::GRA::Texture> *texture; std::shared_ptr<glm::vec3> *position; std::shared_ptr<glm::quat> *orientation; - std::shared_ptr<BluCat::StaticModel> *ptr; + std::shared_ptr<BluCat::GRA::StaticModel> *ptr; mrb_get_args( mrb, "dddd", &static_mesh, &cg_static_mesh_type, &texture, &cg_texture_type, &position, &cg_vector_3d_type, &orientation, &cg_orientation_3d_type); - ptr = (std::shared_ptr<BluCat::StaticModel>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::StaticModel>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::StaticModel>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::StaticModel>)); + ptr = (std::shared_ptr<BluCat::GRA::StaticModel>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::StaticModel>)); - new(ptr)std::shared_ptr<BluCat::StaticModel>( - std::make_shared<BluCat::StaticModel>( + new(ptr)std::shared_ptr<BluCat::GRA::StaticModel>( + std::make_shared<BluCat::GRA::StaticModel>( *static_mesh, *texture, *position, *orientation)); mrb_data_init(self, ptr, &cg_static_model_type); @@ -63,7 +63,7 @@ cg_cStaticModel_initialize(mrb_state *mrb, mrb_value self) static mrb_value cg_cStaticModel_set_orientation(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::StaticModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::StaticModel>*)DATA_PTR(self); std::shared_ptr<glm::quat> *orientation; mrb_get_args(mrb, "d", &orientation, &cg_orientation_3d_type); @@ -75,7 +75,7 @@ cg_cStaticModel_set_orientation(mrb_state *mrb, mrb_value self) static mrb_value cg_cStaticModel_set_position(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::StaticModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::StaticModel>*)DATA_PTR(self); std::shared_ptr<glm::vec3> *position; mrb_get_args(mrb, "d", &position, &cg_vector_3d_type); @@ -87,8 +87,8 @@ cg_cStaticModel_set_position(mrb_state *mrb, mrb_value self) static mrb_value cg_cStaticModel_set_texture(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::StaticModel>*)DATA_PTR(self); - std::shared_ptr<BluCat::Texture> *texture; + auto ptr = (std::shared_ptr<BluCat::GRA::StaticModel>*)DATA_PTR(self); + std::shared_ptr<BluCat::GRA::Texture> *texture; mrb_get_args(mrb, "d", &texture, &cg_texture_type); (*ptr)->texture = *texture; @@ -99,10 +99,10 @@ cg_cStaticModel_set_texture(mrb_state *mrb, mrb_value self) static mrb_value cg_cStaticModel_draw(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::StaticModel>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::StaticModel>*)DATA_PTR(self); - auto &instances = BluCat::core.vk_renderer->static_models_to_draw[ - BluCat::core.vk_swapchain->current_frame][(*ptr)->static_mesh]; + auto &instances = BluCat::INT::core.vk_renderer->static_models_to_draw[ + BluCat::INT::core.vk_swapchain->current_frame][(*ptr)->static_mesh]; instances.push_back(*ptr); return self; diff --git a/src/static_model.hpp b/src/candy_gear/static_model.hpp index dfb7054..dfb7054 100644 --- a/src/static_model.hpp +++ b/src/candy_gear/static_model.hpp diff --git a/src/texture.cpp b/src/candy_gear/texture.cpp index 0bfac25..355a622 100644 --- a/src/texture.cpp +++ b/src/candy_gear/texture.cpp @@ -18,12 +18,12 @@ #include "core.hpp" #include "font.hpp" -#include "blucat/texture.hpp" +#include "../blu_cat/gra/texture.hpp" void cg_free_texture(mrb_state *mrb, void* obj) { - auto *ptr = static_cast<std::shared_ptr<BluCat::Texture>*>(obj); + auto *ptr = static_cast<std::shared_ptr<BluCat::GRA::Texture>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -48,15 +48,15 @@ cg_cTexture_from_image(mrb_state *mrb, mrb_value self) { struct mrb_value texture = texture_alloc(mrb, self); const char *file_path; - std::shared_ptr<BluCat::Texture> *ptr; + std::shared_ptr<BluCat::GRA::Texture> *ptr; mrb_get_args(mrb, "z", &file_path); - ptr = (std::shared_ptr<BluCat::Texture>*)DATA_PTR(texture); + ptr = (std::shared_ptr<BluCat::GRA::Texture>*)DATA_PTR(texture); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::Texture>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::Texture>)); - new(ptr)std::shared_ptr<BluCat::Texture>( - std::make_shared<BluCat::Texture>(file_path)); + ptr = (std::shared_ptr<BluCat::GRA::Texture>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::Texture>)); + new(ptr)std::shared_ptr<BluCat::GRA::Texture>( + std::make_shared<BluCat::GRA::Texture>(file_path)); mrb_data_init(texture, ptr, &cg_texture_type); return texture; @@ -68,17 +68,17 @@ cg_cTexture_from_text(mrb_state *mrb, mrb_value self) const char *text; unsigned int width, height; struct mrb_value texture = texture_alloc(mrb, self); - BluCat::Font *font_ptr; - std::shared_ptr<BluCat::Texture> *ptr; + BluCat::GRA::Font *font_ptr; + std::shared_ptr<BluCat::GRA::Texture> *ptr; mrb_get_args(mrb, "dz", &font_ptr, &cg_font_type, &text); - ptr = (std::shared_ptr<BluCat::Texture>*)DATA_PTR(texture); + ptr = (std::shared_ptr<BluCat::GRA::Texture>*)DATA_PTR(texture); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::Texture>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::Texture>)); - new(ptr)std::shared_ptr<BluCat::Texture>( - std::make_shared<BluCat::Texture>(font_ptr, text)); + ptr = (std::shared_ptr<BluCat::GRA::Texture>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::Texture>)); + new(ptr)std::shared_ptr<BluCat::GRA::Texture>( + std::make_shared<BluCat::GRA::Texture>(font_ptr, text)); mrb_data_init(texture, ptr, &cg_texture_type); return texture; @@ -87,14 +87,14 @@ cg_cTexture_from_text(mrb_state *mrb, mrb_value self) static mrb_value cg_cTexture_width(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::Texture>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::Texture>*)DATA_PTR(self); return mrb_int_value(mrb, (*ptr)->width); } static mrb_value cg_cTexture_height(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::Texture>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::Texture>*)DATA_PTR(self); return mrb_int_value(mrb, (*ptr)->height); } diff --git a/src/texture.hpp b/src/candy_gear/texture.hpp index 36f23db..cd96026 100644 --- a/src/texture.hpp +++ b/src/candy_gear/texture.hpp @@ -18,7 +18,7 @@ #define CANDY_GEAR_TEXTURE_H 1 #include "core.hpp" -#include "blucat/command.hpp" +#include "../blu_cat/com/command.hpp" extern const struct mrb_data_type cg_texture_type; diff --git a/src/vector_3d.cpp b/src/candy_gear/vector_3d.cpp index fc5d186..fc5d186 100644 --- a/src/vector_3d.cpp +++ b/src/candy_gear/vector_3d.cpp diff --git a/src/vector_3d.hpp b/src/candy_gear/vector_3d.hpp index 2827813..2827813 100644 --- a/src/vector_3d.hpp +++ b/src/candy_gear/vector_3d.hpp diff --git a/src/vector_4d.cpp b/src/candy_gear/vector_4d.cpp index dedda2f..b44b612 100644 --- a/src/vector_4d.cpp +++ b/src/candy_gear/vector_4d.cpp @@ -348,7 +348,7 @@ static mrb_value cg_cVector4D_draw_rectangle(mrb_state *mrb, mrb_value self) { mrb_value view_value; - BluCat::View2D *view_2d; + BluCat::GRA::View2D *view_2d; std::shared_ptr<glm::vec3> *color; auto ptr = (std::shared_ptr<glm::vec4>*)DATA_PTR(self); @@ -358,9 +358,9 @@ cg_cVector4D_draw_rectangle(mrb_state *mrb, mrb_value self) glm::vec4 position( (*ptr)->x, (*ptr)->y, (*ptr)->x + (*ptr)->z, (*ptr)->y + (*ptr)->w); - BluCat::Rectangle rect{position, (**color)}; + BluCat::GRA::Rectangle rect{position, (**color)}; auto &rectangles = view_2d->rectangles_to_draw[ - BluCat::core.vk_swapchain->current_frame]; + BluCat::INT::core.vk_swapchain->current_frame]; rectangles.push_back(rect); return self; diff --git a/src/vector_4d.hpp b/src/candy_gear/vector_4d.hpp index 2797d53..2797d53 100644 --- a/src/vector_4d.hpp +++ b/src/candy_gear/vector_4d.hpp diff --git a/src/view_2d.cpp b/src/candy_gear/view_2d.cpp index 09cbac1..e0dc8a1 100644 --- a/src/view_2d.cpp +++ b/src/candy_gear/view_2d.cpp @@ -19,13 +19,13 @@ #include "sprite.hpp" #include "vector_4d.hpp" #include "view_3d.hpp" -#include "blucat/sprite.hpp" -#include "blucat/view_2d.hpp" +#include "../blu_cat/gra/sprite.hpp" +#include "../blu_cat/gra/view_2d.hpp" void cg_free_view_2d(mrb_state *mrb, void* obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::View2D>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::View2D>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -38,35 +38,35 @@ cg_cView2D_initialize(mrb_state *mrb, mrb_value self) { std::shared_ptr<glm::vec4> *region; mrb_float projection_width, projection_height; - std::shared_ptr<BluCat::View2D> *ptr; + std::shared_ptr<BluCat::GRA::View2D> *ptr; mrb_get_args(mrb, "dff", ®ion, &cg_vector_4d_type, &projection_width, &projection_height); - ptr = (std::shared_ptr<BluCat::View2D>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::View2D>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::View2D>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::View2D>)); + ptr = (std::shared_ptr<BluCat::GRA::View2D>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::View2D>)); - new(ptr)std::shared_ptr<BluCat::View2D>( - std::make_shared<BluCat::View2D>( + new(ptr)std::shared_ptr<BluCat::GRA::View2D>( + std::make_shared<BluCat::GRA::View2D>( *region->get(), projection_width, projection_height)); mrb_data_init(self, ptr, &cg_view_2d_type); return self; } -BluCat::View2D* +BluCat::GRA::View2D* cg_cView_to_view_2d(mrb_state *mrb, mrb_value view_value) { - BluCat::View2D* view_2d; + BluCat::GRA::View2D* view_2d; const mrb_data_type *type = DATA_TYPE(view_value); if(type == &cg_view_2d_type) - view_2d = static_cast<std::shared_ptr<BluCat::View2D>*>( + view_2d = static_cast<std::shared_ptr<BluCat::GRA::View2D>*>( DATA_PTR(view_value))->get(); else if (type == &cg_view_3d_type) - view_2d = static_cast<BluCat::View2D*>( - static_cast<std::shared_ptr<BluCat::View3D>*>( + view_2d = static_cast<BluCat::GRA::View2D*>( + static_cast<std::shared_ptr<BluCat::GRA::View3D>*>( DATA_PTR(view_value))->get()); else mrb_raisef( diff --git a/src/view_2d.hpp b/src/candy_gear/view_2d.hpp index a18937e..9b742a0 100644 --- a/src/view_2d.hpp +++ b/src/candy_gear/view_2d.hpp @@ -23,8 +23,8 @@ extern const struct mrb_data_type cg_view_2d_type; // Receives a mrb_value that points to a View2D or a View3D and returns a // pointer to View2D. If the mrb_value points to a View3D, the view will be -// cast to a BluCat::View2D. -BluCat::View2D* +// cast to a BluCat::GRA::View2D. +BluCat::GRA::View2D* cg_cView_to_view_2d(mrb_state *mrb, mrb_value view_value); void diff --git a/src/view_3d.cpp b/src/candy_gear/view_3d.cpp index ddaa3eb..b829cca 100644 --- a/src/view_3d.cpp +++ b/src/candy_gear/view_3d.cpp @@ -20,13 +20,13 @@ #include "orientation_3d.hpp" #include "vector_3d.hpp" #include "vector_4d.hpp" -#include "blucat/sprite.hpp" -#include "blucat/view_3d.hpp" +#include "../blu_cat/gra/sprite.hpp" +#include "../blu_cat/gra/view_3d.hpp" void cg_free_view_3d(mrb_state *mrb, void* obj) { - auto ptr = static_cast<std::shared_ptr<BluCat::View3D>*>(obj); + auto ptr = static_cast<std::shared_ptr<BluCat::GRA::View3D>*>(obj); ptr->~shared_ptr(); mrb_free(mrb, ptr); @@ -39,17 +39,17 @@ cg_cView3D_initialize(mrb_state *mrb, mrb_value self) { std::shared_ptr<glm::vec4> *region; mrb_float projection_width, projection_height; - std::shared_ptr<BluCat::View3D> *ptr; + std::shared_ptr<BluCat::GRA::View3D> *ptr; mrb_get_args(mrb, "dff", ®ion, &cg_vector_4d_type, &projection_width, &projection_height); - ptr = (std::shared_ptr<BluCat::View3D>*)DATA_PTR(self); + ptr = (std::shared_ptr<BluCat::GRA::View3D>*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); - ptr = (std::shared_ptr<BluCat::View3D>*)mrb_malloc( - mrb, sizeof(std::shared_ptr<BluCat::View3D>)); + ptr = (std::shared_ptr<BluCat::GRA::View3D>*)mrb_malloc( + mrb, sizeof(std::shared_ptr<BluCat::GRA::View3D>)); - new(ptr)std::shared_ptr<BluCat::View3D>( - std::make_shared<BluCat::View3D>( + new(ptr)std::shared_ptr<BluCat::GRA::View3D>( + std::make_shared<BluCat::GRA::View3D>( *region->get(), projection_width, projection_height)); mrb_data_init(self, ptr, &cg_view_3d_type); @@ -60,7 +60,7 @@ static mrb_value cg_cView3D_set_camera_position(mrb_state *mrb, mrb_value self) { std::shared_ptr<glm::vec3> *camera_position; - auto ptr = (std::shared_ptr<BluCat::View3D>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::View3D>*)DATA_PTR(self); mrb_get_args(mrb, "d", &camera_position, &cg_vector_3d_type); (*ptr)->camera_position = (*camera_position); @@ -72,7 +72,7 @@ static mrb_value cg_cView3D_set_camera_orientation(mrb_state *mrb, mrb_value self) { std::shared_ptr<glm::quat> *camera_orientation; - auto ptr = (std::shared_ptr<BluCat::View3D>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::View3D>*)DATA_PTR(self); mrb_get_args(mrb, "d", &camera_orientation, &cg_orientation_3d_type); (*ptr)->camera_orientation = (*camera_orientation); @@ -83,7 +83,7 @@ cg_cView3D_set_camera_orientation(mrb_state *mrb, mrb_value self) static mrb_value cg_cView3D_get_field_of_view(mrb_state *mrb, mrb_value self) { - auto ptr = (std::shared_ptr<BluCat::View3D>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::View3D>*)DATA_PTR(self); return mrb_float_value(mrb, (*ptr)->field_of_view); @@ -94,7 +94,7 @@ static mrb_value cg_cView3D_set_field_of_view(mrb_state *mrb, mrb_value self) { mrb_float fov; - auto ptr = (std::shared_ptr<BluCat::View3D>*)DATA_PTR(self); + auto ptr = (std::shared_ptr<BluCat::GRA::View3D>*)DATA_PTR(self); mrb_get_args(mrb, "f", &fov); (*ptr)->field_of_view = fov; diff --git a/src/view_3d.hpp b/src/candy_gear/view_3d.hpp index 22aa084..22aa084 100644 --- a/src/view_3d.hpp +++ b/src/candy_gear/view_3d.hpp |