Add stuff

This commit is contained in:
Bailey Harrison 2022-10-21 12:31:46 +01:00
parent 92ff208c35
commit ddefcc1967
4 changed files with 133 additions and 0 deletions

View File

@ -31,6 +31,8 @@ add_library(${PROJECT_NAME} STATIC
"src/resource_manager.cpp"
"src/gfx_device_vulkan.cpp"
"src/gfx_device_null.cpp"
"src/gfx_device_opengl45.cpp"
# PUBLIC API

48
src/gfx_device_null.cpp Normal file
View File

@ -0,0 +1,48 @@
// The implementation of the graphics layer using Vulkan 1.3.
// This uses SDL specific code
#ifdef ENGINE_BUILD_NULLGFX
#include "gfx_device.hpp"
#include "util.hpp"
#include "config.h"
#include "log.hpp"
namespace engine {
// class definitions
struct GFXDevice::Impl {
};
GFXDevice::GFXDevice(const char* appName, const char* appVersion, SDL_Window* window)
{
pimpl = std::make_unique<Impl>();
}
GFXDevice::~GFXDevice()
{
TRACE("Destroying GFXDevice...");
}
void GFXDevice::draw()
{
}
void GFXDevice::createPipeline(const char* vertShaderPath, const char* fragShaderPath)
{
}
bool GFXDevice::createBuffer(const gfx::BufferDesc& desc, const void* data, gfx::BufferHandle* out)
{
return true;
}
void GFXDevice::waitIdle()
{
}
}
#endif

View File

@ -0,0 +1,82 @@
// The implementation of the graphics layer using Vulkan 1.3.
// This uses SDL specific code
#ifdef ENGINE_BUILD_OPENGL
#include "gfx_device.hpp"
#include "util.hpp"
#include "config.h"
#include "log.hpp"
#include <glad/glad.h>
#include <SDL2/SDL.h>
#include <assert.h>
#include <unordered_set>
#include <array>
#include <fstream>
#include <filesystem>
#include <optional>
namespace engine {
// structures and enums
static std::vector<char> readFile(const std::string& filename)
{
std::ifstream file(filename, std::ios::ate | std::ios::binary);
if (file.is_open() == false) {
throw std::runtime_error("Unable to open file " + filename);
}
std::vector<char> buffer(file.tellg());
file.seekg(0);
file.read(buffer.data(), buffer.size());
file.close();
return buffer;
}
// class definitions
struct GFXDevice::Impl {
SDL_GLContext context = nullptr;
};
GFXDevice::GFXDevice(const char* appName, const char* appVersion, SDL_Window* window)
{
pimpl = std::make_unique<Impl>();
pimpl->context = SDL_GL_CreateContext(window);
}
GFXDevice::~GFXDevice()
{
TRACE("Destroying GFXDevice...");
}
void GFXDevice::draw()
{
}
void GFXDevice::createPipeline(const char* vertShaderPath, const char* fragShaderPath)
{
}
bool GFXDevice::createBuffer(const gfx::BufferDesc& desc, const void* data, gfx::BufferHandle* out)
{
return false;
}
void GFXDevice::waitIdle()
{
glFinish();
}
}
#endif

View File

@ -24,6 +24,7 @@
#include <array>
#include <fstream>
#include <filesystem>
#include <optional>
namespace engine {