aboutsummaryrefslogtreecommitdiff
path: root/src/display.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-10-22 21:08:08 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-10-22 21:08:08 +0300
commitf4c66a4c77e5818ca9703f59a80ea92e27ed45c6 (patch)
treee334b3f1c8bdb5c96bd756be4e451836a7762ab4 /src/display.c
parent9d88d471ac059c93523c00b96ae1cbbc52e07b69 (diff)
abstract messages for easier use
Diffstat (limited to 'src/display.c')
-rw-r--r--src/display.c16
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);