diff options
Diffstat (limited to 'src/display.c')
-rw-r--r-- | src/display.c | 16 |
1 files changed, 7 insertions, 9 deletions
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); |