mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Add stuff
This commit is contained in:
parent
92ff208c35
commit
ddefcc1967
@ -31,6 +31,8 @@ add_library(${PROJECT_NAME} STATIC
|
|||||||
"src/resource_manager.cpp"
|
"src/resource_manager.cpp"
|
||||||
|
|
||||||
"src/gfx_device_vulkan.cpp"
|
"src/gfx_device_vulkan.cpp"
|
||||||
|
"src/gfx_device_null.cpp"
|
||||||
|
"src/gfx_device_opengl45.cpp"
|
||||||
|
|
||||||
# PUBLIC API
|
# PUBLIC API
|
||||||
|
|
||||||
|
48
src/gfx_device_null.cpp
Normal file
48
src/gfx_device_null.cpp
Normal 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
|
82
src/gfx_device_opengl45.cpp
Normal file
82
src/gfx_device_opengl45.cpp
Normal 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
|
@ -24,6 +24,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace engine {
|
namespace engine {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user