VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
renderPassShaderQuad.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4//
6
7#include "quadRender.h"
10
11namespace visutwin::canvas
12{
13 void RenderPassShaderQuad::setShader(const std::shared_ptr<Shader>& shader)
14 {
15 // destroy old
16 _quadRender.reset();
17
18 // handle new
19 _shader = shader;
20 if (_shader) {
21 _quadRender = std::make_shared<QuadRender>(_shader);
22 }
23 }
24
26 {
27 const auto gd = device();
28 if (!gd) {
29 return;
30 }
31
32 // render state
33 gd->setBlendState(blendState);
34 gd->setCullMode(cullMode);
35 gd->setDepthState(depthState);
36 gd->setStencilState(stencilFront, stencilBack);
37 gd->clearQuadTextureBindings();
38 for (size_t i = 0; i < _quadTextureBindings.size(); ++i) {
39 gd->setQuadTextureBinding(i, _quadTextureBindings[i]);
40 }
41
42 const Vector4* viewportPtr = viewport ? &(*viewport) : nullptr;
43 const Vector4* scissorPtr = scissor ? &(*scissor) : nullptr;
44 if (_quadRender) {
45 _quadRender->render(viewportPtr, scissorPtr);
46 }
47 }
48}
std::shared_ptr< GraphicsDevice > device() const
Definition renderPass.h:124
std::shared_ptr< Shader > shader() const
void setShader(const std::shared_ptr< Shader > &shader)
std::shared_ptr< DepthState > depthState
std::shared_ptr< StencilParameters > stencilFront
std::shared_ptr< BlendState > blendState
std::shared_ptr< StencilParameters > stencilBack
4D vector for homogeneous coordinates, color values, and SIMD operations.
Definition vector4.h:20