36 #include <glad/glad.h> 48 "attribute vec2 vPos;\n" 51 " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" 58 " gl_FragColor = vec4(1.0);\n" 71 fprintf(stderr,
"Error: %s\n", description);
76 printf(
"Close callback triggered\n");
97 printf(
"Closing window took %0.3f seconds\n",
glfwGetTime() - base);
100 int main(
int argc,
char** argv)
106 srand((
unsigned int) time(
NULL));
120 GLuint vertex_shader, fragment_shader,
program, vertex_buffer;
121 GLint mvp_location, vpos_location;
127 monitor = monitors[rand() % monitorCount];
153 printf(
"Opening full screen window on monitor %s took %0.3f seconds\n",
159 printf(
"Opening regular window took %0.3f seconds\n",
203 ratio = width / (float) height;
224 printf(
"User closed window\n");
231 printf(
"Closing window\n");
static const char * vertex_shader_text
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
static void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f)
#define glGetAttribLocation
static void mat4x4_identity(mat4x4 M)
void *(* GLADloadproc)(const char *name)
static GLFWwindow * window
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
#define GLFW_CONTEXT_VERSION_MAJOR
Context client API major version hint and attribute.
struct GLFWmonitor GLFWmonitor
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
static void close_window(GLFWwindow *window)
#define glUniformMatrix4fv
static void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
static const char * fragment_shader_text
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
#define glVertexAttribPointer
GLFWAPI GLFWmonitor ** glfwGetMonitors(int *count)
Returns the currently connected monitors.
int main(int argc, char **argv)
GLFWAPI const char * glfwGetMonitorName(GLFWmonitor *monitor)
Returns the name of the specified monitor.
#define glEnableVertexAttribArray
#define GL_COLOR_BUFFER_BIT
GLbitfield GLuint program
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
GLint GLsizei GLsizei height
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
#define glGetUniformLocation
#define GL_FRAGMENT_SHADER
GLAPI int gladLoadGLLoader(GLADloadproc)
static const textual_icon exit
static void window_close_callback(GLFWwindow *window)
static void error_callback(int error, const char *description)
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow *window, GLFWwindowclosefun cbfun)
Sets the close callback for the specified window.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
static void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
static const vec2 vertices[4]
#define GLFW_CONTEXT_VERSION_MINOR
Context client API minor version hint and attribute.
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.