From 9d88d471ac059c93523c00b96ae1cbbc52e07b69 Mon Sep 17 00:00:00 2001 From: kartofen Date: Wed, 19 Oct 2022 22:38:27 +0300 Subject: minor refactor --- src/display.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/display.c') diff --git a/src/display.c b/src/display.c index a09cc46..ba9bc48 100644 --- a/src/display.c +++ b/src/display.c @@ -12,7 +12,7 @@ static void error_callback(int error, const char* description) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) + if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GLFW_TRUE); } @@ -24,6 +24,7 @@ GLubyte pixels[BUF_CAP] = {0}; void pixel(int x, int y, char *buf) { + // for rotating the screen int p = (y*WIDTH + x)*3; int b = ((HEIGHT-1-y)*WIDTH+x)*3; pixels[p+0] = buf[b+0]; @@ -53,20 +54,15 @@ int display(void) glfwMakeContextCurrent(window); glfwSwapInterval(1); - - unsigned char *copy_cam_data; while (!glfwWindowShouldClose(window)) { - // memcpy(copy_cam_data, cam_data, BUF_CAP); - copy_cam_data = cam_data; - - WIDTH = MAX(copy_cam_data[0], 1); - HEIGHT = MAX(copy_cam_data[1], 1); + 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, &(copy_cam_data[2])); + pixel(j, i, &(cam_data[2])); glClear(GL_COLOR_BUFFER_BIT); glDrawPixels(WIDTH, HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels); -- cgit v1.2.3