aboutsummaryrefslogtreecommitdiff
path: root/src/display.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-10-19 22:38:27 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-10-19 22:38:27 +0300
commit9d88d471ac059c93523c00b96ae1cbbc52e07b69 (patch)
tree1c696d196b86084a0208e338e5aaecff24361842 /src/display.c
parent0e6accd72e2b27cd348c6d43eac01cf4d73b752d (diff)
minor refactor
Diffstat (limited to 'src/display.c')
-rw-r--r--src/display.c14
1 files changed, 5 insertions, 9 deletions
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);