window title

This commit is contained in:
Murphy 2023-04-24 00:24:23 -04:00
parent 0e1fc86d08
commit 06389e7a7e
3 changed files with 9 additions and 5 deletions

View file

@ -6,7 +6,7 @@
int main (void) {
Screen screen;
init_screen(&screen, 2160, 1440);
init_screen(&screen, 2160, 1440, "Raycaster");
Camera camera;
init_camera(&camera);
@ -14,6 +14,8 @@ int main (void) {
while (poll_screen(&screen)) {
render(&screen, &camera);
update_camera(&camera, &screen);
if(key_pressed(KEY_ESC)) break;
}
free_screen(&screen);

View file

@ -49,7 +49,7 @@ static void init_x() {
memset(key_checked, 0, sizeof(bool) * key_count);
}
static Window create_window(int x, int y, int w, int h, int d) {
static Window create_window(int x, int y, int w, int h, int d, const char* t) {
XVisualInfo vis_info;
if(!XMatchVisualInfo(dpy, scr, d, TrueColor, &vis_info)) {
@ -68,6 +68,8 @@ static Window create_window(int x, int y, int w, int h, int d) {
long wm = CWBackPixel | CWColormap | CWBorderPixel | CWEventMask;
Window window = XCreateWindow(dpy, root, x, y, w, h, 0, d, InputOutput, visual, wm, &xwa);
XStoreName(dpy, window, t);
XSetIconName(dpy, window, t);
return window;
}
@ -88,7 +90,7 @@ static XImage* create_image(int width, int height, void* data) {
}
void init_screen(struct Screen* screen, uint16_t width, uint16_t height) {
void init_screen(struct Screen* screen, uint16_t width, uint16_t height, const char* title) {
if (dpy == NULL) {
init_x();
@ -103,7 +105,7 @@ void init_screen(struct Screen* screen, uint16_t width, uint16_t height) {
screen->pixels = malloc(pixel_count * bit_depth / 8);
memset(screen->pixels, 0, pixel_count * bit_depth / 8);
Window window = create_window(0, 0, width, height, bit_depth);
Window window = create_window(0, 0, width, height, bit_depth, title);
XMapWindow(dpy, window);
Pixmap pixel_map = XCreatePixmap(dpy, window, width, height, bit_depth);

View file

@ -26,7 +26,7 @@ struct Screen {
#define KEY_EQUALS 13
#define KEY_ESC 1
void init_screen(Screen* screen, uint16_t width, uint16_t height);
void init_screen(Screen* screen, uint16_t width, uint16_t height, const char* title);
bool poll_screen(Screen* screen);
void free_screen(Screen* screen);