载入中...
搜索中...
未找到
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:
19 OffscreenCanvas(Graphics *gfx, int width, int height, bool hdr = false);
21 ~OffscreenCanvas() override;
22
24 int getWidth() const override { return width; }
26 int getHeight() const override { return height; }
28 Texture *getTexture() override { return &colorTex; }
30 bool isHDR() const { return hdr; }
31
33 void clear(std::optional<Color> color, std::optional<int> stencil,
34 std::optional<double> depth) override;
36 Color getPixel(int x, int y) override;
42
44 void draw(Canvas *, const glm::mat4 &) const override {}
46 void draw(eve::graphics::Graphics *, const glm::mat4 &) const override {}
47
48 bool clearRequested = false;
49 Color clearColor{0.f, 0.f, 0.f, 1.f};
50
51 friend class Graphics;
52
53private:
54 Graphics *gfx;
55 int width = 0;
56 int height = 0;
57 wgpu::Texture color;
58 wgpu::TextureView colorView;
59 wgpu::Texture depth;
60 wgpu::TextureView depthView;
61 GpuTexture colorGpu;
62 Texture colorTex;
63 bool hdr = false;
64};
65
66} // namespace eve::graphics::webgpu
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
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:18
EVENGINE_API_BACKENDS public API.
Definition Graphics.h:191
Offscreen render target (RGBA8Unorm color, optional Depth32Float). 2D batches are flushed into the ca...
Definition Canvas.h:16
int getWidth() const override
Returns the width.
Definition Canvas.h:24
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:26
Texture * getTexture() override
Returns the texture.
Definition Canvas.h:28
void draw(eve::graphics::Graphics *, const glm::mat4 &) const override
Draws .
Definition Canvas.h:46
~OffscreenCanvas() override
Releases OffscreenCanvas resources.
bool isHDR() const
True when hdr.
Definition Canvas.h:30
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:44
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:131
glm::vec4 color