载入中...
搜索中...
未找到
Canvas.h
浏览该文件的文档.
1#pragma once
2#include "graphics/Canvas.h"
3#include "graphics/Texture.h"
5
6#include <optional>
7
8#include <glm/glm.hpp>
9
10namespace eve::graphics::webgpu {
11
17public:
18 OffscreenCanvas(Graphics *gfx, int width, int height);
19 ~OffscreenCanvas() override;
20
21 int getWidth() const override { return width; }
22 int getHeight() const override { return height; }
23 Texture *getTexture() override { return &colorTex; }
24
25 void clear(std::optional<Color> color, std::optional<int> stencil,
26 std::optional<double> depth) override;
27 Color getPixel(int x, int y) override;
29
30 void draw(Canvas *, const glm::mat4 &) const override {}
31 void draw(eve::graphics::Graphics *, const glm::mat4 &) const override {}
32
33 bool clearRequested = false;
34 Color clearColor{0.f, 0.f, 0.f, 1.f};
35
36 friend class Graphics;
37
38private:
39 Graphics *gfx;
40 int width = 0;
41 int height = 0;
42 wgpu::Texture color;
43 wgpu::TextureView colorView;
44 wgpu::Texture depth;
45 wgpu::TextureView depthView;
46 GpuTexture colorGpu;
47 Texture colorTex;
48};
49
50} // namespace eve::graphics::webgpu
int y
Definition Grass.cpp:135
float height
Definition Grass.cpp:235
int x
Definition Grass.cpp:135
float depth
int width
image::ImageData::Colorf color
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:17
Offscreen render target (RGBA8Unorm color, optional Depth32Float). 2D batches are flushed into the ca...
Definition Canvas.h:16
int getWidth() const override
Definition Canvas.h:21
image::ImageData * newImageData() override
Definition Canvas.cpp:79
int getHeight() const override
Definition Canvas.h:22
Texture * getTexture() override
Sampleable color buffer; screen Canvas returns nullptr.
Definition Canvas.h:23
void draw(eve::graphics::Graphics *, const glm::mat4 &) const override
Draws the object with the specified transformation matrix.
Definition Canvas.h:31
Color getPixel(int x, int y) override
Definition Canvas.cpp:75
void clear(std::optional< Color > color, std::optional< int > stencil, std::optional< double > depth) override
Definition Canvas.cpp:69
void draw(Canvas *, const glm::mat4 &) const override
Definition Canvas.h:30
Represents raw pixel data.
Definition ImageData.h:26
glm::vec4 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:51