Files
Seele/src/Engine/Graphics/RenderPass/UIPass.h
T

70 lines
2.5 KiB
C++
Raw Normal View History

2021-09-23 10:10:39 +02:00
#pragma once
2024-06-09 12:20:04 +02:00
#include "Graphics/Shader.h"
2021-09-23 10:10:39 +02:00
#include "RenderPass.h"
2025-01-08 19:15:12 +01:00
#include "UI/System.h"
2024-06-09 12:20:04 +02:00
namespace Seele {
2021-09-23 10:10:39 +02:00
DECLARE_NAME_REF(Gfx, Texture2D)
DECLARE_NAME_REF(Gfx, RenderTargetAttachment)
2024-06-09 12:20:04 +02:00
class UIPass : public RenderPass {
public:
2025-01-08 19:15:12 +01:00
UIPass(Gfx::PGraphics graphics, UI::PSystem system);
2023-11-05 10:36:01 +01:00
UIPass(UIPass&&) = default;
UIPass& operator=(UIPass&&) = default;
2021-09-23 10:10:39 +02:00
virtual ~UIPass();
2025-04-11 23:13:19 +02:00
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
2022-04-15 23:45:44 +02:00
virtual void render() override;
virtual void endFrame() override;
2021-09-23 10:10:39 +02:00
virtual void publishOutputs() override;
virtual void createRenderPass() override;
2024-06-09 12:20:04 +02:00
2026-10-13 21:49:28 +02:00
// input: the owning view forwards its window callbacks here (window-relative coords)
void mouseMove(Vector2 position) { system->mouseMove(position); }
void mouseButton(MouseButton button, InputAction action, KeyModifierFlags modifier, Vector2 position) {
system->mouseButton(button, action, (KeyModifier)modifier, position);
}
void scroll(Vector2 delta) { system->scroll(delta); }
void key(KeyCode code, InputAction action, KeyModifierFlags modifier, char text = 0) { system->key(code, action, (KeyModifier)modifier, text); }
2024-06-09 12:20:04 +02:00
private:
2025-01-12 11:26:52 +01:00
struct RenderElementStyle {
float x;
float y;
float w;
float h;
Vector color;
float opacity = 1;
float z = 0;
2025-03-20 20:15:38 +01:00
uint32 textureIndex = std::numeric_limits<uint32>::max();
2026-10-21 21:21:49 +02:00
// UV rect for textured quads (glyphs: their rect in the font atlas); unused for untextured quads
Vector2 uvOffset = Vector2(0);
Vector2 uvSize = Vector2(1);
Vector2 pad;
2025-01-08 19:15:12 +01:00
};
Gfx::RenderTargetAttachment colorAttachment;
2024-02-01 10:21:36 +01:00
Gfx::RenderTargetAttachment depthAttachment;
2023-11-01 23:12:30 +01:00
Gfx::OTexture2D depthBuffer;
2021-09-23 10:10:39 +02:00
2025-01-08 19:15:12 +01:00
Gfx::ODescriptorLayout uiDescriptorLayout;
2025-08-10 19:16:55 +02:00
Gfx::ODescriptorSet uiDescriptorSet;
2023-10-26 18:37:29 +02:00
2025-08-10 19:16:55 +02:00
Gfx::ODescriptorSet viewParamsSet;
2025-05-06 19:36:43 +02:00
2025-01-08 19:15:12 +01:00
Gfx::OVertexShader uiVertexShader;
Gfx::OFragmentShader uiFragmentShader;
Gfx::OPipelineLayout uiPipelineLayout;
Gfx::PGraphicsPipeline uiPipeline;
2025-01-12 11:26:52 +01:00
UI::PSystem system;
Array<UI::UIRender> renderElements;
Array<RenderElementStyle> elements;
Gfx::OShaderBuffer elementBuffer;
2025-03-07 21:48:27 +01:00
constexpr static const char* ELEMENT_NAME = "elements";
2026-10-20 22:01:51 +02:00
Gfx::OSampler uiSampler;
2025-03-07 21:48:27 +01:00
constexpr static const char* GLYPHSAMPLER_NAME = "glyphSampler";
2024-06-20 21:57:26 +02:00
Array<Gfx::PTexture2D> usedTextures;
2025-03-07 21:48:27 +01:00
constexpr static const char* TEXTURES_NAME = "textures";
2021-09-23 10:10:39 +02:00
};
DEFINE_REF(UIPass);
} // namespace Seele