1 /*
2 * OpenBOR - http://www.LavaLit.com
3 * -----------------------------------------------------------------------
4 * Licensed under the BSD license, see LICENSE in OpenBOR root for details.
5 *
6 * Copyright (c) 2004 - 2011 OpenBOR Team
7 */
8
9 #include "vertex.h"
10
setVertexTexture(tVertexTexture * t,short texture_width,short texture_height,short texture_step,float vertex_width,float vertex_height,float vertex_x,float vertex_y)11 void setVertexTexture(
12 tVertexTexture *t,
13 short texture_width,
14 short texture_height,
15 short texture_step,
16 float vertex_width,
17 float vertex_height,
18 float vertex_x,
19 float vertex_y)
20 {
21 t->texture_width = texture_width;
22 t->texture_width_remaining = texture_width;
23 t->texture_step = texture_step;
24 t->output_texture_y_start = 0;
25 t->output_texture_x_end = 0;
26 t->output_texture_y_end = texture_height;
27 t->output_last = 0;
28 t->vertex_step = vertex_width * (float) texture_step / (float) texture_width;
29 t->vertex_x_plus_vertex_width = vertex_x + vertex_width;
30 t->output_vertex_y_start = vertex_y;
31 t->output_vertex_x_end = vertex_x;
32 t->output_vertex_y_end = vertex_y + vertex_height;
33 }
34
getVertexTexture(tVertexTexture * t)35 void getVertexTexture(tVertexTexture *t)
36 {
37 t->output_texture_x_start = t->output_texture_x_end;
38 t->output_vertex_x_start = t->output_vertex_x_end;
39 if (t->texture_width_remaining > t->texture_step)
40 {
41 t->texture_width_remaining -= t->texture_step;
42 t->output_texture_x_end += t->texture_step;
43 t->output_vertex_x_end += t->vertex_step;
44 }
45 else
46 {
47 t->output_texture_x_end = t->texture_width;
48 t->output_vertex_x_end = t->vertex_x_plus_vertex_width;
49 t->output_last = 1;
50 }
51 }
52