1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
use na::*;
use color::{Rgba,ToRgba};
use glin;

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex2D{
    pub position: Vec2,
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex2D{
    pub position: Vec2,
}

pub fn vertex2d(position: Vec2) -> Vertex2D{
    Vertex2D{position: position}
}

impl Default for Vertex2D{
    fn default() -> Vertex2D{
        vertex2d(vec2!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3D{
    pub position: Vec3,
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3D{
    pub position: Vec3,
}

pub fn vertex3d(position: Vec3) -> Vertex3D{
    Vertex3D{position: position}
}

impl Default for Vertex3D{
    fn default() -> Vertex3D{
        vertex3d(vec3!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex2DTex{
    pub position: Vec2,
    pub texcoord: Vec2
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex2DTex{
    pub position: Vec2,
    pub texcoord: Vec2
}

pub fn vertex2dtex(position: Vec2, texcoord: Vec2) -> Vertex2DTex{
    Vertex2DTex{position: position, texcoord: texcoord}
}

impl Default for Vertex2DTex{
    fn default() -> Vertex2DTex{
        vertex2dtex(vec2!(0.), vec2!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex2DTex3D{
    pub position: Vec2,
    pub texcoord: Vec3
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex2DText3D{
    pub position: Vec2,
    pub texcoord: Vec3
}

pub fn vertex2dtex3d(position: Vec2, texcoord: Vec3) -> Vertex2DTex3D{
    Vertex2DTex3D{position: position, texcoord: texcoord}
}

impl Default for Vertex2DTex3D{
    fn default() -> Vertex2DTex3D{
        vertex2dtex3d(vec2!(0.), vec3!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex2DColor{
    pub position: Vec2,
    pub color: Rgba<f32>,
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex2DColor{
    pub position: Vec2,
    pub color: Rgba<f32>,
}

pub fn vertex2dcolor<C: ToRgba>(position: Vec2, color: &C) -> Vertex2DColor{
    Vertex2DColor{position: position, color: color.to_rgba()}
}

impl Default for Vertex2DColor{
    fn default() -> Vertex2DColor{
        vertex2dcolor(vec2!(0.), &rgba!(1.,1.,1.,1.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex2DTexColor{
    pub position: Vec2,
    pub texcoord: Vec2,
    pub color: Rgba<f32>
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex2DTexColor{
    pub position: Vec2,
    pub texcoord: Vec2,
    pub color: Rgba<f32>
}

pub fn vertex2dtexcolor<C: ToRgba>(position: Vec2, texcoord: Vec2, color: &C) -> Vertex2DTexColor{
    Vertex2DTexColor{position: position, texcoord: texcoord, color: color.to_rgba()}
}

impl Default for Vertex2DTexColor{
    fn default() -> Vertex2DTexColor{
        vertex2dtexcolor(vec2!(0.), vec2!(0.), &rgba!(1.,1.,1.,1.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3DTex{
    pub position: Vec3,
    pub texcoord: Vec2,
    pub pad: Vec3
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3DTex{
    pub position: Vec3,
    pub texcoord: Vec2,
    pub pad: Vec3
}

pub fn vertex3dtex(position: Vec3, texcoord: Vec2) -> Vertex3DTex{
    Vertex3DTex{position: position, texcoord: texcoord, pad: zero()}
}

impl Default for Vertex3DTex{
    fn default() -> Vertex3DTex{
        vertex3dtex(vec3!(0.), vec2!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3DColor{
    pub position: Vec3,
    pub color: Rgba<f32>,
    pub pad: f32
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3DColor{
    pub position: Vec3,
    pub color: Rgba<f32>,
    pub pad: f32
}

pub fn vertex3dcolor<C: ToRgba>(position: Vec3, color: &C) -> Vertex3DColor{
    Vertex3DColor{position: position, color: color.to_rgba(), pad: 0f32}
}

impl Default for Vertex3DColor{
    fn default() -> Vertex3DColor{
        vertex3dcolor(vec3!(0.), &rgba!(1.,1.,1.,1.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3DTexNormal{
    pub position: Vec3,
    pub texcoord: Vec2,
    pub normal: Vec3
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3DTexNormal{
    pub position: Vec3,
    pub texcoord: Vec2,
    pub normal: Vec3
}

pub fn vertex3dtexnormal(position: Vec3, texcoord: Vec2, normal: Vec3) -> Vertex3DTexNormal{
    Vertex3DTexNormal{position: position, texcoord: texcoord, normal: normal}
}

impl Default for Vertex3DTexNormal{
    fn default() -> Vertex3DTexNormal{
        vertex3dtexnormal(vec3!(0.), vec2!(0.), vec3!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3DNormal{
    pub position: Vec3,
    pub normal: Vec3,
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3DNormal{
    pub position: Vec3,
    pub normal: Vec3,
}

pub fn vertex3dnormal(position: Vec3, normal: Vec3) -> Vertex3DNormal{
    Vertex3DNormal{position: position, normal: normal }
}

impl Default for Vertex3DNormal{
    fn default() -> Vertex3DNormal{
        vertex3dnormal(vec3!(0.), vec3!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3DColorNormal{
    pub position: Vec3,
    pub color: Rgba<f32>,
    pub normal: Vec3,
    pub pad: [f32;6]
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3DColorNormal{
    pub position: Vec3,
    pub color: Rgba<f32>,
    pub normal: Vec3,
    pub pad: [f32;6]
}

pub fn vertex3dcolornormal<C: ToRgba>(position: Vec3, color: &C, normal: Vec3) -> Vertex3DColorNormal{
    Vertex3DColorNormal{position: position, color: color.to_rgba(), normal: normal, pad: [0f32;6]}
}

impl Default for Vertex3DColorNormal{
    fn default() -> Vertex3DColorNormal{
        vertex3dcolornormal(vec3!(0.), &rgba!(1.,1.,1.,1.), vec3!(0.))
    }
}

#[cfg(not(target_os = "emscripten"))]
#[derive(Clone,Copy,Debug,VertexFormat)]
#[repr(C)]
pub struct Vertex3DTexColor{
    pub position: Vec3,
    pub texcoord: Vec2,
    pub color: Rgba<f32>,
    pub pad: [f32;7]
}

#[cfg(target_os = "emscripten")]
#[derive(Clone,Copy,Debug,VertexFormat)]
pub struct Vertex3DTexColor{
    pub position: Vec3,
    pub texcoord: Vec2,
    pub color: Rgba<f32>,
    pub pad: [f32;7]
}

pub fn vertex3dtexcolor<C: ToRgba>(position: Vec3, texcoord: Vec2, color: &C) -> Vertex3DTexColor{
    Vertex3DTexColor{position: position, color: color.to_rgba(), texcoord: texcoord, pad: [0f32;7]}
}

impl Default for Vertex3DTexColor{
    fn default() -> Vertex3DTexColor{
        vertex3dtexcolor(vec3!(0.), vec2!(0.), &rgba!(1.,1.,1.,1.))
    }
}