186 lines
3.4 KiB
C++
186 lines
3.4 KiB
C++
#pragma once
|
|
|
|
|
|
#ifndef TINYGLTF_IMPLEMENTATION
|
|
#define TINYGLTF_IMPLEMENTATION
|
|
#endif
|
|
#ifndef STB_IMAGE_IMPLEMENTATION
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
#endif
|
|
|
|
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
|
|
#define TINYGLTF_NO_STB_IMAGE_WRITE
|
|
#endif
|
|
|
|
|
|
#include <assert.h>
|
|
#include <chrono>
|
|
#include <cstdio>
|
|
#include <map>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <vector>
|
|
|
|
#include "algorithm"
|
|
#include <codecvt>
|
|
#include <filesystem>
|
|
#include <iostream>
|
|
#include <locale>
|
|
#include <sys/stat.h>
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#ifndef _GLFW3_H
|
|
#define _GLFW3_H
|
|
#include "GLFW/glfw3.h"
|
|
#endif // !_GLFW3_H
|
|
|
|
#ifndef _VULKANFOUNDATION_H
|
|
#define _VULKANFOUNDATION_H
|
|
#include "vulkanFoundation.h"
|
|
#endif // !VULKANFOUNDATION_H
|
|
|
|
#ifndef _GLTFMODEL_H
|
|
#define _GLTFMODEL_H
|
|
#include "glTFModel.h"
|
|
#endif // !GLTFMODEL_H
|
|
|
|
|
|
|
|
#ifndef _RENDERGUI_H
|
|
#define _RENDERGUI_H
|
|
#include "renderUI.h"
|
|
#endif // !_RENDERGUI_H
|
|
|
|
#ifndef _UI_HPP
|
|
#define _UI_HPP
|
|
#include "ui.hpp"
|
|
#endif // !UI_HPP
|
|
|
|
#ifndef _RENDERIO_H
|
|
#define _RENDERIO_H
|
|
#include "renderIO.h"
|
|
#endif // !RENDERIO_H
|
|
|
|
#ifndef _VULKANDEVICE_HPP
|
|
#define _VULKANDEVICE_HPP
|
|
#include "VulkanDevice.hpp"
|
|
#endif // !_VULKANDEVICE_HPP
|
|
|
|
#ifndef _CAMERA_HPP
|
|
#define _CAMERA_HPP
|
|
#include "camera.hpp"
|
|
#endif // !_CAMERA_HPP
|
|
|
|
#ifndef _VULKANTEXTURE_HPP
|
|
#define _VULKANTEXTURE_HPP
|
|
#include "VulkanTexture.hpp"
|
|
#endif // !_VULKANTEXTURE_HPP
|
|
|
|
#ifndef _VULKANUTILS_HPP
|
|
#define _VULKANUTILS_HPP
|
|
#include "VulkanUtils.hpp"
|
|
#endif // !_VULKANUTILS_HPP
|
|
|
|
#ifndef _STB_IMAGE_WRITE_H
|
|
#define _STB_IMAGE_WRITE_H
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
#include "stb_image_write.h"
|
|
#endif // !_STB_IMAGE_WRITE_H
|
|
|
|
|
|
#define ENABLE_VALIDATION false
|
|
|
|
PluamgeVulkanBackend::VulkanFoundation vkFoundation;
|
|
|
|
namespace PlumageRender
|
|
{
|
|
|
|
|
|
class renderMain
|
|
{
|
|
public:
|
|
|
|
GLFWwindow* window;
|
|
|
|
|
|
|
|
struct Models
|
|
{
|
|
glTFModel::Model scene;
|
|
glTFModel::Model skybox;
|
|
}models;
|
|
|
|
|
|
struct stat
|
|
{
|
|
|
|
} info;
|
|
|
|
|
|
glm::vec3 modelrot = glm::vec3(0.0f);
|
|
glm::vec3 modelPos = glm::vec3(0.0f);
|
|
|
|
uint32_t frameIndex = 0;
|
|
uint32_t frameCounter = 0;
|
|
|
|
//VkImage swapChainImage;
|
|
|
|
static uint32_t currentBuffer;
|
|
|
|
|
|
|
|
|
|
uint64_t savedFrameCounter = 1;
|
|
|
|
|
|
|
|
uint32_t lastFPS = 0;
|
|
float frameTimer = 1.0f;
|
|
float fpsTimer = 0.0f;
|
|
static int32_t animationIndex;
|
|
float animationTimer = 0.0f;
|
|
|
|
Camera camera;
|
|
|
|
|
|
renderMain();
|
|
~renderMain();
|
|
|
|
void initWindow(int width, int height);
|
|
static void framebufferResizeCallback(GLFWwindow* window, int width, int height);
|
|
void windowResized();
|
|
void prepare(Setter setter, PlumageGUI renderGUI, RenderInput renderInput, RenderOutput renderOutput, PBR::Material pbrMaterial, PluamgeVulkanBackend::VulkanFoundation vkFoundation, renderMain mainRender, UI* ui);
|
|
void setupCamera(Camera camera, Setter setter);
|
|
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
|
|
void submitToPresentQueue();
|
|
|
|
virtual void render(Setter setter, PlumageGUI plumageGUI, UI* gui, renderMain mainRender, PluamgeVulkanBackend::VulkanFoundation vkFoundation, RenderInput renderInput, RenderOutput renderOutput);
|
|
void renderLoop(GLFWwindow* window, Setter setter);
|
|
void drawFrame();
|
|
private:
|
|
|
|
|
|
bool framebufferResized = false;
|
|
|
|
bool prepared = false;
|
|
|
|
};
|
|
|
|
renderMain::renderMain()
|
|
{
|
|
|
|
}
|
|
|
|
renderMain::~renderMain()
|
|
{
|
|
models.scene.destroy(PluamgeVulkanBackend::VulkanFoundation::device);
|
|
models.skybox.destroy(PluamgeVulkanBackend::VulkanFoundation::device);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|