]> git.jsancho.org Git - guile-irrlicht.git/blob - src/material-types.cpp
Some doc
[guile-irrlicht.git] / src / material-types.cpp
1 /* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
2
3    Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
4
5    This file is part of guile-irrlicht.
6
7    guile-irrlicht is free software; you can redistribute it and/or modify
8    it under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 3 of the
10    License, or (at your option) any later version.
11
12    guile-irrlicht is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with guile-irrlicht. If not, see
19    <http://www.gnu.org/licenses/>.
20 */
21
22 #include <irrlicht/irrlicht.h>
23 #include <libguile.h>
24 #include "material-types.h"
25
26 using namespace irr;
27
28 video::E_MATERIAL_TYPE
29 scm_to_material_type (SCM material_type)
30 {
31   char* type_name = scm_to_utf8_string (scm_symbol_to_string (material_type));
32   video::E_MATERIAL_TYPE type;
33
34   if (!strcmp (type_name, "solid"))
35     {
36       type = video::EMT_SOLID;
37     }
38   else if (!strcmp (type_name, "solid-2-layer"))
39     {
40       type = video::EMT_SOLID_2_LAYER;
41     }
42   else if (!strcmp (type_name, "lightmap"))
43     {
44       type = video::EMT_LIGHTMAP;
45     }
46   else if (!strcmp (type_name, "lightmap-add"))
47     {
48       type = video::EMT_LIGHTMAP_ADD;
49     }
50   else if (!strcmp (type_name, "lightmap-m2"))
51     {
52       type = video::EMT_LIGHTMAP_M2;
53     }
54   else if (!strcmp (type_name, "lightmap-m4"))
55     {
56       type = video::EMT_LIGHTMAP_M4;
57     }
58   else if (!strcmp (type_name, "lightmap-lighting"))
59     {
60       type = video::EMT_LIGHTMAP_LIGHTING;
61     }
62   else if (!strcmp (type_name, "lightmap-lighting-m2"))
63     {
64       type = video::EMT_LIGHTMAP_LIGHTING_M2;
65     }
66   else if (!strcmp (type_name, "lightmap-lighting-m4"))
67     {
68       type = video::EMT_LIGHTMAP_LIGHTING_M4;
69     }
70   else if (!strcmp (type_name, "detail-map"))
71     {
72       type = video::EMT_DETAIL_MAP;
73     }
74   else if (!strcmp (type_name, "sphere-map"))
75     {
76       type = video::EMT_SPHERE_MAP;
77     }
78   else if (!strcmp (type_name, "reflection-2-layer"))
79     {
80       type = video::EMT_REFLECTION_2_LAYER;
81     }
82   else if (!strcmp (type_name, "transparent-add-color"))
83     {
84       type = video::EMT_TRANSPARENT_ADD_COLOR;
85     }
86   else if (!strcmp (type_name, "transparent-alpha-channel"))
87     {
88       type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
89     }
90   else if (!strcmp (type_name, "transparent-alpha-channel-ref"))
91     {
92       type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
93     }
94   else if (!strcmp (type_name, "transparent-vertex-alpha"))
95     {
96       type = video::EMT_TRANSPARENT_VERTEX_ALPHA;
97     }
98   else if (!strcmp (type_name, "transparent-reflection-2-layer"))
99     {
100       type = video::EMT_TRANSPARENT_REFLECTION_2_LAYER;
101     }
102   else if (!strcmp (type_name, "normal-map-solid"))
103     {
104       type = video::EMT_NORMAL_MAP_SOLID;
105     }
106   else if (!strcmp (type_name, "normal-map-transparent-add-color"))
107     {
108       type = video::EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR;
109     }
110   else if (!strcmp (type_name, "normal-map-transparent-vertex-alpha"))
111     {
112       type = video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA;
113     }
114   else if (!strcmp (type_name, "parallax-map-solid"))
115     {
116       type = video::EMT_PARALLAX_MAP_SOLID;
117     }
118   else if (!strcmp (type_name, "parallax-map-transparent-add-color"))
119     {
120       type = video::EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR;
121     }
122   else if (!strcmp (type_name, "parallax-map-transparent-vertex-alpha"))
123     {
124       type = video::EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA;
125     }
126   else if (!strcmp (type_name, "onetexture-blend"))
127     {
128       type = video::EMT_ONETEXTURE_BLEND;
129     }
130   else
131     {
132       scm_error (scm_arg_type_key, NULL, "Wrong material type: ~S",
133                  scm_list_1 (material_type), scm_list_1 (material_type));
134     }
135
136   free (type_name);
137   return type;
138 }