aboutsummaryrefslogtreecommitdiff
path: root/include/mgl/window/window.h
blob: b30583ba76fb92103eedd6c56c291ea6e7bdf84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef MGL_WINDOW_H
#define MGL_WINDOW_H

#include "../graphics/color.h"
#include "../system/vec.h"
#include <stdbool.h>

typedef struct __GLXcontextRec *GLXContext;
typedef struct mgl_event mgl_event;
/* x11 window handle. TODO: Add others when wayland, etc is added */
typedef unsigned long mgl_window_handle;

typedef struct mgl_window mgl_window;

struct mgl_window {
    mgl_window_handle window;
    GLXContext glx_context;
    mgl_vec2i size;
    mgl_vec2i cursor_position;
};

int mgl_window_create(mgl_window *self, const char *title, int width, int height);
/* if |parent_window| is 0 then the root window is used */
int mgl_window_create_with_params(mgl_window *self, const char *title, int width, int height, mgl_window_handle parent_window);
int mgl_window_init_from_existing_window(mgl_window *self, mgl_window_handle existing_window);
void mgl_window_deinit(mgl_window *self);

void mgl_window_clear(mgl_window *self, mgl_color color);
bool mgl_window_poll_event(mgl_window *self, mgl_event *event);
void mgl_window_display(mgl_window *self);

#endif /* MGL_WINDOW_H */