1#define GF_EXPOSE_DRAW_PLATFORM
23void gf_draw_platform_begin(
void) {
25 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
26 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
27 glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
28 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
31void gf_draw_platform_end(
void) {}
33void gf_glfw_size(GLFWwindow* window,
int w,
int h) {
37 glfwSetWindowSize(window, w, h);
38 gf_draw_reshape(draw);
41void gf_glfw_button(GLFWwindow* window,
int button,
int action,
int mods) {
43 if(draw->
input != NULL) {
55void gf_glfw_cursor(GLFWwindow* window,
double x,
double y) {
57 if(draw->
input != NULL) {
63int gf_draw_platform_has_extension(
gf_draw_t* draw,
const char* query) {
64 const char* ext = NULL;
66 const int len = strlen(query);
68 glfwMakeContextCurrent(draw->
platform->window);
70 return glfwExtensionSupported(query);
73int gf_draw_platform_step(
gf_draw_t* draw) {
76 glfwMakeContextCurrent(draw->
platform->window);
78 if(draw->
close) glfwSetWindowShouldClose(draw->
platform->window, GLFW_FALSE);
81 gf_draw_driver_before(draw);
83 gf_draw_driver_after(draw);
85 glfwSwapBuffers(draw->
platform->window);
92 memset(platform, 0,
sizeof(*platform));
93 platform->engine = engine;
95 platform->window = glfwCreateWindow(draw->
width, draw->
height, draw->
title, NULL, NULL);
96 if(platform->window == NULL) {
98 gf_draw_platform_destroy(platform);
102 glfwSetWindowUserPointer(platform->window, draw);
103 glfwSetCursorPosCallback(platform->window, gf_glfw_cursor);
104 glfwSetWindowSizeCallback(platform->window, gf_glfw_size);
105 glfwSetMouseButtonCallback(platform->window, gf_glfw_button);
107 glfwMakeContextCurrent(platform->window);
108#ifdef DO_SWAP_INTERVAL
115 if(platform->window != NULL) {
116 glfwDestroyWindow(platform->window);
118 gf_log_function(platform->engine,
"Destroyed platform-dependent part of drawing driver",
"");
#define gf_log_function(engine, fmt,...)
Output log with line number and function name.
Required headers before anything.
gf_input_t * input
Input interface.
char title[128]
Window title.
int close
1 if it was requested to be closed, otherwise 0
gf_draw_platform_t * platform
Platform-dependent part of drawing driver.
int width
Width of window.
int height
Height of window.