-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathcommon_texture.h
40 lines (37 loc) · 929 Bytes
/
common_texture.h
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
#ifndef COMMON_TEXTURE_H
#define COMMON_TEXTURE_H
#include <stdlib.h>
/**
* Return checkered array with colors like:
*
* black | green
* -------------
* blue | red
*/
unsigned char * common_texture_get_image(unsigned int width, unsigned int height) {
unsigned char *cur, *image;
size_t i, j;
image = malloc(3 * width * height);
for (i = 0; i < width; i++) {
for (j = 0; j < height; j++) {
cur = &image[3 * (i * width + j)];
cur[0] = 0;
cur[1] = 0;
cur[2] = 0;
if (i < width / 2) {
if (j < height / 2) {
} else {
cur[0] = 255;
}
} else {
if (j < height / 2) {
cur[1] = 255;
} else {
cur[2] = 255;
}
}
}
}
return image;
}
#endif