-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.c
50 lines (42 loc) · 1.06 KB
/
test.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
/* small test showing a basic example of providing pcm data in a thread
*/
#include "mmm.h"
#include <stdio.h>
int main ()
{
int frame = 1024;
Mmm *fb = mmm_new (800, 600, 0, NULL);
if (!fb)
{
fprintf (stderr, "failed to open buffer\n");
return -1;
}
while (frame < 16000)
{
int x, y;
uint8_t *buffer;
int width, height, stride;
mmm_client_check_size (fb, &width, &height); /* does the real resize as a side-effect */
buffer = mmm_get_buffer_write (fb, &width, &height, &stride, NULL);
for (y = 0; y < height; y++)
{
uint8_t *pixel = &buffer[y * stride];
for (x = 0; x < width; x++, pixel+=4)
{
pixel[0] = (int)((x * 255.0) / width );
pixel[1] = (int)((y * 255.0) / height );
pixel[2] = (int)((width-x) * 255.0 / width );
pixel[3] = 255;
}
}
mmm_write_done (fb, 0, 0, -1, -1);
frame++;
while (mmm_has_event (fb))
{
const char *event = mmm_get_event (fb);
fprintf (stderr, "%s\n", event);
}
}
mmm_destroy (fb);
return 0;
}