Gazebo Msgs

API Reference

11.0.0~pre1
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#include <gz/msgs/config.hh>
21
22// Message Headers
23#include "gz/msgs/material.pb.h"
24
25// Data Headers
26#include <string>
27
28namespace gz::msgs {
29// Inline bracket to help doxygen filtering.
30inline namespace GZ_MSGS_VERSION_NAMESPACE {
31
33inline msgs::Material::ShaderType ConvertShaderType(const std::string &_str)
34{
35 auto result = msgs::Material::VERTEX;
36 if (_str == "vertex")
37 {
38 result = msgs::Material::VERTEX;
39 }
40 else if (_str == "pixel")
41 {
42 result = msgs::Material::PIXEL;
43 }
44 else if (_str == "normal_map_object_space")
45 {
46 result = msgs::Material::NORMAL_MAP_OBJECT_SPACE;
47 }
48 else if (_str == "normal_map_tangent_space")
49 {
50 result = msgs::Material::NORMAL_MAP_TANGENT_SPACE;
51 }
52 else
53 {
54 std::cerr << "Unrecognized Material::ShaderType ["
55 << _str
56 << "], returning msgs::Material::VERTEX"
57 << std::endl;
58 }
59 return result;
60}
61
63inline std::string ConvertShaderType(const msgs::Material::ShaderType &_type)
64{
65 std::string result;
66 switch (_type)
67 {
68 case msgs::Material::VERTEX:
69 {
70 result = "vertex";
71 break;
72 }
73 case msgs::Material::PIXEL:
74 {
75 result = "pixel";
76 break;
77 }
78 case msgs::Material::NORMAL_MAP_OBJECT_SPACE:
79 {
80 result = "normal_map_object_space";
81 break;
82 }
83 case msgs::Material::NORMAL_MAP_TANGENT_SPACE:
84 {
85 result = "normal_map_tangent_space";
86 break;
87 }
88 default:
89 {
90 result = "unknown";
91 std::cerr << "Unrecognized Material::ShaderType ["
92 << _type
93 << "], returning 'unknown'"
94 << std::endl;
95 break;
96 }
97 }
98 return result;
99}
100
101} // namespce
102} // namespace gz::msgs
103
104#endif // GZ_MSGS_CONVERT_SHADERTYPE_HH_