2023-06-26 18:46:11 +00:00
|
|
|
#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;
|
2023-06-28 20:43:01 +00:00
|
|
|
void drawTexture(Resource* resource, IntRect size) override;
|
2023-06-26 18:46:11 +00:00
|
|
|
|
|
|
|
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;
|
2023-06-28 20:43:01 +00:00
|
|
|
void resize(unsigned int width, unsigned int height);
|
2023-06-26 18:46:11 +00:00
|
|
|
|
|
|
|
std::vector<WGPUFeatureName> mWebGPUFeatures;
|
|
|
|
private:
|
|
|
|
WGPUAdapter requestAdapter(WGPURequestAdapterOptions const * options);
|
|
|
|
WGPUDevice requestDevice(WGPUDeviceDescriptor const * descriptor);
|
|
|
|
|
2023-06-28 20:43:01 +00:00
|
|
|
void setupSwapChain(unsigned int width, unsigned int height);
|
|
|
|
|
2023-06-26 18:46:11 +00:00
|
|
|
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};
|
|
|
|
};
|
|
|
|
}
|