diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-10-17 23:04:12 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-10-17 23:04:12 +0300 |
commit | 7e64d0c78e8a21f2ede7eab1303758391001c0dc (patch) | |
tree | a01e44b12d66de3e4fbc5cf5ab20f439fc8d6fc8 /src/display.c | |
parent | b1b7c92aa96af5502f276819b628b05d54f4655c (diff) |
many changes in progess
Diffstat (limited to 'src/display.c')
-rw-r--r-- | src/display.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/display.c b/src/display.c index 2fb1d78..6d4c55a 100644 --- a/src/display.c +++ b/src/display.c @@ -5,11 +5,13 @@ #include "display.h" #include "typedef.h" +#define MAX(x, y) (((x) > (y)) ? (x) : (y)) + +extern unsigned char *cam_data; + unsigned char WIDTH = 1; unsigned char HEIGHT = 1; - GLubyte pixels[BUF_CAP] = {0}; -static int fd; void pixel(int x, int y, char *buf) { @@ -22,14 +24,12 @@ void pixel(int x, int y, char *buf) void render() { - read(fd, &WIDTH, sizeof(WIDTH)); - read(fd, &HEIGHT, sizeof(HEIGHT)); + WIDTH = MAX(cam_data[0], 1); + HEIGHT = MAX(cam_data[1], 1); - char buf[BUF_CAP] = {0}; - if(read(fd, buf, sizeof(buf)) != -1) - for(int i = 0; i < HEIGHT; i++) - for(int j = 0; j < WIDTH; j++) - pixel(j, i, buf); + for(int i = 0; i < HEIGHT; i++) + for(int j = 0; j < WIDTH; j++) + pixel(j, i, &(cam_data[2])); glClear(GL_COLOR_BUFFER_BIT); glDrawPixels(WIDTH, HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels); @@ -39,17 +39,13 @@ void render() glutPostRedisplay(); } -void display(int *argc, char **argv, int readfd) +void display(int *argc, char **argv) { glutInit(argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(69, 69); glutCreateWindow(argv[0]); - fd = readfd; - glutDisplayFunc(render); glutMainLoop(); - - puts("DISPLAY EXIT"); } |