Gazebo Msgs

API Reference

10.1.1
ShaderType.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef GZ_MSGS_CONVERT_SHADERTYPE_HH_
18#define GZ_MSGS_CONVERT_SHADERTYPE_HH_
19
20// Message Headers
21#include "gz/msgs/material.pb.h"
22
23// Data Headers
24#include <string>
25
26namespace gz::msgs {
27// Inline bracket to help doxygen filtering.
28inline namespace GZ_MSGS_VERSION_NAMESPACE {
29
31inline msgs::Material::ShaderType ConvertShaderType(const std::string &_str)
32{
33 auto result = msgs::Material::VERTEX;
34 if (_str == "vertex")
35 {
36 result = msgs::Material::VERTEX;
37 }
38 else if (_str == "pixel")
39 {
40 result = msgs::Material::PIXEL;
41 }
42 else if (_str == "normal_map_object_space")
43 {
44 result = msgs::Material::NORMAL_MAP_OBJECT_SPACE;
45 }
46 else if (_str == "normal_map_tangent_space")
47 {
48 result = msgs::Material::NORMAL_MAP_TANGENT_SPACE;
49 }
50 else
51 {
52 std::cerr << "Unrecognized Material::ShaderType ["
53 << _str
54 << "], returning msgs::Material::VERTEX"
55 << std::endl;
56 }
57 return result;
58}
59
61inline std::string ConvertShaderType(const msgs::Material::ShaderType &_type)
62{
63 std::string result;
64 switch (_type)
65 {
66 case msgs::Material::VERTEX:
67 {
68 result = "vertex";
69 break;
70 }
71 case msgs::Material::PIXEL:
72 {
73 result = "pixel";
74 break;
75 }
76 case msgs::Material::NORMAL_MAP_OBJECT_SPACE:
77 {
78 result = "normal_map_object_space";
79 break;
80 }
81 case msgs::Material::NORMAL_MAP_TANGENT_SPACE:
82 {
83 result = "normal_map_tangent_space";
84 break;
85 }
86 default:
87 {
88 result = "unknown";
89 std::cerr << "Unrecognized Material::ShaderType ["
90 << _type
91 << "], returning 'unknown'"
92 << std::endl;
93 break;
94 }
95 }
96 return result;
97}
98
99} // namespce
100} // namespace gz::msgs
101
102#endif // GZ_MSGS_CONVERT_SHADERTYPE_HH_