| 1 | /* |
| 2 | * C helper for loading OpenGL functions via GLAD and GLFW. |
| 3 | * This simplifies the Fortran binding since we can't easily pass |
| 4 | * glfwGetProcAddress as a function pointer from Fortran. |
| 5 | * |
| 6 | * Also provides wrapper functions for OpenGL calls, since GLAD uses |
| 7 | * function pointers that can't be directly called from Fortran bindings. |
| 8 | */ |
| 9 | |
| 10 | #include <glad/gl.h> |
| 11 | #include <GLFW/glfw3.h> |
| 12 | |
| 13 | /* Load OpenGL functions using GLFW's loader */ |
| 14 | int fortty_load_gl(void) { |
| 15 | return gladLoadGL((GLADloadfunc) glfwGetProcAddress); |
| 16 | } |
| 17 | |
| 18 | /* OpenGL wrapper functions for Fortran */ |
| 19 | void fortty_glViewport(int x, int y, int width, int height) { |
| 20 | glViewport(x, y, width, height); |
| 21 | } |
| 22 | |
| 23 | void fortty_glClear(unsigned int mask) { |
| 24 | glClear(mask); |
| 25 | } |
| 26 | |
| 27 | void fortty_glClearColor(float red, float green, float blue, float alpha) { |
| 28 | glClearColor(red, green, blue, alpha); |
| 29 | } |