-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite_scale.c
137 lines (105 loc) · 2.64 KB
/
sprite_scale.c
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
/**
* Copyright 2021 Jesús Abelardo Saldívar Aguilar
*
*
* Demonstration of sprite scaling with OpenVG
*
*/
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <VG/openvg.h>
#include <VG/vgu.h>
#include "vc.h"
#include "sprites.h"
#include "spritedata1.h"
VGfloat stroke_desp = 0.0f;
VGfloat rota = 0.0f;
void draw(EGL_DISPMANX_WINDOW_T *nativewindow, JS_VG_SPRITE *sprite_escena){
float clearColor[4] = {1, 1, 1, 0};
float dx = 1;
float dy = 1;
float ds = 1.01;
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
vgClear(0, 0, nativewindow->width, nativewindow->height);
vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
while (1){
// ¿Por qué ellipse.c no necesita llamar a esta función durante ciclo?
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
vgClear(0, 0, nativewindow->width, nativewindow->height);
//simple_shape();
draw_sprite(sprite_escena);
eglSwapBuffers(egldisplay, eglsurface);
//stroke_desp += 1.0f;
sprite_grupo.rotate += 2.0f;
sprite_grupo.scale[0] *= ds;
sprite_grupo.scale[1] *= ds;
sprite_grupo.translate[0] += dx;
sprite_grupo.translate[1] += dy;
if (sprite_grupo.translate[0] + 100 >= nativewindow->width){
sprite_grupo.translate[0] = nativewindow->width - 100;
dx = -1;
}
if (sprite_grupo.translate[0] - 100 <= 0){
sprite_grupo.translate[0] = 100;
dx = 1;
}
if (sprite_grupo.translate[1] + 100 >= nativewindow->height){
sprite_grupo.translate[1] = nativewindow->height - 100;
dy = -1;
}
if (sprite_grupo.translate[1] - 100 <= 0){
sprite_grupo.translate[1] = 100;
dy = 1;
}
if (sprite_grupo.scale[0] > 10){
sprite_grupo.scale[0] = 10;
ds = 0.99;
}
if (sprite_grupo.scale[0] < 0.02){
sprite_grupo.scale[0] = 0.02;
ds = 1.01;
}
//vgFlush();
}
vgFlush();
}
void sig_handler(int sig) {
printf("Abortando proceso...\n");
//eglTerminate(p_state->display);
deinit();
exit(1);
}
/*
typedef struct {
int
} SPRITE_BOUNCE;
*/
void sprite_bounce_routine(JS_VG_SPRITE *sprite){
}
int
main(int argc, char *argv[])
{
EGL_DISPMANX_WINDOW_T nativewindow;
JS_VG_SPRITE_LIST lista_sprites = {
.sprite = &sprite_grupo,
.sig = NULL
};
JS_VG_SPRITE sprite_escena = {
.translate = { 0, 0 },
.scale = { 1, 1 },
.rotate = 0,
.data = &lista_sprites,
.init_sprite = init_sprite_group_list,
.draw_func = draw_sprite_group_list
};
signal(SIGINT, sig_handler);
inicia_vc(&nativewindow);
init_sprite(&sprite_escena);
draw(&nativewindow, &sprite_escena);
deinit();
exit(0);
}