engine/include/gfx_device.hpp

55 lines
1.7 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:
GFXDevice(const char* appName, const char* appVersion, SDL_Window* window, bool vsync);
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-27 22:06:56 +00:00
void getViewportSize(uint32_t *w, uint32_t *h);
2022-10-24 14:16:04 +00:00
// adds a draw call to the queue
2022-10-27 16:58:30 +00:00
// vertexBuffer is required, indexBuffer can be NULL, uniformData is required
2022-11-11 16:18:22 +00:00
void draw(const gfx::Pipeline* pipeline, const gfx::Buffer* vertexBuffer, const gfx::Buffer* indexBuffer, uint32_t count, const void* pushConstantData, size_t pushConstantSize, const gfx::Texture* texture);
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-11-27 14:35:41 +00:00
gfx::Pipeline* createPipeline(const char* vertShaderPath, const char* fragShaderPath, const gfx::VertexFormat& vertexFormat, uint64_t uniformBufferSize, bool alphaBlending, bool backfaceCulling);
2022-10-23 23:19:07 +00:00
void destroyPipeline(const gfx::Pipeline* pipeline);
2022-11-07 20:15:26 +00:00
void updateUniformBuffer(const gfx::Pipeline* pipeline, void* data, size_t size, uint32_t offset);
2022-10-31 16:21:07 +00:00
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
2022-11-15 13:59:43 +00:00
gfx::Texture* createTexture(const void* imageData, uint32_t w, uint32_t h, gfx::TextureFilter minFilter, gfx::TextureFilter magFilter);
void destroyTexture(const gfx::Texture* texture);
// 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
};
2022-10-27 16:58:30 +00:00
extern GFXDevice* gfxdev;
2022-09-13 18:25:18 +00:00
}