31 #include <glad/glad.h> 54 "attribute vec2 vPos;\n" 57 " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" 64 " gl_FragColor = vec4(1.0);\n" 75 snprintf(title,
sizeof(title),
"Tearing detector (interval %i%s, %0.1f Hz)",
92 fprintf(stderr,
"Error: %s\n", description);
154 int main(
int argc,
char** argv)
156 unsigned long frame_count = 0;
159 GLuint vertex_buffer, vertex_shader, fragment_shader,
program;
160 GLint mvp_location, vpos_location;
216 float position = cosf((
float)
glfwGetTime() * 4.
f) * 0.75f;
237 if (current_time - last_time > 1.0)
239 frame_rate = frame_count / (current_time - last_time);
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
static void update_window_title(GLFWwindow *window)
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
GLFWAPI void glfwSetWindowTitle(GLFWwindow *window, const char *title)
Sets the title of the specified window.
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 mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f)
#define glGetAttribLocation
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.
#define glUniformMatrix4fv
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
#define glVertexAttribPointer
static void mat4x4_translate(mat4x4 T, float x, float y, float z)
#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.
static const char * vertex_shader_text
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
static const struct @55 vertices[4]
#define glGetUniformLocation
#define GL_FRAGMENT_SHADER
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
GLAPI int gladLoadGLLoader(GLADloadproc)
GLFWAPI GLFWmonitor * glfwGetWindowMonitor(GLFWwindow *window)
Returns the monitor that the window uses for full screen mode.
static const textual_icon exit
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
GLFWAPI void glfwSetWindowMonitor(GLFWwindow *window, GLFWmonitor *monitor, int xpos, int ypos, int width, int height, int refreshRate)
Sets the mode, monitor, video mode and placement of a window.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
static void error_callback(int error, const char *description)
GLFWAPI void glfwGetWindowPos(GLFWwindow *window, int *xpos, int *ypos)
Retrieves the position of the client area of the specified window.
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
static void set_swap_interval(GLFWwindow *window, int interval)
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
static void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
GLFWAPI int glfwExtensionSupported(const char *extension)
Returns whether the specified extension is available.
int main(int argc, char **argv)
#define GLFW_CONTEXT_VERSION_MINOR
Context client API minor version hint and attribute.
static const char * fragment_shader_text
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.