From f4c66a4c77e5818ca9703f59a80ea92e27ed45c6 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sat, 22 Oct 2022 21:08:08 +0300 Subject: abstract messages for easier use --- src/display.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/display.c') diff --git a/src/display.c b/src/display.c index ba9bc48..fa3d573 100644 --- a/src/display.c +++ b/src/display.c @@ -17,19 +17,19 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, } extern unsigned char cam_data[]; +extern unsigned int WIDTH; +extern unsigned int HEIGHT; -unsigned char WIDTH = 1; -unsigned char HEIGHT = 1; GLubyte pixels[BUF_CAP] = {0}; -void pixel(int x, int y, char *buf) +void pixel(int x, int y) { // for rotating the screen int p = (y*WIDTH + x)*3; int b = ((HEIGHT-1-y)*WIDTH+x)*3; - pixels[p+0] = buf[b+0]; - pixels[p+1] = buf[b+1]; - pixels[p+2] = buf[b+2]; + pixels[p+0] = cam_data[b+0]; + pixels[p+1] = cam_data[b+1]; + pixels[p+2] = cam_data[b+2]; } int display(void) @@ -56,13 +56,11 @@ int display(void) while (!glfwWindowShouldClose(window)) { - WIDTH = MAX(cam_data[0], 1); - HEIGHT = MAX(cam_data[1], 1); glfwSetWindowSize(window, WIDTH, HEIGHT); for(int i = 0; i < HEIGHT; i++) for(int j = 0; j < WIDTH; j++) - pixel(j, i, &(cam_data[2])); + pixel(j, i); glClear(GL_COLOR_BUFFER_BIT); glDrawPixels(WIDTH, HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels); -- cgit v1.2.3