载入中...
搜索中...
未找到
Canvas.h
浏览该文件的文档.
1#pragma once
2#include "graphics/Canvas.h"
3#include "graphics/Texture.h"
5
6#include <optional>
7
8// Incomplete glm::mat4 is enough for const-reference parameters.
9#include <glm/fwd.hpp>
10
11namespace eve::graphics::webgpu {
12
18public:
20 OffscreenCanvas(Graphics *gfx, int width, int height, bool hdr = false);
22 ~OffscreenCanvas() override;
23
25 int getWidth() const override { return width; }
27 int getHeight() const override { return height; }
29 Texture *getTexture() override { return &colorTex; }
31 bool isHDR() const { return hdr; }
32
34 void clear(std::optional<Color> color, std::optional<int> stencil,
35 std::optional<double> depth) override;
37 Color getPixel(int x, int y) override;
43
45 void draw(Canvas*, const glm::mat4&) const override {}
47 void draw(eve::graphics::Graphics*, const glm::mat4&) const override {}
48
49 bool clearRequested = false;
50 Color clearColor{0.f, 0.f, 0.f, 1.f};
51
52 friend class Graphics;
53
54private:
55 Graphics *gfx;
56 int width = 0;
57 int height = 0;
58 wgpu::Texture color;
59 wgpu::TextureView colorView;
60 wgpu::Texture depth;
61 wgpu::TextureView depthView;
62 GpuTexture colorGpu;
63 Texture colorTex;
64 bool hdr = false;
65};
66
67} // namespace eve::graphics::webgpu
double y
double x
std::uint32_t height
std::uint32_t width
std::uint32_t depth
Canvas public API.
Definition Canvas.h:17
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
EVENGINE_API_BACKENDS public API.
Definition Graphics.h:199
Offscreen render target (RGBA8Unorm color, optional Depth32Float). 2D batches are flushed into the ca...
Definition Canvas.h:17
int getWidth() const override
Returns the width.
Definition Canvas.h:25
image::ImageData * newImageData() override
Creates a image data. @ownership Caller deletes unless documented otherwise.
Definition Canvas.cpp:76
image::ImageData * newHDRImageData() override
Creates a hdr image data. @ownership Caller deletes unless documented otherwise.
Definition Canvas.cpp:81
int getHeight() const override
Returns the height.
Definition Canvas.h:27
Texture * getTexture() override
Returns the texture.
Definition Canvas.h:29
void draw(eve::graphics::Graphics *, const glm::mat4 &) const override
Draws .
Definition Canvas.h:47
~OffscreenCanvas() override
Releases OffscreenCanvas resources.
bool isHDR() const
True when hdr.
Definition Canvas.h:31
Color getPixel(int x, int y) override
Returns the pixel.
Definition Canvas.cpp:71
void clear(std::optional< Color > color, std::optional< int > stencil, std::optional< double > depth) override
Clears .
Definition Canvas.cpp:65
void draw(Canvas *, const glm::mat4 &) const override
Draws .
Definition Canvas.h:45
Represents raw pixel data.
Definition ImageData.h:38
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
Texture resources backed by a wgpu texture + view + sampler + bind groups.
Definition Graphics.h:137
glm::vec4 color