31 #include <glad/glad.h> 48 printf(
"Usage: monitors [-t]\n");
49 printf(
" monitors -h\n");
54 return b ?
euclid(b, a % b) :
a;
64 "%i x %i x %i (%i:%i) (%i %i %i) %i Hz",
71 buffer[
sizeof(
buffer) - 1] =
'\0';
77 fprintf(stderr,
"Error: %s\n", description);
82 printf(
"Framebuffer resized to %ix%i\n", width, height);
95 int count,
x,
y, width_mm, height_mm,
i;
104 printf(
"Name: %s (%s)\n",
108 printf(
"Virtual position: %i %i\n", x, y);
109 printf(
"Content scale: %f %f\n", xscale, yscale);
111 printf(
"Physical size: %i x %i mm (%0.2f dpi)\n",
112 width_mm, height_mm, mode->
width * 25.4f / width_mm);
116 for (i = 0; i <
count; i++)
118 printf(
"%3u: %s", (
unsigned int) i,
format_mode(modes + i));
120 if (memcmp(mode, modes + i,
sizeof(
GLFWvidmode)) == 0)
121 printf(
" (current mode)");
133 for (i = 0; i <
count; i++)
143 printf(
"Testing mode %u on monitor %s: %s\n",
154 printf(
"Failed to enter mode %u: %s\n",
177 printf(
"User terminated program\n");
194 printf(
"*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
201 printf(
"*** Size mismatch: %ix%i instead of %ix%i\n",
206 printf(
"Closing window\n");
215 int main(
int argc,
char** argv)
220 while ((ch =
getopt(argc, argv,
"th")) != -1)
243 for (i = 0; i <
count; i++)
GLboolean GLboolean GLboolean b
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
static void error_callback(int error, const char *description)
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 void list_modes(GLFWmonitor *monitor)
static GLFWwindow * window
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
struct GLFWmonitor GLFWmonitor
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
#define GLFW_REFRESH_RATE
Monitor refresh rate hint.
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow *window, GLFWframebuffersizefun cbfun)
Sets the framebuffer resize callback for the specified window.
int getopt(int argc, char *const argv[], const char *optstring)
GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor *monitor, float *xscale, float *yscale)
Retrieves the content scale for the specified monitor.
GLboolean GLboolean GLboolean GLboolean a
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
#define GLFW_RED_BITS
Framebuffer bit depth hint.
GLFWAPI GLFWmonitor ** glfwGetMonitors(int *count)
Returns the currently connected monitors.
GLFWAPI const char * glfwGetMonitorName(GLFWmonitor *monitor)
Returns the name of the specified monitor.
#define GL_COLOR_BUFFER_BIT
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
int main(int argc, char **argv)
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 GLFW_GREEN_BITS
Framebuffer bit depth hint.
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.
static int euclid(int a, int b)
GLFWAPI void glfwGetMonitorPos(GLFWmonitor *monitor, int *xpos, int *ypos)
Returns the position of the monitor's viewport on the virtual screen.
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
GLFWAPI const GLFWvidmode * glfwGetVideoModes(GLFWmonitor *monitor, int *count)
Returns the available video modes for the specified monitor.
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
static void framebuffer_size_callback(GLFWwindow *window, int width, int height)
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor *monitor, int *widthMM, int *heightMM)
Returns the physical size of the monitor.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
#define GLFW_BLUE_BITS
Framebuffer bit depth hint.
static void test_modes(GLFWmonitor *monitor)
static const char * format_mode(const GLFWvidmode *mode)
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.