45 lines
1 KiB
C++
45 lines
1 KiB
C++
#pragma once
|
|
|
|
#include <webgpu/webgpu.h>
|
|
|
|
#include <Shared.h>
|
|
#include "../Platform/Window.h"
|
|
|
|
namespace Artifact {
|
|
|
|
class Graphics;
|
|
|
|
class GraphicsSubsystem {
|
|
public:
|
|
Graphics * graphics;
|
|
virtual void init() {}
|
|
virtual void reload() {}
|
|
virtual void deinit() {}
|
|
virtual void render(WGPUTextureView nextTexture, WGPUCommandEncoder encoder) {}
|
|
};
|
|
|
|
class Graphics: public BaseSubsystem, public Engine<GraphicsSubsystem> {
|
|
public:
|
|
WGPUInstance instance = nullptr;
|
|
WGPUSurface surface = nullptr;
|
|
WGPUAdapter adapter = nullptr;
|
|
WGPUDevice device = nullptr;
|
|
|
|
WGPUTexture depthTexture = nullptr;
|
|
WGPUTextureView depthTextureView = nullptr;
|
|
WGPUQueue queue = nullptr;
|
|
|
|
Window * window;
|
|
|
|
void init() override;
|
|
void deinit() override;
|
|
void render() override;
|
|
void onSubsystemAdd(GraphicsSubsystem * system) {
|
|
system->graphics = this;
|
|
}
|
|
|
|
WGPUTexture createTextureFromData(const void* data, uint32_t width, uint32_t height);
|
|
WGPUTexture createTextureFromFile(const char* file);
|
|
};
|
|
|
|
}
|