#include "xe_engine.hpp" namespace xe { XeEngine::XeEngine(int width, int height, std::string name) : xeWindow{width, height, name}, xeDevice{xeWindow}, xeRenderer{xeWindow, xeDevice}, xeCamera{}, xeInput{xeWindow} { loadDescriptorPool(); alutInit(0, NULL); std::cout << "Audio device: " << alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER) << "\n"; }; XeEngine::~XeEngine() { alutExit(); }; void XeEngine::loadDescriptorPool() { xeDescriptorPool = XeDescriptorPool::Builder(xeDevice) .setMaxSets(XeSwapChain::MAX_FRAMES_IN_FLIGHT) .addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT) .addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT) .addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, XeSwapChain::MAX_FRAMES_IN_FLIGHT) .build(); } std::shared_ptr XeEngine::loadModelFromFile(const std::string &filename) { return XeModel::createModelFromFile(xeDevice, filename); } std::shared_ptr XeEngine::loadModelFromData(std::vector vertices, std::vector indices) { XeModel::Builder builder{}; builder.vertices = vertices; if(indices.size() > 0) { builder.indices = indices; } return std::make_shared(xeDevice, builder); } std::shared_ptr XeEngine::loadImage(const std::string &filename) { return std::make_shared(xeDevice, filename); } bool XeEngine::poll() { glfwPollEvents(); auto newTime = std::chrono::high_resolution_clock::now(); frameTime = std::chrono::duration(newTime - currentTime).count(); currentTime = newTime; float aspect = xeRenderer.getAspectRatio(); xeCamera.setPerspectiveProjection(glm::radians(FOV), aspect, 0.1f, 100.f); return !xeWindow.shouldClose(); } }