1#define GF_EXPOSE_DRAW_PLATFORM
21void gf_draw_platform_begin(
void) {
23 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
24 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
25 glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
26 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
29void gf_draw_platform_end(
void) {}
31void gf_glfw_size(GLFWwindow* window,
int w,
int h) {
35 glfwSetWindowSize(window, w, h);
36 gf_draw_reshape(draw);
39int gf_draw_platform_has_extension(
gf_draw_t* draw,
const char* query) {
40 const char* ext = NULL;
42 const int len = strlen(query);
44 glfwMakeContextCurrent(draw->
platform->window);
46 return glfwExtensionSupported(query);
49int gf_draw_platform_step(
gf_draw_t* draw) {
52 glfwMakeContextCurrent(draw->
platform->window);
54 if(draw->
close) glfwSetWindowShouldClose(draw->
platform->window, GLFW_FALSE);
57 gf_draw_driver_before(draw);
59 gf_draw_driver_after(draw);
61 glfwSwapBuffers(draw->
platform->window);
68 memset(platform, 0,
sizeof(*platform));
69 platform->engine = engine;
71 platform->window = glfwCreateWindow(draw->
width, draw->
height, draw->
title, NULL, NULL);
72 if(platform->window == NULL) {
74 gf_draw_platform_destroy(platform);
78 glfwSetWindowUserPointer(platform->window, draw);
79 glfwSetWindowSizeCallback(platform->window, gf_glfw_size);
81 glfwMakeContextCurrent(platform->window);
82#ifdef DO_SWAP_INTERVAL
89 if(platform->window != NULL) {
90 glfwDestroyWindow(platform->window);
92 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.
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.