59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <webgpu/webgpu.hpp>
|
|
|
|
#define GLFW_INCLUDE_NONE
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <renderer/renderer.hpp>
|
|
|
|
namespace hibis::rwgpu {
|
|
class RWGPU : public Renderer {
|
|
public:
|
|
RWGPU(std::string title, IntVec2 size, LoggerCallback callback);
|
|
~RWGPU();
|
|
|
|
// Draw
|
|
void clearScreen(Color col = Color {0, 0, 0, 255}) override;
|
|
void renderCurrent() override;
|
|
|
|
void drawText(Resource* resource, std::string text, IntVec2 pos, Color color) override;
|
|
void drawTexture(Resource* resource, IntRect size) override;
|
|
|
|
void useShader(Shader* shader, Point2D points[3]) override;
|
|
void stopUsingShaders() override;
|
|
|
|
// Pre and Post draw
|
|
void preDraw() override;
|
|
void postDraw() override;
|
|
|
|
// Update
|
|
void update() override;
|
|
|
|
// Util
|
|
void compileShader(Shader* shader) override;
|
|
void toggleWireframe() override;
|
|
void setWindowTitle(std::string title) override;
|
|
void resize(unsigned int width, unsigned int height);
|
|
|
|
std::vector<WGPUFeatureName> mWebGPUFeatures;
|
|
private:
|
|
WGPUAdapter requestAdapter(WGPURequestAdapterOptions const * options);
|
|
WGPUDevice requestDevice(WGPUDeviceDescriptor const * descriptor);
|
|
|
|
void setupSwapChain(unsigned int width, unsigned int height);
|
|
|
|
GLFWwindow* mWindow;
|
|
wgpu::Instance mWebGPUInstance = nullptr;
|
|
wgpu::Adapter mWebGPUAdapter = nullptr;
|
|
wgpu::Device mWebGPUDevice = nullptr;
|
|
wgpu::Queue mWebGPUQueue = nullptr;
|
|
wgpu::SwapChain mWebGPUSwapChain = nullptr;
|
|
|
|
wgpu::Surface mWebGPUSurface = nullptr;
|
|
|
|
wgpu::Color mCurrentClearColor = {0.9, 0.1, 0.2, 1.0};
|
|
};
|
|
}
|