31 #include <glad/glad.h> 43 printf(
"Usage: iconify [-h] [-f [-a] [-n]]\n");
45 printf(
" -a create windows for all monitors\n");
46 printf(
" -f create full screen window(s)\n");
47 printf(
" -h show this help\n");
52 fprintf(stderr,
"Error: %s\n", description);
57 printf(
"%0.2f Key %s\n",
59 action ==
GLFW_PRESS ?
"pressed" :
"released");
124 printf(
"%0.2f Window resized to %ix%i\n",
glfwGetTime(), width, height);
129 printf(
"%0.2f Framebuffer resized to %ix%i\n",
glfwGetTime(), width, height);
134 printf(
"%0.2f Window %s\n",
136 focused ?
"focused" :
"defocused");
141 printf(
"%0.2f Window %s\n",
143 iconified ?
"iconified" :
"uniconified");
148 printf(
"%0.2f Window %s\n",
150 maximized ?
"maximized" :
"unmaximized");
199 int main(
int argc,
char** argv)
201 int ch,
i, window_count;
205 while ((ch =
getopt(argc, argv,
"afhn")) != -1)
232 if (fullscreen && all_monitors)
237 window_count = monitor_count;
238 windows = calloc(window_count,
sizeof(
GLFWwindow*));
240 for (i = 0; i < monitor_count; i++)
255 windows = calloc(window_count,
sizeof(
GLFWwindow*));
259 for (i = 0; i < window_count; i++)
271 printf(
"Window is %s and %s\n",
280 for (i = 0; i < window_count; i++)
286 if (i < window_count)
static void window_focus_callback(GLFWwindow *window, int focused)
#define GLFW_AUTO_ICONIFY
Window auto-iconification window hint and attribute.
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)
GLFWAPI int glfwGetWindowAttrib(GLFWwindow *window, int attrib)
Returns an attribute of the specified window.
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow *window, GLFWwindowsizefun cbfun)
Sets the size callback for 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 window_refresh_callback(GLFWwindow *window)
static GLFWwindow * create_window(GLFWmonitor *monitor)
void *(* GLADloadproc)(const char *name)
static GLFWwindow * window
GLFWAPI void glfwSetWindowAttrib(GLFWwindow *window, int attrib, int value)
Sets an attribute of the specified window.
#define GLFW_ICONIFIED
Window iconification window attribute.
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
static void window_size_callback(GLFWwindow *window, int width, int height)
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.
static int windowed_height
int getopt(int argc, char *const argv[], const char *optstring)
static void window_maximize_callback(GLFWwindow *window, int maximized)
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow *window, GLFWwindowiconifyfun cbfun)
Sets the iconify callback for the specified window.
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.
#define GLFW_FLOATING
Window decoration window hint and attribute.
#define GL_COLOR_BUFFER_BIT
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow *window, GLFWwindowrefreshfun cbfun)
Sets the refresh callback for the specified window.
static int windowed_width
GLFWAPI void glfwIconifyWindow(GLFWwindow *window)
Iconifies the specified window.
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.
GLFWAPI void glfwMaximizeWindow(GLFWwindow *window)
Maximizes the specified window.
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow *window, GLFWwindowfocusfun cbfun)
Sets the focus callback for the specified window.
#define GLFW_GREEN_BITS
Framebuffer bit depth hint.
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
#define GLFW_RESIZABLE
Window resize-ability window hint and attribute.
GLAPI int gladLoadGLLoader(GLADloadproc)
GLFWAPI GLFWmonitor * glfwGetWindowMonitor(GLFWwindow *window)
Returns the monitor that the window uses for full screen mode.
static void window_iconify_callback(GLFWwindow *window, int iconified)
static const textual_icon exit
#define GLFW_FOCUSED
Input focus window hint and attribute.
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
GLFWAPI void glfwWaitEvents(void)
Waits until events are queued and processes them.
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.
GLFWAPI void glfwGetWindowPos(GLFWwindow *window, int *xpos, int *ypos)
Retrieves the position of the client area of the specified window.
int main(int argc, char **argv)
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
static const char * maximized
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
#define GLFW_BLUE_BITS
Framebuffer bit depth hint.
#define GLFW_DECORATED
Window decoration window hint and attribute.
GLFWAPI void glfwRestoreWindow(GLFWwindow *window)
Restores the specified window.
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
static void framebuffer_size_callback(GLFWwindow *window, int width, int height)
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow *window, GLFWwindowmaximizefun cbfun)
Sets the maximize callback for the specified window.
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.