aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/gl/gl.c22
-rw-r--r--platform/x11/x11.c12
2 files changed, 17 insertions, 17 deletions
diff --git a/platform/gl/gl.c b/platform/gl/gl.c
index acfa0c5..30ea49d 100644
--- a/platform/gl/gl.c
+++ b/platform/gl/gl.c
@@ -36,16 +36,16 @@ static char frag[] =
"}\n"
;
-struct gl_platform {
+typedef struct {
GLFWwindow *win;
GLuint vao;
GLuint vbo;
GLuint program;
GLint uniform_tex_loc;
GLuint screen_handle;
-};
+} Gl_Platform;
-struct gl_platform p;
+Gl_Platform p;
static
GLuint compile_shader(GLenum type, const char *src)
@@ -65,7 +65,7 @@ GLuint compile_shader(GLenum type, const char *src)
return shader;
}
-void ty_platform_init(struct ty_ctx *ctx)
+void ty_platform_init(ty_Ctx *ctx)
{
ty_log_info("initializing GLFW...");
if (glfwInit() < 0)
@@ -92,7 +92,7 @@ void ty_platform_init(struct ty_ctx *ctx)
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
ty_log_fatal(TY_PLATFORM_ERR, "could not init GLAD");
- struct ty_vec2 vertices[] = {
+ ty_Vec2 vertices[] = {
ty_vec2(-1, -1), ty_vec2(0, 1),
ty_vec2( 1, -1), ty_vec2(1, 1),
ty_vec2( 1, 1), ty_vec2(1, 0),
@@ -119,14 +119,14 @@ void ty_platform_init(struct ty_ctx *ctx)
0,
2, GL_FLOAT,
GL_FALSE,
- sizeof(struct ty_vec2) * 2, (void*)0
+ sizeof(ty_Vec2) * 2, (void*)0
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(
1,
2, GL_FLOAT,
GL_FALSE,
- sizeof(struct ty_vec2) * 2, (void*)sizeof(struct ty_vec2)
+ sizeof(ty_Vec2) * 2, (void*)sizeof(ty_Vec2)
);
glEnableVertexAttribArray(1);
@@ -167,7 +167,7 @@ void ty_platform_deinit(void)
glfwTerminate();
}
-void ty_platform_frame(struct ty_image img)
+void ty_platform_frame(ty_Image img)
{
glfwPollEvents();
@@ -216,7 +216,7 @@ double ty_platform_get_time(void)
return glfwGetTime();
}
-struct ty_vec2i ty_platform_get_mouse(void)
+ty_Vec2i ty_platform_get_mouse(void)
{
double x, y;
glfwGetCursorPos(p.win, &x, &y);
@@ -224,7 +224,7 @@ struct ty_vec2i ty_platform_get_mouse(void)
}
static
-int button_to_glfw_key(enum ty_button btn)
+int button_to_glfw_key(ty_Button btn)
{
switch (btn) {
case TY_BTN_LEFT_UP: return GLFW_KEY_W;
@@ -245,7 +245,7 @@ int button_to_glfw_key(enum ty_button btn)
return 0;
}
-bool ty_platform_is_button_down(enum ty_button btn)
+bool ty_platform_is_button_down(ty_Button btn)
{
return glfwGetKey(p.win, button_to_glfw_key(btn)) == GLFW_PRESS;
}
diff --git a/platform/x11/x11.c b/platform/x11/x11.c
index 2dde168..ad85677 100644
--- a/platform/x11/x11.c
+++ b/platform/x11/x11.c
@@ -17,7 +17,7 @@
#define SEC2NANO ((uint64_t)1000000000)
-struct x11_platform {
+typedef struct {
Display *dis;
Window root;
Window win;
@@ -28,9 +28,9 @@ struct x11_platform {
bool should_close;
uint64_t initial_time;
-};
+} X11_Platform;
-struct x11_platform p;
+X11_Platform p;
static
int err_handler(Display *dis, XErrorEvent *ev)
@@ -46,7 +46,7 @@ int err_handler(Display *dis, XErrorEvent *ev)
return 0;
}
-void ty_platform_init(struct ty_ctx *ctx)
+void ty_platform_init(ty_Ctx *ctx)
{
XSetErrorHandler(err_handler);
@@ -101,7 +101,7 @@ void ty_platform_deinit(void)
}
static
-void display_image(struct ty_image img)
+void display_image(ty_Image img)
{
size_t size = img.width * img.height;
// Don't use ty_alloc cause it will be owned and freed by Xlib
@@ -157,7 +157,7 @@ void handle_client_msg(XEvent ev)
p.should_close = true;
}
-void ty_platform_frame(struct ty_image img)
+void ty_platform_frame(ty_Image img)
{
XPending(p.dis);