From 1b53cc099c2b218479e0aaa585e2251b6365cb08 Mon Sep 17 00:00:00 2001 From: Abhinav Prasai Date: Sat, 22 Nov 2025 21:06:11 +0000 Subject: create window + draw in context . --- include/quark.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/sdl.h | 9 +++++++++ 2 files changed, 55 insertions(+) create mode 100644 include/quark.h create mode 100644 include/sdl.h (limited to 'include') diff --git a/include/quark.h b/include/quark.h new file mode 100644 index 0000000..233314e --- /dev/null +++ b/include/quark.h @@ -0,0 +1,46 @@ +#pragma once + +#include +#include + +#include + +/* types */ +typedef struct { + SDL_Window* win; + SDL_GLContext gl; + int win_w; + int win_h; + bool running; +} quark_t; + +/* logging */ +#define ANSI_RESET "\x1b[0m" +#define ANSI_FG_WHITE "\x1b[37m" +#define ANSI_BG_CYAN "\x1b[46m" +#define ANSI_BG_MAGENTA "\x1b[45m" +#define ANSI_BG_RED "\x1b[41m" +#define ANSI_BG_GREEN "\x1b[42m" +#define ANSI_BG_YELLOW "\x1b[43m" + +#define LOG(fmt, ...) \ + fprintf(stdout, fmt "\n", ##__VA_ARGS__) + +#define LOG_INFO(fmt, ...) \ + fprintf(stdout, ANSI_FG_WHITE ANSI_BG_CYAN " INFO " ANSI_RESET " " fmt "\n", ##__VA_ARGS__) + +#define LOG_PASS(fmt, ...) \ + fprintf(stdout, ANSI_FG_WHITE ANSI_BG_GREEN " PASS " ANSI_RESET " " fmt " (%s:%d)\n", ##__VA_ARGS__, __FILE__, __LINE__) + +#define LOG_WARN(fmt, ...) \ + fprintf(stderr, ANSI_FG_WHITE ANSI_BG_YELLOW " WARN " ANSI_RESET " " fmt "\n", ##__VA_ARGS__) + +#define LOG_ERROR(fmt, ...) \ + fprintf(stderr, ANSI_FG_WHITE ANSI_BG_RED " ERROR " ANSI_RESET " " fmt " (%s:%d)\n", ##__VA_ARGS__, __FILE__, __LINE__) + +#ifdef DEBUG +#define LOG_DEBUG(fmt, ...) \ + fprintf(stdout, ANSI_FG_WHITE ANSI_BG_MAGENTA " DEBUG " ANSI_RESET " " fmt "\n", ##__VA_ARGS__) +#else +#define LOG_DEBUG(fmt, ...) ((void)0) +#endif diff --git a/include/sdl.h b/include/sdl.h new file mode 100644 index 0000000..e73a903 --- /dev/null +++ b/include/sdl.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +#include + +SDL_Window* sdl_create_window(const char* title, int w, int h); +bool sdl_init(void); +void sdl_quit(void); -- cgit v1.2.3