diff --git a/engine/include/sophia/application.hpp b/engine/include/sophia/application.hpp index cb75d9b..89d7e29 100644 --- a/engine/include/sophia/application.hpp +++ b/engine/include/sophia/application.hpp @@ -43,8 +43,8 @@ class Application { private: friend class Canvas; - void pushModel(std::vector vertices, std::vector indices); - void clearModels(); + void pushMesh(std::vector vertices, std::vector indices); + void clearMeshes(); class Impl; std::unique_ptr impl; diff --git a/engine/include/sophia/camera_2d.hpp b/engine/include/sophia/camera_2d.hpp index 177674c..fed29ed 100644 --- a/engine/include/sophia/camera_2d.hpp +++ b/engine/include/sophia/camera_2d.hpp @@ -2,7 +2,6 @@ #define GLM_FORCE_RADIANS #define GLM_FORCE_DEPTH_ZERO_TO_ONE - #include #include diff --git a/engine/src/application.cpp b/engine/src/application.cpp index 88cde93..85275c7 100644 --- a/engine/src/application.cpp +++ b/engine/src/application.cpp @@ -14,7 +14,7 @@ #include "buffer.hpp" #include "device.hpp" -#include "model.hpp" +#include "mesh.hpp" #include "pipelines/graphics_pipeline.hpp" #include "render_context.hpp" #include "shader.hpp" @@ -183,7 +183,7 @@ class Application::Impl { commandBuffer.setViewport(0, viewport); commandBuffer.setScissor(0, scissor); - modelRenderSystem.render(commandBuffer, this->models, frameInfo); + modelRenderSystem.render(commandBuffer, this->meshes, frameInfo); commandBuffer.endRendering(); @@ -205,23 +205,23 @@ class Application::Impl { log::info("Application ran for", totalRuntime, "s"); } - void pushModel(std::vector vertices, std::vector indices) { - Model::Builder builder{}; + void pushMesh(std::vector vertices, std::vector indices) { + Mesh::Builder builder{}; builder.vertices.reserve(vertices.size()); for (const CanvasVertex& vertex : vertices) { builder.vertices.push_back({vertex.position, vertex.color}); } builder.indices = std::move(indices); - this->models.push_back(std::make_unique(this->device, builder)); + this->meshes.push_back(std::make_unique(this->device, builder)); } - void clearModels() { - // Models back live GPU vertex buffers and up to MAX_FRAMES_IN_FLIGHT + void clearMeshes() { + // Meshes back live GPU vertex buffers and up to MAX_FRAMES_IN_FLIGHT // command buffers may still be executing against them, so wait for the // device to go idle before freeing anything. this->device.waitIdle(); - this->models.clear(); + this->meshes.clear(); } private: @@ -231,7 +231,7 @@ class Application::Impl { Device device; RenderContext renderContext; - std::vector> models; + std::vector> meshes; }; void Application::setCommandLineArgs(int argc, const char* const* argv) { @@ -247,11 +247,11 @@ Application::~Application() = default; void Application::run() { impl->run(); } -void Application::pushModel(std::vector vertices, - std::vector indices) { - impl->pushModel(std::move(vertices), std::move(indices)); +void Application::pushMesh(std::vector vertices, + std::vector indices) { + impl->pushMesh(std::move(vertices), std::move(indices)); } -void Application::clearModels() { impl->clearModels(); } +void Application::clearMeshes() { impl->clearMeshes(); } } // namespace sophia diff --git a/engine/src/canvas.cpp b/engine/src/canvas.cpp index 36c0ab8..f6d2aaa 100644 --- a/engine/src/canvas.cpp +++ b/engine/src/canvas.cpp @@ -15,7 +15,7 @@ class Canvas::Impl { {c, color}, }; - application->pushModel(std::move(vertices), {}); + application->pushMesh(std::move(vertices), {}); } void quad(glm::vec2 position, glm::vec2 size, @@ -28,10 +28,10 @@ class Canvas::Impl { }; std::vector indices{0, 1, 2, 2, 3, 0}; - application->pushModel(std::move(vertices), std::move(indices)); + application->pushMesh(std::move(vertices), std::move(indices)); } - void clear() { application->clearModels(); } + void clear() { application->clearMeshes(); } private: Application* application; diff --git a/engine/src/model.cpp b/engine/src/mesh.cpp similarity index 88% rename from engine/src/model.cpp rename to engine/src/mesh.cpp index b84b70e..f1d8311 100644 --- a/engine/src/model.cpp +++ b/engine/src/mesh.cpp @@ -1,4 +1,4 @@ -#include "model.hpp" +#include "mesh.hpp" #include #include @@ -6,7 +6,7 @@ namespace sophia { std::vector -Model::Vertex::getBindingDescriptions() { +Mesh::Vertex::getBindingDescriptions() { std::vector bindingDescriptions(1); bindingDescriptions[0].binding = 0; bindingDescriptions[0].stride = sizeof(Vertex); @@ -16,7 +16,7 @@ Model::Vertex::getBindingDescriptions() { } std::vector -Model::Vertex::getAttributeDescriptions() { +Mesh::Vertex::getAttributeDescriptions() { std::vector attributeDescriptions{}; attributeDescriptions.push_back( @@ -31,14 +31,14 @@ Model::Vertex::getAttributeDescriptions() { return attributeDescriptions; } -Model::Model(Device& device, const Builder& builder) : device{device} { +Mesh::Mesh(Device& device, const Builder& builder) : device{device} { createVertexBuffers(builder.vertices); createIndexBuffers(builder.indices); } -Model::~Model() {} +Mesh::~Mesh() {} -void Model::bind(vk::CommandBuffer commandBuffer) { +void Mesh::bind(vk::CommandBuffer commandBuffer) { vk::Buffer buffers[] = {this->vertexBuffer->getBuffer()}; vk::DeviceSize offset[] = {0}; commandBuffer.bindVertexBuffers(0, 1, buffers, offset); @@ -49,7 +49,7 @@ void Model::bind(vk::CommandBuffer commandBuffer) { } } -void Model::draw(vk::CommandBuffer commandBuffer) { +void Mesh::draw(vk::CommandBuffer commandBuffer) { if (this->hasIndexBuffer) { commandBuffer.drawIndexed(this->indexCount, 1, 0, 0, 0); } else { @@ -57,7 +57,7 @@ void Model::draw(vk::CommandBuffer commandBuffer) { } } -void Model::createVertexBuffers(const std::vector& vertices) { +void Mesh::createVertexBuffers(const std::vector& vertices) { this->vertexCount = static_cast(vertices.size()); assert(this->vertexCount >= 3 && "vertex count must be at least 3"); @@ -87,7 +87,7 @@ void Model::createVertexBuffers(const std::vector& vertices) { this->vertexBuffer->getBuffer(), bufferSize); } -void Model::createIndexBuffers(const std::vector& indicies) { +void Mesh::createIndexBuffers(const std::vector& indicies) { this->indexCount = static_cast(indicies.size()); this->hasIndexBuffer = this->indexCount > 0; diff --git a/engine/src/model.hpp b/engine/src/mesh.hpp similarity index 85% rename from engine/src/model.hpp rename to engine/src/mesh.hpp index d3247de..0a16710 100644 --- a/engine/src/model.hpp +++ b/engine/src/mesh.hpp @@ -12,7 +12,7 @@ namespace sophia { -class Model { +class Mesh { public: struct Vertex { glm::vec2 position{}; @@ -37,13 +37,13 @@ class Model { // void loadModel(const std::string& filepath); }; - Model(Device& device, const Model::Builder& builder); - ~Model(); + Mesh(Device& device, const Mesh::Builder& builder); + ~Mesh(); - Model(const Model&) = delete; - Model& operator=(const Model&) = delete; + Mesh(const Mesh&) = delete; + Mesh& operator=(const Mesh&) = delete; - // static std::unique_ptr createModelFromFile( + // static std::unique_ptr createMeshFromFile( // Device& device, const std::string& filepath); void bind(vk::CommandBuffer commandBuffer); diff --git a/engine/src/systems/model_render_system.cpp b/engine/src/systems/model_render_system.cpp index 2897d23..b6b7e8a 100644 --- a/engine/src/systems/model_render_system.cpp +++ b/engine/src/systems/model_render_system.cpp @@ -24,8 +24,8 @@ ModelRenderSystem::ModelRenderSystem(Device& device, .setStage(ShaderStage::FRAGMENT) .build(); - auto bindingDescriptions = Model::Vertex::getBindingDescriptions(); - auto attributeDescriptions = Model::Vertex::getAttributeDescriptions(); + auto bindingDescriptions = Mesh::Vertex::getBindingDescriptions(); + auto attributeDescriptions = Mesh::Vertex::getAttributeDescriptions(); this->graphicsPipeline = GraphicsPipeline::Builder(device) @@ -42,13 +42,13 @@ ModelRenderSystem::~ModelRenderSystem() { } void ModelRenderSystem::render(vk::CommandBuffer commandBuffer, - std::span> models, + std::span> meshes, const FrameInfo& frameInfo) { glm::mat4 viewProjection = frameInfo.camera.getViewProjection(); this->graphicsPipeline->bind(commandBuffer); - for (const std::unique_ptr& model : models) { + for (const std::unique_ptr& mesh : meshes) { PushConstantData push{}; push.modelMatrix = viewProjection; @@ -57,8 +57,8 @@ void ModelRenderSystem::render(vk::CommandBuffer commandBuffer, vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0, sizeof(PushConstantData), &push); - model->bind(commandBuffer); - model->draw(commandBuffer); + mesh->bind(commandBuffer); + mesh->draw(commandBuffer); } } diff --git a/engine/src/systems/model_render_system.hpp b/engine/src/systems/model_render_system.hpp index 8edb308..4d0e4be 100644 --- a/engine/src/systems/model_render_system.hpp +++ b/engine/src/systems/model_render_system.hpp @@ -5,7 +5,7 @@ #include #include "device.hpp" -#include "model.hpp" +#include "mesh.hpp" #include "pipelines/graphics_pipeline.hpp" #include "render_context.hpp" @@ -25,7 +25,7 @@ class ModelRenderSystem { ~ModelRenderSystem(); void render(vk::CommandBuffer commandBuffer, - std::span> models, + std::span> meshes, const FrameInfo& frameInfo); private: