31 #include <glad/glad.h> 34 #define NK_IMPLEMENTATION 35 #define NK_INCLUDE_FIXED_TYPES 36 #define NK_INCLUDE_FONT_BAKING 37 #define NK_INCLUDE_DEFAULT_FONT 38 #define NK_INCLUDE_DEFAULT_ALLOCATOR 39 #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT 40 #define NK_INCLUDE_STANDARD_VARARGS 43 #define NK_GLFW_GL2_IMPLEMENTATION 54 printf(
"Usage: inputlag [-h] [-f]\n");
56 printf(
" -f create full screen window\n");
57 printf(
" -h show this help\n");
70 cursor_new.x = (float) x;
71 cursor_new.y = (float) y;
76 cursor_pos = cursor_new;
81 cursor_new.x = (float) xpos;
82 cursor_new.y = (float) ypos;
109 GLint occlusion_result;
121 unsigned char rgba[4];
128 fprintf(stderr,
"Error: %s\n", description);
146 struct nk_color colors[4] = {
nk_rgb(255,0,0),
nk_rgb(255,255,0),
nk_rgb(0,255,0),
nk_rgb(0,96,255) };
147 struct nk_rect rect = { -5 + pos.
x, -5 + pos.
y, 10, 10 };
151 int main(
int argc,
char** argv)
154 unsigned long frame_count = 0;
161 struct nk_font_atlas* atlas;
165 while ((ch =
getopt(argc, argv,
"fh")) != -1)
234 area =
nk_rect(0.
f, 0.
f, (
float) width, (
float) height);
244 for (lead = show_forecasts ? 3 : 0; lead >= 0; lead--)
250 nk_label(nk,
"Move mouse uniformly and check marker under cursor:", align_left);
251 for (lead = 0; lead <= 3; lead++) {
258 nk_label(nk,
"- current cursor position (no input lag)", align_left);
260 nk_labelf(nk, align_left,
"- %d-frame forecast (input lag is %d frame)", lead, lead);
267 nk_label(nk,
"Input method:", align_left);
275 nk_value_float(nk,
"FPS", (
float) frame_rate);
281 nk_label(nk,
"After swap:", align_left);
296 if (current_time - last_time > 1.0)
298 frame_rate = frame_count / (current_time - last_time);
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
NK_API void nk_layout_row_end(struct nk_context *)
NK_API void nk_fill_circle(struct nk_command_buffer *, struct nk_rect, struct nk_color)
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
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.
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context *, struct nk_vec2)
int getopt(int argc, char *const argv[], const char *optstring)
NK_API void nk_glfw3_render(enum nk_anti_aliasing)
NK_API struct nk_color nk_rgb(int r, int g, int b)
#define GLFW_SCALE_TO_MONITOR
Window content area scaling window window hint.
GLboolean GLboolean GLboolean GLboolean a
NK_API struct nk_vec2 nk_vec2(float x, float y)
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
#define GL_COLOR_BUFFER_BIT
NK_API void nk_glfw3_new_frame(void)
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
NK_API struct nk_context * nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state)
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.
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
#define glGetQueryObjectiv
GLAPI int gladLoadGLLoader(GLADloadproc)
static const textual_icon exit
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.
NK_API int nk_option_label(struct nk_context *, const char *, int active)
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
NK_API void nk_glfw3_font_stash_end(void)
#define GL_SAMPLES_PASSED
NK_API void nk_glfw3_font_stash_begin(struct nk_font_atlas **atlas)
NK_API void nk_end(struct nk_context *ctx)
#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.
NK_API void nk_layout_row_push(struct nk_context *, float value)