]> git.jsancho.org Git - c-irrlicht.git/blob - include/SMaterial.h
Use structs with casting, without classes replication
[c-irrlicht.git] / include / SMaterial.h
1 /* c-irrlicht --- C bindings for Irrlicht Engine
2
3    Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
4
5    This file is part of c-irrlicht.
6
7    c-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    c-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 #ifndef __C_IRR_S_MATERIAL_H_INCLUDED__
23 #define __C_IRR_S_MATERIAL_H_INCLUDED__
24
25 #include <inttypes.h>
26 #include <math.h>
27 #include <stdbool.h>
28
29 #include "EMaterialTypes.h"
30 #include "irrMath.h"
31 #include "SColor.h"
32 #include "SMaterialLayer.h"
33
34 #define MATERIAL_MAX_TEXTURES _IRR_MATERIAL_MAX_TEXTURES_
35
36 typedef enum
37   {
38    irr_video_EBO_NONE = 0,
39    irr_video_EBO_ADD,
40    irr_video_EBO_SUBTRACT,
41    irr_video_EBO_REVSUBTRACT,
42    irr_video_EBO_MIN,
43    irr_video_EBO_MAX,
44    irr_video_EBO_MIN_FACTOR,
45    irr_video_EBO_MAX_FACTOR,
46    irr_video_EBO_MIN_ALPHA,
47    irr_video_EBO_MAX_ALPHA
48   } irr_video_E_BLEND_OPERATION;
49
50 typedef enum
51   {
52    irr_video_ECFN_NEVER = 0,
53    irr_video_ECFN_LESSEQUAL = 1,
54    irr_video_ECFN_EQUAL = 2,
55    irr_video_ECFN_LESS,
56    irr_video_ECFN_NOTEQUAL,
57    irr_video_ECFN_GREATEREQUAL,
58    irr_video_ECFN_GREATER,
59    irr_video_ECFN_ALWAYS
60   } irr_video_E_COMPARISON_FUNC;
61
62 typedef enum
63   {
64    irr_video_ECP_NONE = 0,
65    irr_video_ECP_ALPHA = 1,
66    irr_video_ECP_RED = 2,
67    irr_video_ECP_GREEN = 4,
68    irr_video_ECP_BLUE = 8,
69    irr_video_ECP_RGB = 14,
70    irr_video_ECP_ALL = 15
71   } irr_video_E_COLOR_PLANE;
72
73 typedef enum
74   {
75    irr_video_EAAM_OFF = 0,
76    irr_video_EAAM_SIMPLE = 1,
77    irr_video_EAAM_QUALITY = 3,
78    irr_video_EAAM_LINE_SMOOTH = 4,
79    irr_video_EAAM_POINT_SMOOTH = 8,
80    irr_video_EAAM_FULL_BASIC = 15,
81    irr_video_EAAM_ALPHA_TO_COVERAGE = 16
82   } irr_video_E_ANTI_ALIASING_MODE;
83
84 typedef enum
85   {
86    irr_video_ECM_NONE = 0,
87    irr_video_ECM_DIFFUSE,
88    irr_video_ECM_AMBIENT,
89    irr_video_ECM_EMISSIVE,
90    irr_video_ECM_SPECULAR,
91    irr_video_ECM_DIFFUSE_AND_AMBIENT
92   } irr_video_E_COLOR_MATERIAL;
93
94 typedef enum
95   {
96    irr_video_EPO_BACK = 0,
97    irr_video_EPO_FRONT = 1
98   } irr_video_E_POLYGON_OFFSET;
99
100 typedef struct
101 {
102   irr_video_SMaterialLayer textureLayer[MATERIAL_MAX_TEXTURES];
103   irr_video_E_MATERIAL_TYPE materialType;
104   irr_video_SColor ambientColor;
105   irr_video_SColor diffuseColor;
106   irr_video_SColor emissiveColor;
107   irr_video_SColor specularColor;
108   float_t shininess;
109   float_t materialTypeParam;
110   float_t materialTypeParam2;
111   float_t thickness;
112   uint8_t zBuffer;
113   uint8_t antiAliasing;
114   uint8_t colorMask:4;
115   uint8_t colorMaterial:3;
116   irr_video_E_BLEND_OPERATION blendOperation:4;
117   uint8_t polygonOffsetFactor:3;
118   irr_video_E_POLYGON_OFFSET polygonOffsetDirection:1;
119   bool wireframe:1;
120   bool pointCloud:1;
121   bool gouraudShading:1;
122   bool lighting:1;
123   bool zWriteEnable:1;
124   bool backfaceCulling:1;
125   bool frontfaceCulling:1;
126   bool fogEnable:1;
127   bool normalizeNormals:1;
128   bool useMipMaps:1;
129 } irr_video_SMaterial;
130
131 #define S_MATERIAL_DEFAULT                            \
132 {                                                     \
133   .materialType = irr_video_EMT_SOLID,                \
134   .ambientColor = {255, 255, 255, 255},               \
135   .diffuseColor = {255, 255, 255, 255},               \
136   .emissiveColor = {0, 0, 0, 0},                      \
137   .specularColor = {255, 255, 255, 255},              \
138   .shininess = 0,                                     \
139   .materialTypeParam = 0,                             \
140   .materialTypeParam2 = 0,                            \
141   .thickness = 1,                                     \
142   .zBuffer = irr_video_ECFN_LESSEQUAL,                \
143   .antiAliasing = irr_video_EAAM_SIMPLE,              \
144   .colorMask = irr_video_ECP_ALL,                     \
145   .colorMaterial = irr_video_ECM_DIFFUSE,             \
146   .blendOperation = irr_video_EBO_NONE,               \
147   .polygonOffsetFactor = 0,                           \
148   .polygonOffsetDirection = irr_video_EPO_FRONT,      \
149   .wireframe = false,                                 \
150   .pointCloud = false,                                \
151   .gouraudShading = true,                             \
152   .lighting = true,                                   \
153   .zWriteEnable = true,                               \
154   .backfaceCulling = true,                            \
155   .frontfaceCulling = false,                          \
156   .fogEnable = false,                                 \
157   .normalizeNormals = false,                          \
158   .useMipMaps = true                                  \
159 }
160
161 #endif