VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
shaderMaterial.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 10.02.2026.
5//
6#include "shaderMaterial.h"
7
9#include "spdlog/spdlog.h"
10
11namespace visutwin::canvas
12{
13 ShaderMaterial::ShaderMaterial(const std::shared_ptr<GraphicsDevice>& device, const std::string& uniqueName,
14 const std::string& vertexEntry, const std::string& fragmentEntry, const std::string& sourceCode)
15 {
16 setName(uniqueName);
17 setTransparent(false);
18
19 if (device) {
20 if (sourceCode.empty()) {
21 spdlog::warn("ShaderMaterial '{}' created without source code. Shader override was not created.", uniqueName);
22 return;
23 }
24 ShaderDefinition definition;
25 definition.name = uniqueName;
26 definition.vshader = vertexEntry;
27 definition.fshader = fragmentEntry;
28 setShaderOverride(createShader(device.get(), definition, sourceCode));
29 }
30 }
31}
void setShaderOverride(const std::shared_ptr< Shader > &shader)
Definition material.h:161
void setName(const std::string &name)
Definition material.h:152
void setTransparent(const bool value)
Definition material.h:155
ShaderMaterial(const std::shared_ptr< GraphicsDevice > &device, const std::string &uniqueName, const std::string &vertexEntry="vertexShader", const std::string &fragmentEntry="fragmentShader", const std::string &sourceCode="")
std::shared_ptr< Shader > createShader(GraphicsDevice *graphicsDevice, const ShaderDefinition &definition, const std::string &sourceCode)
Definition shader.cpp:39