summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2023-04-30 01:53:01 -0700
committerSchark <jordan@schark.online>2023-04-30 01:53:01 -0700
commit1f63b19853f5dbbffb9a0c170f2260288d2f6020 (patch)
tree833685fab73b334e30d28af6c3e702171fa5a7e1 /src/main.c
parentd8157543163cfc8108653ac385016642ce8b6cd3 (diff)
downloadgamedev-1f63b19853f5dbbffb9a0c170f2260288d2f6020.tar.gz
gamedev-1f63b19853f5dbbffb9a0c170f2260288d2f6020.zip
Working window, basic cmake implementation
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..c225b14
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,46 @@
+#include <SDL.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+ printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_Window *window = SDL_CreateWindow("Raycaster", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
+ if (!window) {
+ printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
+ if (!renderer) {
+ printf("Renderer could not be created. SDL_Error: %s\n", SDL_GetError());
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+ return 1;
+ }
+
+ int running = 1;
+ SDL_Event event;
+
+ while (running) {
+ while (SDL_PollEvent(&event)){
+ if (event.type == SDL_QUIT) {
+ running = 0;
+ }
+ }
+
+ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+ SDL_RenderClear(renderer);
+
+ SDL_RenderPresent(renderer);
+
+ }
+
+ SDL_DestroyRenderer(renderer);
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
+ return 0;
+}