cg-from-scratch/src/rasteriser/main.c
2024-06-22 19:27:30 +01:00

48 lines
1.0 KiB
C

#include "rasteriser/rasteriser.h"
#include "vector/vec.h"
#include "window/window.h"
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_keycode.h>
#include <stdlib.h>
int main(void) {
colour_t bg =
(colour_t){.rgba.r = 27, .rgba.g = 38, .rgba.b = 79, .rgba.a = 255};
window_t window = {0};
if (!init_window(&window, 800, 800, "CG From Scratch Rasteriser")) {
return EXIT_FAILURE;
}
bool running = true;
SDL_Event event = {0};
// i32 w_min = ((i32)window.half_width) * -1;
// i32 w_max = (i32)window.half_width;
// i32 h_min = ((i32)window.half_height) * -1;
// i32 h_max = (i32)window.half_height;
vec2i_t a = {.x = -300, .y = 0};
vec2i_t b = {.x = 300, .y = 250};
while (running) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
running = false;
break;
}
}
clear_window(&window, bg);
draw_line(&window, a, b, (colour_t){.colour = 0xffffffff});
swap_buffers(&window);
}
close_window(&window);
return EXIT_SUCCESS;
}