From 7e64d0c78e8a21f2ede7eab1303758391001c0dc Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 17 Oct 2022 23:04:12 +0300 Subject: many changes in progess --- src/display.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/display.c') 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"); } -- cgit v1.2.3