1 // Copyright 2018 The Amber Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "src/command_data.h"
16
17 namespace amber {
18
NameToTopology(const std::string & name)19 Topology NameToTopology(const std::string& name) {
20 static const struct {
21 const char* name;
22 Topology val;
23 } topologies[] = {
24 {"PATCH_LIST", Topology::kPatchList},
25 {"POINT_LIST", Topology::kPointList},
26 {"GL_LINE_STRIP_ADJACENCY", Topology::kLineStripWithAdjacency},
27 {"GL_LINE_STRIP", Topology::kLineStrip},
28 {"GL_LINES", Topology::kLineList},
29 {"GL_LINES_ADJACENCY", Topology::kLineListWithAdjacency},
30 {"GL_PATCHES", Topology::kPatchList},
31 {"GL_POINTS", Topology::kPointList},
32 {"GL_TRIANGLE_STRIP", Topology::kTriangleStrip},
33 {"GL_TRIANGLE_FAN", Topology::kTriangleFan},
34 {"GL_TRIANGLES", Topology::kTriangleList},
35 {"GL_TRIANGLES_ADJACENCY", Topology::kTriangleListWithAdjacency},
36 {"GL_TRIANGLE_STRIP_ADJACENCY", Topology::kTriangleStripWithAdjacency},
37 {"LINE_LIST", Topology::kLineList},
38 {"LINE_LIST_WITH_ADJACENCY", Topology::kLineListWithAdjacency},
39 {"LINE_STRIP", Topology::kLineStrip},
40 {"LINE_STRIP_WITH_ADJACENCY", Topology::kLineStripWithAdjacency},
41 {"TRIANGLE_FAN", Topology::kTriangleFan},
42 {"TRIANGLE_LIST", Topology::kTriangleList},
43 {"TRIANGLE_LIST_WITH_ADJACENCY", Topology::kTriangleListWithAdjacency},
44 {"TRIANGLE_STRIP", Topology::kTriangleStrip},
45 {"TRIANGLE_STRIP_WITH_ADJACENCY", Topology::kTriangleStripWithAdjacency},
46 };
47
48 // TODO(dsinclair): Make smarter if needed
49 for (auto& topo : topologies) {
50 if (topo.name == name)
51 return topo.val;
52 }
53
54 return Topology::kUnknown;
55 }
56
57 } // namespace amber
58