Branch data Line data Source code
1 : : /* ______ ___ ___
2 : : * /\ _ \ /\_ \ /\_ \
3 : : * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
4 : : * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
5 : : * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
6 : : * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
7 : : * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
8 : : * /\____/
9 : : * \_/__/
10 : : *
11 : : * Software implementation of some of the primitive routines.
12 : : *
13 : : *
14 : : * By Pavel Sountsov.
15 : : *
16 : : * See readme.txt for copyright information.
17 : : */
18 : :
19 : :
20 : : #include "allegro5/allegro.h"
21 : : #include "allegro5/internal/aintern_bitmap.h"
22 : :
23 : : #include "allegro5/allegro_primitives.h"
24 : : #include "allegro5/internal/aintern.h"
25 : : #include "allegro5/internal/aintern_prim_soft.h"
26 : : #include "allegro5/internal/aintern_prim.h"
27 : : #include "allegro5/internal/aintern_tri_soft.h"
28 : :
29 : : /*
30 : : The vertex cache allows for bulk transformation of vertices, for faster run speeds
31 : : */
32 : : #define LOCAL_VERTEX_CACHE ALLEGRO_VERTEX vertex_cache[ALLEGRO_VERTEX_CACHE_SIZE]
33 : :
34 : 19740 : static void convert_vtx(ALLEGRO_BITMAP* texture, const char* src, ALLEGRO_VERTEX* dest, const ALLEGRO_VERTEX_DECL* decl)
35 : : {
36 : : ALLEGRO_VERTEX_ELEMENT* e;
37 [ + - ]: 19740 : if(!decl) {
38 : 19740 : *dest = *((ALLEGRO_VERTEX*)src);
39 : 19740 : return;
40 : : }
41 : 0 : e = &decl->elements[ALLEGRO_PRIM_POSITION];
42 [ # # ]: 0 : if(e->attribute) {
43 [ # # # ]: 0 : switch(e->storage) {
44 : : case ALLEGRO_PRIM_FLOAT_2:
45 : : case ALLEGRO_PRIM_FLOAT_3:
46 : : {
47 : 0 : float *ptr = (float*)(src + e->offset);
48 : 0 : dest->x = *(ptr);
49 : 0 : dest->y = *(ptr + 1);
50 : 0 : break;
51 : : }
52 : : case ALLEGRO_PRIM_SHORT_2:
53 : : {
54 : 0 : short *ptr = (short*)(src + e->offset);
55 : 0 : dest->x = (float)*(ptr);
56 : 0 : dest->y = (float)*(ptr + 1);
57 : 0 : break;
58 : : }
59 : : }
60 : : } else {
61 : 0 : dest->x = 0;
62 : 0 : dest->y = 0;
63 : : }
64 : :
65 : 0 : e = &decl->elements[ALLEGRO_PRIM_TEX_COORD];
66 [ # # ]: 0 : if(!e->attribute)
67 : 0 : e = &decl->elements[ALLEGRO_PRIM_TEX_COORD_PIXEL];
68 [ # # ]: 0 : if(e->attribute) {
69 [ # # # ]: 0 : switch(e->storage) {
70 : : case ALLEGRO_PRIM_FLOAT_2:
71 : : case ALLEGRO_PRIM_FLOAT_3:
72 : : {
73 : 0 : float *ptr = (float*)(src + e->offset);
74 : 0 : dest->u = *(ptr);
75 : 0 : dest->v = *(ptr + 1);
76 : 0 : break;
77 : : }
78 : : case ALLEGRO_PRIM_SHORT_2:
79 : : {
80 : 0 : short *ptr = (short*)(src + e->offset);
81 : 0 : dest->u = (float)*(ptr);
82 : 0 : dest->v = (float)*(ptr + 1);
83 : 0 : break;
84 : : }
85 : : }
86 [ # # ][ # # ]: 0 : if(texture && e->attribute == ALLEGRO_PRIM_TEX_COORD) {
87 : 0 : dest->u *= (float)al_get_bitmap_width(texture);
88 : 0 : dest->v *= (float)al_get_bitmap_height(texture);
89 : : }
90 : : } else {
91 : 0 : dest->u = 0;
92 : 0 : dest->v = 0;
93 : : }
94 : :
95 : 0 : e = &decl->elements[ALLEGRO_PRIM_COLOR_ATTR];
96 [ # # ]: 0 : if(e->attribute) {
97 : 0 : dest->color = *(ALLEGRO_COLOR*)(src + e->offset);
98 : : } else {
99 : 0 : dest->color = al_map_rgba_f(1,1,1,1);
100 : : }
101 : : }
102 : :
103 : 4312 : int _al_draw_prim_soft(ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, int start, int end, int type)
104 : : {
105 : : LOCAL_VERTEX_CACHE;
106 : : int num_primitives;
107 : : int num_vtx;
108 : : int use_cache;
109 [ - + ]: 4312 : int stride = decl ? decl->stride : (int)sizeof(ALLEGRO_VERTEX);
110 : 4312 : const ALLEGRO_TRANSFORM* global_trans = al_get_current_transform();
111 : :
112 : 4312 : num_primitives = 0;
113 : 4312 : num_vtx = end - start;
114 : 4312 : use_cache = num_vtx < ALLEGRO_VERTEX_CACHE_SIZE;
115 : :
116 [ + + ]: 4312 : if (texture)
117 : 34 : al_lock_bitmap(texture, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
118 : :
119 [ + - ]: 4312 : if (use_cache) {
120 : : int ii;
121 : 4312 : int n = 0;
122 : 4312 : const char* vtxptr = (const char*)vtxs + start * stride;
123 [ + + ]: 24052 : for (ii = 0; ii < num_vtx; ii++) {
124 : 19740 : convert_vtx(texture, vtxptr, &vertex_cache[ii], decl);
125 : 19740 : al_transform_coordinates(global_trans, &vertex_cache[ii].x, &vertex_cache[ii].y);
126 : 19740 : n++;
127 : 19740 : vtxptr += stride;
128 : : }
129 : : }
130 : :
131 : : #define SET_VERTEX(v, idx) \
132 : : convert_vtx(texture, (const char*)vtxs + stride * (idx), &v, decl); \
133 : : al_transform_coordinates(global_trans, &v.x, &v.y); \
134 : :
135 [ + + + + : 4312 : switch (type) {
+ + - - ]
136 : : case ALLEGRO_PRIM_LINE_LIST: {
137 [ - + ]: 4109 : if (use_cache) {
138 : : int ii;
139 [ + + ]: 8224 : for (ii = 0; ii < num_vtx - 1; ii += 2) {
140 : 4115 : _al_line_2d(texture, &vertex_cache[ii], &vertex_cache[ii + 1]);
141 : : }
142 : : } else {
143 : : int ii;
144 [ # # ]: 0 : for (ii = start; ii < end - 1; ii += 2) {
145 : : ALLEGRO_VERTEX v1, v2;
146 : 0 : SET_VERTEX(v1, ii);
147 : 0 : SET_VERTEX(v2, ii + 1);
148 : :
149 : 0 : _al_line_2d(texture, &v1, &v2);
150 : : }
151 : : }
152 : 4109 : num_primitives = num_vtx / 2;
153 : 4109 : break;
154 : : };
155 : : case ALLEGRO_PRIM_LINE_STRIP: {
156 [ + - ]: 10 : if (use_cache) {
157 : : int ii;
158 [ + + ]: 210 : for (ii = 1; ii < num_vtx; ii++) {
159 : 200 : _al_line_2d(texture, &vertex_cache[ii - 1], &vertex_cache[ii]);
160 : : }
161 : : } else {
162 : : int ii;
163 : 0 : int idx = 1;
164 : : ALLEGRO_VERTEX vtx[2];
165 : 0 : SET_VERTEX(vtx[0], start);
166 [ # # ]: 0 : for (ii = start + 1; ii < end; ii++) {
167 : 0 : SET_VERTEX(vtx[idx], ii)
168 : 0 : _al_line_2d(texture, &vtx[0], &vtx[1]);
169 : 0 : idx = 1 - idx;
170 : : }
171 : : }
172 : 10 : num_primitives = num_vtx - 1;
173 : 10 : break;
174 : : };
175 : : case ALLEGRO_PRIM_LINE_LOOP: {
176 [ + - ]: 13 : if (use_cache) {
177 : : int ii;
178 [ + + ]: 218 : for (ii = 1; ii < num_vtx; ii++) {
179 : 205 : _al_line_2d(texture, &vertex_cache[ii - 1], &vertex_cache[ii]);
180 : : }
181 : 13 : _al_line_2d(texture, &vertex_cache[num_vtx - 1], &vertex_cache[0]);
182 : : } else {
183 : : int ii;
184 : 0 : int idx = 1;
185 : : ALLEGRO_VERTEX vtx[2];
186 : 0 : SET_VERTEX(vtx[0], start);
187 [ # # ]: 0 : for (ii = start + 1; ii < end; ii++) {
188 : 0 : SET_VERTEX(vtx[idx], ii)
189 : 0 : _al_line_2d(texture, &vtx[idx], &vtx[1 - idx]);
190 : 0 : idx = 1 - idx;
191 : : }
192 : 0 : SET_VERTEX(vtx[idx], start)
193 : 0 : _al_line_2d(texture, &vtx[idx], &vtx[1 - idx]);
194 : : }
195 : 13 : num_primitives = num_vtx;
196 : 13 : break;
197 : : };
198 : : case ALLEGRO_PRIM_TRIANGLE_LIST: {
199 [ - + ]: 35 : if (use_cache) {
200 : : int ii;
201 [ + + ]: 1450 : for (ii = 0; ii < num_vtx - 2; ii += 3) {
202 : 1415 : _al_triangle_2d(texture, &vertex_cache[ii], &vertex_cache[ii + 1], &vertex_cache[ii + 2]);
203 : : }
204 : : } else {
205 : : int ii;
206 [ # # ]: 0 : for (ii = start; ii < end - 2; ii += 3) {
207 : : ALLEGRO_VERTEX v1, v2, v3;
208 : 0 : SET_VERTEX(v1, ii);
209 : 0 : SET_VERTEX(v2, ii + 1);
210 : 0 : SET_VERTEX(v3, ii + 2);
211 : :
212 : 0 : _al_triangle_2d(texture, &v1, &v2, &v3);
213 : : }
214 : : }
215 : 35 : num_primitives = num_vtx / 3;
216 : 35 : break;
217 : : };
218 : : case ALLEGRO_PRIM_TRIANGLE_STRIP: {
219 [ + - ]: 65 : if (use_cache) {
220 : : int ii;
221 [ + + ]: 5589 : for (ii = 2; ii < num_vtx; ii++) {
222 : 5524 : _al_triangle_2d(texture, &vertex_cache[ii - 2], &vertex_cache[ii - 1], &vertex_cache[ii]);
223 : : }
224 : : } else {
225 : : int ii;
226 : 0 : int idx = 2;
227 : : ALLEGRO_VERTEX vtx[3];
228 : 0 : SET_VERTEX(vtx[0], start);
229 : 0 : SET_VERTEX(vtx[1], start + 1);
230 [ # # ]: 0 : for (ii = start + 2; ii < end; ii++) {
231 : 0 : SET_VERTEX(vtx[idx], ii);
232 : :
233 : 0 : _al_triangle_2d(texture, &vtx[0], &vtx[1], &vtx[2]);
234 : 0 : idx = (idx + 1) % 3;
235 : : }
236 : : }
237 : 65 : num_primitives = num_vtx - 2;
238 : 65 : break;
239 : : };
240 : : case ALLEGRO_PRIM_TRIANGLE_FAN: {
241 [ + - ]: 80 : if (use_cache) {
242 : : int ii;
243 [ + + ]: 1183 : for (ii = 1; ii < num_vtx; ii++) {
244 : 1103 : _al_triangle_2d(texture, &vertex_cache[0], &vertex_cache[ii], &vertex_cache[ii - 1]);
245 : : }
246 : : } else {
247 : : int ii;
248 : 0 : int idx = 1;
249 : : ALLEGRO_VERTEX v0;
250 : : ALLEGRO_VERTEX vtx[2];
251 : 0 : SET_VERTEX(v0, start);
252 : 0 : SET_VERTEX(vtx[0], start + 1);
253 [ # # ]: 0 : for (ii = start + 1; ii < end; ii++) {
254 : 0 : SET_VERTEX(vtx[idx], ii)
255 : 0 : _al_triangle_2d(texture, &v0, &vtx[0], &vtx[1]);
256 : 0 : idx = 1 - idx;
257 : : }
258 : : }
259 : 80 : num_primitives = num_vtx - 2;
260 : 80 : break;
261 : : };
262 : : case ALLEGRO_PRIM_POINT_LIST: {
263 [ # # ]: 0 : if (use_cache) {
264 : : int ii;
265 [ # # ]: 0 : for (ii = 0; ii < num_vtx; ii++) {
266 : 0 : _al_point_2d(texture, &vertex_cache[ii]);
267 : : }
268 : : } else {
269 : : int ii;
270 [ # # ]: 0 : for (ii = start; ii < end; ii++) {
271 : : ALLEGRO_VERTEX v;
272 : 0 : SET_VERTEX(v, ii);
273 : :
274 : 0 : _al_point_2d(texture, &v);
275 : : }
276 : : }
277 : 0 : num_primitives = num_vtx;
278 : 0 : break;
279 : : };
280 : : }
281 : :
282 [ + + ]: 4312 : if(texture)
283 : 34 : al_unlock_bitmap(texture);
284 : :
285 : 4312 : return num_primitives;
286 : : #undef SET_VERTEX
287 : : }
288 : :
289 : 0 : int _al_draw_prim_indexed_soft(ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl,
290 : : const int* indices, int num_vtx, int type)
291 : : {
292 : : LOCAL_VERTEX_CACHE;
293 : : int num_primitives;
294 : : int use_cache;
295 : : int min_idx, max_idx;
296 : : int ii;
297 [ # # ]: 0 : int stride = decl ? decl->stride : (int)sizeof(ALLEGRO_VERTEX);
298 : 0 : const ALLEGRO_TRANSFORM* global_trans = al_get_current_transform();
299 : :
300 : 0 : num_primitives = 0;
301 : 0 : use_cache = 1;
302 : 0 : min_idx = indices[0];
303 : 0 : max_idx = indices[0];
304 : :
305 : : /*
306 : : Determine the range we are dealing with
307 : : */
308 [ # # ]: 0 : for (ii = 1; ii < num_vtx; ii++) {
309 : 0 : int idx = indices[ii];
310 [ # # ]: 0 : if (max_idx < idx)
311 : : max_idx = idx;
312 [ # # ]: 0 : else if (min_idx > indices[ii])
313 : 0 : min_idx = idx;
314 : : }
315 [ # # ]: 0 : if (max_idx - min_idx >= ALLEGRO_VERTEX_CACHE_SIZE) {
316 : 0 : use_cache = 0;
317 : : }
318 : :
319 [ # # ]: 0 : if (texture)
320 : 0 : al_lock_bitmap(texture, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
321 : :
322 [ # # ]: 0 : if (use_cache) {
323 : : int ii;
324 [ # # ]: 0 : for (ii = 0; ii < num_vtx; ii++) {
325 : 0 : int idx = indices[ii];
326 : 0 : convert_vtx(texture, (const char*)vtxs + idx * stride, &vertex_cache[idx - min_idx], decl);
327 : 0 : al_transform_coordinates(global_trans, &vertex_cache[idx - min_idx].x, &vertex_cache[idx - min_idx].y);
328 : : }
329 : : }
330 : :
331 : : #define SET_VERTEX(v, idx) \
332 : : convert_vtx(texture, (const char*)vtxs + stride * (idx), &v, decl); \
333 : : al_transform_coordinates(global_trans, &v.x, &v.y); \
334 : :
335 [ # # # # : 0 : switch (type) {
# # # # ]
336 : : case ALLEGRO_PRIM_LINE_LIST: {
337 [ # # ]: 0 : if (use_cache) {
338 : : int ii;
339 [ # # ]: 0 : for (ii = 0; ii < num_vtx - 1; ii += 2) {
340 : 0 : int idx1 = indices[ii] - min_idx;
341 : 0 : int idx2 = indices[ii + 1] - min_idx;
342 : :
343 : 0 : _al_line_2d(texture, &vertex_cache[idx1], &vertex_cache[idx2]);
344 : : }
345 : : } else {
346 : : int ii;
347 [ # # ]: 0 : for (ii = 0; ii < num_vtx - 1; ii += 2) {
348 : 0 : int idx1 = indices[ii];
349 : 0 : int idx2 = indices[ii + 1];
350 : :
351 : : ALLEGRO_VERTEX v1, v2;
352 : 0 : SET_VERTEX(v1, idx1);
353 : 0 : SET_VERTEX(v2, idx2);
354 : :
355 : 0 : _al_line_2d(texture, &v1, &v2);
356 : : }
357 : : }
358 : 0 : num_primitives = num_vtx / 2;
359 : 0 : break;
360 : : };
361 : : case ALLEGRO_PRIM_LINE_STRIP: {
362 [ # # ]: 0 : if (use_cache) {
363 : : int ii;
364 [ # # ]: 0 : for (ii = 1; ii < num_vtx; ii++) {
365 : 0 : int idx1 = indices[ii - 1] - min_idx;
366 : 0 : int idx2 = indices[ii] - min_idx;
367 : :
368 : 0 : _al_line_2d(texture, &vertex_cache[idx1], &vertex_cache[idx2]);
369 : : }
370 : : } else {
371 : : int ii;
372 : 0 : int idx = 1;
373 : : ALLEGRO_VERTEX vtx[2];
374 : 0 : SET_VERTEX(vtx[0], indices[0]);
375 [ # # ]: 0 : for (ii = 1; ii < num_vtx; ii++) {
376 : 0 : SET_VERTEX(vtx[idx], indices[ii])
377 : 0 : _al_line_2d(texture, &vtx[0], &vtx[1]);
378 : 0 : idx = 1 - idx;
379 : : }
380 : : }
381 : 0 : num_primitives = num_vtx - 1;
382 : 0 : break;
383 : : };
384 : : case ALLEGRO_PRIM_LINE_LOOP: {
385 [ # # ]: 0 : if (use_cache) {
386 : : int ii;
387 : : int idx1, idx2;
388 : :
389 [ # # ]: 0 : for (ii = 1; ii < num_vtx; ii++) {
390 : 0 : int idx1 = indices[ii - 1] - min_idx;
391 : 0 : int idx2 = indices[ii] - min_idx;
392 : :
393 : 0 : _al_line_2d(texture, &vertex_cache[idx1], &vertex_cache[idx2]);
394 : : }
395 : 0 : idx1 = indices[0] - min_idx;
396 : 0 : idx2 = indices[num_vtx - 1] - min_idx;
397 : :
398 : 0 : _al_line_2d(texture, &vertex_cache[idx2], &vertex_cache[idx1]);
399 : : } else {
400 : : int ii;
401 : 0 : int idx = 1;
402 : : ALLEGRO_VERTEX vtx[2];
403 : 0 : SET_VERTEX(vtx[0], indices[0]);
404 [ # # ]: 0 : for (ii = 1; ii < num_vtx; ii++) {
405 : 0 : SET_VERTEX(vtx[idx], indices[ii])
406 : 0 : _al_line_2d(texture, &vtx[0], &vtx[1]);
407 : 0 : idx = 1 - idx;
408 : : }
409 : 0 : SET_VERTEX(vtx[idx], indices[0])
410 : 0 : _al_line_2d(texture, &vtx[0], &vtx[1]);
411 : : }
412 : 0 : num_primitives = num_vtx;
413 : 0 : break;
414 : : };
415 : : case ALLEGRO_PRIM_TRIANGLE_LIST: {
416 [ # # ]: 0 : if (use_cache) {
417 : : int ii;
418 [ # # ]: 0 : for (ii = 0; ii < num_vtx - 2; ii += 3) {
419 : 0 : int idx1 = indices[ii] - min_idx;
420 : 0 : int idx2 = indices[ii + 1] - min_idx;
421 : 0 : int idx3 = indices[ii + 2] - min_idx;
422 : 0 : _al_triangle_2d(texture, &vertex_cache[idx1], &vertex_cache[idx2], &vertex_cache[idx3]);
423 : : }
424 : : } else {
425 : : int ii;
426 [ # # ]: 0 : for (ii = 0; ii < num_vtx - 2; ii += 3) {
427 : 0 : int idx1 = indices[ii];
428 : 0 : int idx2 = indices[ii + 1];
429 : 0 : int idx3 = indices[ii + 2];
430 : :
431 : : ALLEGRO_VERTEX v1, v2, v3;
432 : 0 : SET_VERTEX(v1, idx1);
433 : 0 : SET_VERTEX(v2, idx2);
434 : 0 : SET_VERTEX(v3, idx3);
435 : :
436 : 0 : _al_triangle_2d(texture, &v1, &v2, &v3);
437 : : }
438 : : }
439 : 0 : num_primitives = num_vtx / 3;
440 : 0 : break;
441 : : };
442 : : case ALLEGRO_PRIM_TRIANGLE_STRIP: {
443 [ # # ]: 0 : if (use_cache) {
444 : : int ii;
445 [ # # ]: 0 : for (ii = 2; ii < num_vtx; ii++) {
446 : 0 : int idx1 = indices[ii - 2] - min_idx;
447 : 0 : int idx2 = indices[ii - 1] - min_idx;
448 : 0 : int idx3 = indices[ii] - min_idx;
449 : 0 : _al_triangle_2d(texture, &vertex_cache[idx1], &vertex_cache[idx2], &vertex_cache[idx3]);
450 : : }
451 : : } else {
452 : : int ii;
453 : 0 : int idx = 2;
454 : : ALLEGRO_VERTEX vtx[3];
455 : 0 : SET_VERTEX(vtx[0], indices[0]);
456 : 0 : SET_VERTEX(vtx[1], indices[1]);
457 [ # # ]: 0 : for (ii = 2; ii < num_vtx; ii ++) {
458 : 0 : SET_VERTEX(vtx[idx], indices[ii]);
459 : :
460 : 0 : _al_triangle_2d(texture, &vtx[0], &vtx[1], &vtx[2]);
461 : 0 : idx = (idx + 1) % 3;
462 : : }
463 : : }
464 : 0 : num_primitives = num_vtx - 2;
465 : 0 : break;
466 : : };
467 : : case ALLEGRO_PRIM_TRIANGLE_FAN: {
468 [ # # ]: 0 : if (use_cache) {
469 : : int ii;
470 : 0 : int idx0 = indices[0] - min_idx;
471 [ # # ]: 0 : for (ii = 1; ii < num_vtx; ii++) {
472 : 0 : int idx1 = indices[ii] - min_idx;
473 : 0 : int idx2 = indices[ii - 1] - min_idx;
474 : 0 : _al_triangle_2d(texture, &vertex_cache[idx0], &vertex_cache[idx1], &vertex_cache[idx2]);
475 : : }
476 : : } else {
477 : : int ii;
478 : 0 : int idx = 1;
479 : : ALLEGRO_VERTEX v0;
480 : : ALLEGRO_VERTEX vtx[2];
481 : 0 : SET_VERTEX(v0, indices[0]);
482 : 0 : SET_VERTEX(vtx[0], indices[1]);
483 [ # # ]: 0 : for (ii = 2; ii < num_vtx; ii ++) {
484 : 0 : SET_VERTEX(vtx[idx], indices[ii])
485 : 0 : _al_triangle_2d(texture, &v0, &vtx[0], &vtx[1]);
486 : 0 : idx = 1 - idx;
487 : : }
488 : : }
489 : 0 : num_primitives = num_vtx - 2;
490 : 0 : break;
491 : : };
492 : : case ALLEGRO_PRIM_POINT_LIST: {
493 [ # # ]: 0 : if (use_cache) {
494 : : int ii;
495 [ # # ]: 0 : for (ii = 0; ii < num_vtx; ii++) {
496 : 0 : int idx = indices[ii] - min_idx;
497 : 0 : _al_point_2d(texture, &vertex_cache[idx]);
498 : : }
499 : : } else {
500 : : int ii;
501 [ # # ]: 0 : for (ii = 0; ii < num_vtx; ii++) {
502 : : ALLEGRO_VERTEX v;
503 : 0 : SET_VERTEX(v, indices[ii]);
504 : :
505 : 0 : _al_point_2d(texture, &v);
506 : : }
507 : : }
508 : 0 : num_primitives = num_vtx;
509 : 0 : break;
510 : : };
511 : : }
512 : :
513 [ # # ]: 0 : if(texture)
514 : 0 : al_unlock_bitmap(texture);
515 : :
516 : 0 : return num_primitives;
517 : : #undef SET_VERTEX
518 : : }
519 : :
520 : : /* Function: al_draw_soft_triangle
521 : : */
522 : 0 : void al_draw_soft_triangle(
523 : : ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3, uintptr_t state,
524 : : void (*init)(uintptr_t, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*),
525 : : void (*first)(uintptr_t, int, int, int, int),
526 : : void (*step)(uintptr_t, int),
527 : : void (*draw)(uintptr_t, int, int, int))
528 : : {
529 : 0 : _al_draw_soft_triangle(v1, v2, v3, state, init, first, step, draw);
530 : 0 : }
531 : :
532 : : /* vim: set sts=3 sw=3 et: */
|