]> git.jsancho.org Git - guile-irrlicht.git/blob - src/material-flags.cpp
set-material-flag!
[guile-irrlicht.git] / src / material-flags.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-flags.h"
25 #include "scene-node.h"
26
27 extern "C" {
28
29   void
30   init_material_flag (void)
31   {
32     scm_c_define_gsubr ("set-material-flag!", 3, 0, 0, (scm_t_subr)irr_scene_setMaterialFlag);
33   }
34
35   SCM
36   irr_scene_setMaterialFlag (SCM wrapped_obj,
37                              SCM flag,
38                              SCM newvalue)
39   {
40     if (scene_node_p (wrapped_obj))
41       {
42         unwrap_scene_node (wrapped_obj)->setMaterialFlag (scm_to_material_flag (flag),
43                                                           scm_to_bool (newvalue));
44       }
45     else
46       {
47         scm_error (scm_arg_type_key, NULL, "Cannot set material flag for object: ~S",
48                    scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
49       }
50     return SCM_UNSPECIFIED;
51   }
52
53   irr::video::E_MATERIAL_FLAG
54   scm_to_material_flag (SCM material_flag)
55   {
56     char* flag = scm_to_utf8_stringn (scm_symbol_to_string (material_flag), NULL);
57     if (!strcmp (flag, "wireframe"))
58       {
59         return irr::video::EMF_WIREFRAME;
60       }
61     else if (!strcmp (flag, "pointcloud"))
62       {
63         return irr::video::EMF_POINTCLOUD;
64       }
65     else if (!strcmp (flag, "gouraud-shading"))
66       {
67         return irr::video::EMF_GOURAUD_SHADING;
68       }
69     else if (!strcmp (flag, "lighting"))
70       {
71         return irr::video::EMF_LIGHTING;
72       }
73     else if (!strcmp (flag, "zbuffer"))
74       {
75         return irr::video::EMF_ZBUFFER;
76       }
77     else if (!strcmp (flag, "zwrite-enable"))
78       {
79         return irr::video::EMF_ZWRITE_ENABLE;
80       }
81     else if (!strcmp (flag, "back-face-culling"))
82       {
83         return irr::video::EMF_BACK_FACE_CULLING;
84       }
85     else if (!strcmp (flag, "front-face-culling"))
86       {
87         return irr::video::EMF_FRONT_FACE_CULLING;
88       }
89     else if (!strcmp (flag, "bilinear-filter"))
90       {
91         return irr::video::EMF_BILINEAR_FILTER;
92       }
93     else if (!strcmp (flag, "trilinear-filter"))
94       {
95         return irr::video::EMF_TRILINEAR_FILTER;
96       }
97     else if (!strcmp (flag, "anisotropic-filter"))
98       {
99         return irr::video::EMF_ANISOTROPIC_FILTER;
100       }
101     else if (!strcmp (flag, "fog-enable"))
102       {
103         return irr::video::EMF_FOG_ENABLE;
104       }
105     else if (!strcmp (flag, "normalize-normals"))
106       {
107         return irr::video::EMF_NORMALIZE_NORMALS;
108       }
109     else if (!strcmp (flag, "texture-wrap"))
110       {
111         return irr::video::EMF_TEXTURE_WRAP;
112       }
113     else if (!strcmp (flag, "anti-aliasing"))
114       {
115         return irr::video::EMF_ANTI_ALIASING;
116       }
117     else if (!strcmp (flag, "color-mask"))
118       {
119         return irr::video::EMF_COLOR_MASK;
120       }
121     else if (!strcmp (flag, "color-material"))
122       {
123         return irr::video::EMF_COLOR_MATERIAL;
124       }
125     else if (!strcmp (flag, "use-mip-maps"))
126       {
127         return irr::video::EMF_USE_MIP_MAPS;
128       }
129     else if (!strcmp (flag, "blend-operation"))
130       {
131         return irr::video::EMF_BLEND_OPERATION;
132       }
133     else if (!strcmp (flag, "polygon-offset"))
134       {
135         return irr::video::EMF_POLYGON_OFFSET;
136       }
137     else
138       {
139         scm_error (scm_arg_type_key, NULL, "Wrong material flag: ~S",
140                    scm_list_1 (material_flag), scm_list_1 (material_flag));
141       }
142   }
143
144 }