47 lines
1 KiB
C++
47 lines
1 KiB
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include <GLFW/glfw3.h>
|
|
#if defined(__EMSCRIPTEN__)
|
|
#include <emscripten/emscripten.h>
|
|
#endif
|
|
#include <dawn/webgpu_cpp_print.h>
|
|
#include <webgpu/webgpu_cpp.h>
|
|
#include <webgpu/webgpu_glfw.h>
|
|
|
|
namespace wne {
|
|
// TODO: load me in a better way
|
|
const char shaderCode[] = R"(
|
|
@vertex fn vertexMain(@builtin(vertex_index) i : u32) ->
|
|
@builtin(position) vec4f {
|
|
const pos = array(vec2f(0, 1), vec2f(-1, -1), vec2f(1, -1));
|
|
return vec4f(pos[i], 0, 1);
|
|
}
|
|
@fragment fn fragmentMain() -> @location(0) vec4f {
|
|
return vec4f(1, 0, 0, 1);
|
|
}
|
|
)";
|
|
|
|
class window {
|
|
wgpu::Instance instance;
|
|
wgpu::Adapter adapter;
|
|
wgpu::Device device;
|
|
wgpu::RenderPipeline pipeline;
|
|
|
|
wgpu::Surface surface;
|
|
wgpu::TextureFormat format;
|
|
const uint32_t kWidth = 512;
|
|
const uint32_t kHeight = 512;
|
|
|
|
void ConfigureSurface();
|
|
void CreateRenderPipeline();
|
|
void Render();
|
|
void InitGraphics();
|
|
|
|
public:
|
|
//TODO: make init the constructor
|
|
window();
|
|
void Start();
|
|
};
|
|
} // namespace wne
|