Kiwano Engine v1.3.x
Shader.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/core/UUID.h>
23#include <kiwano/render/Bitmap.h>
24
25namespace kiwano
26{
27
37class KGE_API Shader : public NativeObject
38{
39public:
43
44protected:
45 Shader() = default;
46};
47
52class KGE_API PixelShader : public Shader
53{
54public:
58 static RefPtr<PixelShader> Preload(const kiwano::UUID& uuid, StringView cso_path);
59
63 static RefPtr<PixelShader> Preload(const kiwano::UUID& uuid, BinaryData cso_data);
64
67 RefPtr<Image> Process(RefPtr<Image> input) override;
68
71 template <typename T>
72 void SetConstants(const T& value)
73 {
74 SetConstants(reinterpret_cast<const uint8_t*>(&value), sizeof(value));
75 }
76
79 void SetConstants(const uint8_t* data, uint32_t size);
80
83 void SetExpansion(PixelSize left_top, PixelSize right_bottom);
84
87 kiwano::UUID GetUUID() const;
88
89protected:
90 PixelShader(const kiwano::UUID& uuid);
91
92protected:
93 kiwano::UUID uuid_;
94};
95
99{
100 return uuid_;
101}
102
103} // namespace kiwano
含有本地指针的对象
Definition: NativeObject.hpp:32
像素着色器
Definition: Shader.h:53
void SetConstants(const T &value)
设置 Pixel Shader 常量区
Definition: Shader.h:72
kiwano::UUID GetUUID() const
获取唯一标识
Definition: Shader.h:98
引用计数智能指针
Definition: RefBasePtr.hpp:35
着色器
Definition: Shader.h:38
virtual RefPtr< Image > Process(RefPtr< Image > input)=0
处理图像
二进制数据
Definition: BinaryData.h:30
通用唯一标示符
Definition: UUID.h:30