diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-27 17:03:43 -0400 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-27 17:03:43 -0400 |
commit | 9b60b862e58905780bf47f69a34522fde046ebea (patch) | |
tree | bda8f9c998cdeec6ad1a5b4fb6e60800dbaca8ad /engine | |
parent | async chunk meshing (diff) | |
download | minecraftvulkan-9b60b862e58905780bf47f69a34522fde046ebea.tar.gz minecraftvulkan-9b60b862e58905780bf47f69a34522fde046ebea.tar.bz2 minecraftvulkan-9b60b862e58905780bf47f69a34522fde046ebea.zip |
procedural chunk loading
Diffstat (limited to 'engine')
-rw-r--r-- | engine/xe_engine.cpp | 18 | ||||
-rw-r--r-- | engine/xe_engine.hpp | 10 | ||||
-rw-r--r-- | engine/xe_image.cpp | 3 | ||||
-rw-r--r-- | engine/xe_image.hpp | 2 | ||||
-rw-r--r-- | engine/xe_model.cpp | 7 | ||||
-rw-r--r-- | engine/xe_model.hpp | 4 | ||||
-rw-r--r-- | engine/xe_renderer.hpp | 1 |
7 files changed, 12 insertions, 33 deletions
diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp index 6392d78..201ea81 100644 --- a/engine/xe_engine.cpp +++ b/engine/xe_engine.cpp @@ -32,24 +32,6 @@ void Engine::loadDescriptorPool() { .build(); } -Model* Engine::loadModelFromFile(const std::string &filename) { - return Model::createModelFromFile(xeDevice, filename); -} - -Model* Engine::loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices) { - Model::Builder builder{}; - builder.vertexData.data = vertexData; - builder.vertexSize = vertexSize; - if(indices.size() > 0) { - builder.indices = indices; - } - return new Model(xeDevice, builder); -} - -Image* Engine::loadImageFromFile(const std::string &filename, bool anisotropic) { - return new Image(xeDevice, filename, anisotropic); -} - bool Engine::poll() { glfwPollEvents(); auto newTime = std::chrono::high_resolution_clock::now(); diff --git a/engine/xe_engine.hpp b/engine/xe_engine.hpp index eff2d13..ae75afa 100644 --- a/engine/xe_engine.hpp +++ b/engine/xe_engine.hpp @@ -1,13 +1,12 @@ #pragma once +#include "xe_buffer.hpp" #include "xe_device.hpp" #include "xe_renderer.hpp" #include "xe_camera.hpp" #include "xe_descriptors.hpp" -#include "xe_image.hpp" #include "xe_input.hpp" #include "xe_sound.hpp" -#include "xe_model.hpp" #include <chrono> #include <string> @@ -30,11 +29,6 @@ class Engine { Input& getInput() {return xeInput;} Camera& getCamera() {return xeCamera;} - Device& getDevice() {return xeDevice;} - - Model* loadModelFromFile(const std::string &filename); - Model* loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices); - Image* loadImageFromFile(const std::string &filename, bool anisotropic = true); bool beginFrame() { return xeRenderer.beginFrame(); } void endFrame() { xeRenderer.endFrame(); } @@ -63,6 +57,8 @@ class Engine { std::unique_ptr<DescriptorPool> xeDescriptorPool; friend class RenderSystem; + friend class Image; + friend class Model; }; }
\ No newline at end of file diff --git a/engine/xe_image.cpp b/engine/xe_image.cpp index cabcea3..1ac82e2 100644 --- a/engine/xe_image.cpp +++ b/engine/xe_image.cpp @@ -1,4 +1,5 @@ #include "xe_image.hpp" +#include "xe_engine.hpp" #include <vulkan/vulkan.h> #include <stdexcept> @@ -10,7 +11,7 @@ namespace xe { -Image::Image(Device &xeDevice, const std::string &filename, bool anisotropic) : xeDevice{xeDevice} { +Image::Image(const std::string &filename, bool anisotropic) : xeDevice{Engine::getInstance()->xeDevice} { createTextureImage(filename); createTextureImageView(); createTextureSampler(anisotropic); diff --git a/engine/xe_image.hpp b/engine/xe_image.hpp index 6520a95..bc1dad2 100644 --- a/engine/xe_image.hpp +++ b/engine/xe_image.hpp @@ -10,7 +10,7 @@ class Image { public: - Image(Device &xeDevice, const std::string &filename, bool anisotropic); + Image(const std::string &filename, bool anisotropic); ~Image(); Image(const Image&) = delete; diff --git a/engine/xe_model.cpp b/engine/xe_model.cpp index ff0d630..dc39584 100644 --- a/engine/xe_model.cpp +++ b/engine/xe_model.cpp @@ -1,4 +1,5 @@ #include "xe_model.hpp" +#include "xe_engine.hpp" #define TINYOBJLOADER_IMPLEMENTATION #include "xe_obj_loader.hpp" @@ -13,17 +14,17 @@ namespace xe { -Model::Model(Device &device, const Model::Builder &builder) : xeDevice{device} { +Model::Model(const Model::Builder &builder) : xeDevice{Engine::getInstance()->xeDevice} { createVertexBuffers(builder.vertexData.data, builder.vertexSize); createIndexBuffers(builder.indices); } Model::~Model() {} -Model* Model::createModelFromFile(Device &device, const std::string &filepath) { +Model* Model::createModelFromFile(const std::string &filepath) { Builder builder{}; builder.loadModel(filepath); - return new Model(device, builder); + return new Model(builder); } void Model::createVertexBuffers(const std::vector<unsigned char> &vertexData, uint32_t vertexSize) { diff --git a/engine/xe_model.hpp b/engine/xe_model.hpp index 1886657..b75576e 100644 --- a/engine/xe_model.hpp +++ b/engine/xe_model.hpp @@ -34,13 +34,13 @@ class Model { void loadModel(const std::string &filepath); }; - Model(Device &device, const Model::Builder &builder); + Model(const Model::Builder &builder); ~Model(); Model(const Model &) = delete; Model operator=(const Model &) = delete; - static Model* createModelFromFile(Device &device, const std::string &filepath); + static Model* createModelFromFile(const std::string &filepath); void bind(VkCommandBuffer commandBuffer); void draw(VkCommandBuffer commandBuffer); diff --git a/engine/xe_renderer.hpp b/engine/xe_renderer.hpp index 547de1e..8742f75 100644 --- a/engine/xe_renderer.hpp +++ b/engine/xe_renderer.hpp @@ -1,7 +1,6 @@ #pragma once #include "xe_device.hpp" -#include "xe_game_object.hpp" #include "xe_swap_chain.hpp" #include "xe_descriptors.hpp" #include "xe_window.hpp" |