4 Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
24 #include "c3texture.h"
25 #include "c3driver_geometry.h"
30 const c3driver_geometry_t * d)
32 // c3texture_p t = (c3texture_p)g;
33 C3_DRIVER_INHERITED(g, d, dispose);
39 const c3driver_geometry_t * d,
42 c3texture_p t = (c3texture_p)g;
43 c3pixels_p p = t->geometry.mat.texture;
45 C3_DRIVER_INHERITED(g, d, project, m);
49 t->size.x > 0 ? t->size.x : p->w,
50 t->size.y > 0 ? t->size.y : p->h);
52 c3vec3f(0, 0, 0), c3vec3f(qs.x, 0, 0),
53 c3vec3f(qs.x, qs.y, 0), c3vec3f(0, qs.y, 0)
55 c3vertex_array_clear(&g->vertice);
56 c3vertex_array_realloc(&g->vertice, 4);
57 c3vertex_array_insert(&g->vertice, 0, v, 4);
59 c3f tw = p->normalize ? 1.0 : p->w,
60 th = p->normalize ? 1.0 : p->h;
62 c3vec2f(0, th), c3vec2f(tw, th),
63 c3vec2f(tw, 0), c3vec2f(0, 0)
66 printf("%s size %.0fx%.0f tex %.0fx%.0f\n", __func__, qs.x, qs.y, tw, th);
67 c3tex_array_clear(&t->geometry.textures);
68 c3tex_array_realloc(&t->geometry.textures, 4);
69 c3tex_array_insert(&t->geometry.textures, 0, ti, 4);
71 C3_DRIVER_INHERITED(g, d, project, m);
74 const c3driver_geometry_t c3texture_driver = {
75 .dispose = _c3texture_dispose,
76 .project = _c3texture_project,
78 const c3driver_geometry_t c3geometry_driver;
82 struct c3object_t * o /* = NULL */)
84 c3texture_p res = malloc(sizeof(*res));
85 return c3texture_init(res, o);
91 struct c3object_t * o /* = NULL */)
93 memset(t, 0, sizeof(*t));
94 c3geometry_init(&t->geometry,
95 c3geometry_type(C3_TEXTURE_TYPE, 0 /* GL_TRIANGLE_FAN */),
97 static const c3driver_geometry_t * list[] = {
98 &c3texture_driver, &c3geometry_driver, NULL,
100 t->geometry.driver = list;