engine/include/gfx_device.hpp

47 lines
1.3 KiB
C++
Raw Normal View History

2022-09-13 18:25:18 +00:00
#pragma once
#include "engine_api.h"
2022-10-22 12:15:25 +00:00
#include "gfx.hpp"
2022-09-17 00:22:35 +00:00
#include <memory>
2022-09-19 08:57:02 +00:00
struct SDL_Window;
2022-09-13 18:25:18 +00:00
2022-10-02 15:34:51 +00:00
namespace engine {
2022-09-13 18:25:18 +00:00
2022-10-02 12:56:13 +00:00
class ENGINE_API GFXDevice {
2022-09-13 18:25:18 +00:00
2022-10-02 12:56:13 +00:00
public:
2022-10-04 10:54:23 +00:00
GFXDevice(const char* appName, const char* appVersion, SDL_Window* window);
2022-09-19 17:33:56 +00:00
2022-09-21 19:52:26 +00:00
GFXDevice(const GFXDevice&) = delete;
GFXDevice& operator=(const GFXDevice&) = delete;
~GFXDevice();
2022-09-13 18:25:18 +00:00
2022-10-22 12:15:25 +00:00
// adds a vertex buffer draw call to the queue
2022-10-24 00:10:48 +00:00
void drawBuffer(const gfx::Pipeline* pipeline, const gfx::Buffer* vertexBuffer, uint32_t count);
void drawIndexed(const gfx::Pipeline* pipeline, const gfx::Buffer* vertexBuffer, const gfx::Buffer* indexBuffer, uint32_t indexCount);
2022-10-22 12:15:25 +00:00
// Call once per frame. Executes all queued draw calls and renders to the screen.
2022-10-24 00:10:48 +00:00
void renderFrame();
// creates the equivalent of an OpenGL shader program & vertex attrib configuration
2022-10-23 23:19:07 +00:00
gfx::Pipeline* createPipeline(const char* vertShaderPath, const char* fragShaderPath, const gfx::VertexFormat& vertexFormat);
void destroyPipeline(const gfx::Pipeline* pipeline);
2022-10-24 00:10:48 +00:00
gfx::Buffer* createBuffer(gfx::BufferType type, uint64_t size, const void* data);
void destroyBuffer(const gfx::Buffer* buffer);
2022-10-07 14:18:09 +00:00
// wait until all the active GPU queues have finished working
void waitIdle();
2022-09-13 18:25:18 +00:00
private:
struct Impl;
std::unique_ptr<Impl> pimpl;
2022-09-13 18:25:18 +00:00
};
}