| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -34,8 +34,7 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#include <stdio.h> | 
					 | 
					 | 
					 | 
					#include <stdio.h> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#include <stdlib.h> | 
					 | 
					 | 
					 | 
					#include <stdlib.h> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#include "getopt.h" | 
					 | 
					 | 
					 | 
					static GLFWwindow* windows[4]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static const char* titles[] = | 
					 | 
					 | 
					 | 
					static const char* titles[] = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{ | 
					 | 
					 | 
					 | 
					{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    "Red", | 
					 | 
					 | 
					 | 
					    "Red", | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -55,18 +54,24 @@ static const struct | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { 0.98f, 0.74f, 0.04f } | 
					 | 
					 | 
					 | 
					    { 0.98f, 0.74f, 0.04f } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}; | 
					 | 
					 | 
					 | 
					}; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static void usage(void) | 
					 | 
					 | 
					 | 
					static void error_callback(int error, const char* description) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{ | 
					 | 
					 | 
					 | 
					{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf("Usage: windows [-h] [-b] [-f] \n"); | 
					 | 
					 | 
					 | 
					    fprintf(stderr, "Error: %s\n", description); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf("Options:\n"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf("  -b create decorated windows\n"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf("  -f set focus on show off for all but first window\n"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    printf("  -h show this help\n"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static void error_callback(int error, const char* description) | 
					 | 
					 | 
					 | 
					static void arrange_windows(void) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{ | 
					 | 
					 | 
					 | 
					{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fprintf(stderr, "Error: %s\n", description); | 
					 | 
					 | 
					 | 
					    int xbase, ybase; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    glfwGetWindowPos(windows[0], &xbase, &ybase); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    for (int i = 0;  i < 4;  i++) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        int left, top, right, bottom; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        glfwSetWindowPos(windows[i], | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                         xbase + (i & 1) * (200 + left + right), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                         ybase + (i >> 1) * (200 + top + bottom)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) | 
					 | 
					 | 
					 | 
					static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -87,49 +92,34 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        case GLFW_KEY_ESCAPE: | 
					 | 
					 | 
					 | 
					        case GLFW_KEY_ESCAPE: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            glfwSetWindowShouldClose(window, GLFW_TRUE); | 
					 | 
					 | 
					 | 
					            glfwSetWindowShouldClose(window, GLFW_TRUE); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            break; | 
					 | 
					 | 
					 | 
					            break; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int main(int argc, char** argv) | 
					 | 
					 | 
					 | 
					        case GLFW_KEY_D: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        { | 
					 | 
					 | 
					 | 
					        { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int i, ch; | 
					 | 
					 | 
					 | 
					            for (int i = 0;  i < 4;  i++) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int decorated = GLFW_FALSE; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int focusOnShow = GLFW_TRUE; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    int running = GLFW_TRUE; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    GLFWwindow* windows[4]; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    while ((ch = getopt(argc, argv, "bfh")) != -1) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        switch (ch) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            { | 
					 | 
					 | 
					 | 
					            { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            case 'b': | 
					 | 
					 | 
					 | 
					                const int decorated = glfwGetWindowAttrib(windows[i], GLFW_DECORATED); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                decorated = GLFW_TRUE; | 
					 | 
					 | 
					 | 
					                glfwSetWindowAttrib(windows[i], GLFW_DECORATED, !decorated); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                break; | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            case 'f': | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                focusOnShow = GLFW_FALSE; | 
					 | 
					 | 
					 | 
					            arrange_windows(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            break; | 
					 | 
					 | 
					 | 
					            break; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            case 'h': | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                usage(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                exit(EXIT_SUCCESS); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            default: | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                usage(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                exit(EXIT_FAILURE); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					int main(int argc, char** argv) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glfwSetErrorCallback(error_callback); | 
					 | 
					 | 
					 | 
					    glfwSetErrorCallback(error_callback); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (!glfwInit()) | 
					 | 
					 | 
					 | 
					    if (!glfwInit()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        exit(EXIT_FAILURE); | 
					 | 
					 | 
					 | 
					        exit(EXIT_FAILURE); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_DECORATED, decorated); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); | 
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (i = 0;  i < 4;  i++) | 
					 | 
					 | 
					 | 
					    for (int i = 0;  i < 4;  i++) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int left, top, right, bottom; | 
					 | 
					 | 
					 | 
					        if (i > 0) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (i) | 
					 | 
					 | 
					 | 
					            glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            glfwWindowHint(GLFW_FOCUS_ON_SHOW, focusOnShow); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); | 
					 | 
					 | 
					 | 
					        windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!windows[i]) | 
					 | 
					 | 
					 | 
					        if (!windows[i]) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -143,32 +133,29 @@ int main(int argc, char** argv) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glfwMakeContextCurrent(windows[i]); | 
					 | 
					 | 
					 | 
					        glfwMakeContextCurrent(windows[i]); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        gladLoadGL(glfwGetProcAddress); | 
					 | 
					 | 
					 | 
					        gladLoadGL(glfwGetProcAddress); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f); | 
					 | 
					 | 
					 | 
					        glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glfwSetWindowPos(windows[i], | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                         100 + (i & 1) * (200 + left + right), | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                         100 + (i >> 1) * (200 + top + bottom)); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (i = 0;  i < 4;  i++) | 
					 | 
					 | 
					 | 
					    arrange_windows(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    for (int i = 0;  i < 4;  i++) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glfwShowWindow(windows[i]); | 
					 | 
					 | 
					 | 
					        glfwShowWindow(windows[i]); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    while (running) | 
					 | 
					 | 
					 | 
					    for (;;) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for (i = 0;  i < 4;  i++) | 
					 | 
					 | 
					 | 
					        for (int i = 0;  i < 4;  i++) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        { | 
					 | 
					 | 
					 | 
					        { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            glfwMakeContextCurrent(windows[i]); | 
					 | 
					 | 
					 | 
					            glfwMakeContextCurrent(windows[i]); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            glClear(GL_COLOR_BUFFER_BIT); | 
					 | 
					 | 
					 | 
					            glClear(GL_COLOR_BUFFER_BIT); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            glfwSwapBuffers(windows[i]); | 
					 | 
					 | 
					 | 
					            glfwSwapBuffers(windows[i]); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (glfwWindowShouldClose(windows[i])) | 
					 | 
					 | 
					 | 
					            if (glfwWindowShouldClose(windows[i])) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                running = GLFW_FALSE; | 
					 | 
					 | 
					 | 
					            { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                glfwTerminate(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                exit(EXIT_SUCCESS); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glfwWaitEvents(); | 
					 | 
					 | 
					 | 
					        glfwWaitEvents(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glfwTerminate(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    exit(EXIT_SUCCESS); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
  |