Begun integrating monitor and window.

This commit is contained in:
Camilla Berglund
2012-09-27 21:37:36 +02:00
parent 7aaeb6955b
commit 1be1636326
32 changed files with 106 additions and 112 deletions

View File

@@ -90,7 +90,7 @@ int main(void)
glfwSetWindowSizeCallback(window_size_callback);
glfwSetKeyCallback(key_callback);
window = glfwCreateWindow(window_width, window_height, GLFW_WINDOWED, "", NULL);
window = glfwCreateWindow(window_width, window_height, "", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -125,7 +125,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL);
window = glfwCreateWindow(0, 0, "Clipboard Test", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -85,7 +85,7 @@ int main(void)
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL);
window = glfwCreateWindow(0, 0, "Defaults", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -399,7 +399,7 @@ int main(void)
glfwSetCharCallback(char_callback);
glfwSetMonitorCallback(monitor_callback);
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL);
window = glfwCreateWindow(0, 0, "Event Linter", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -98,7 +98,7 @@ int main(int argc, char** argv)
glfwWindowHint(GLFW_FSAA_SAMPLES, samples);
window = glfwCreateWindow(800, 400, GLFW_WINDOWED, "Aliasing Detector", NULL);
window = glfwCreateWindow(800, 400, "Aliasing Detector", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -82,7 +82,7 @@ int main(void)
exit(EXIT_FAILURE);
}
window = glfwCreateWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL);
window = glfwCreateWindow(640, 480, "Fullscreen focus", glfwGetPrimaryMonitor(), NULL);
if (!window)
{
glfwTerminate();

View File

@@ -97,7 +97,7 @@ static void size_callback(GLFWwindow window, int width, int height)
int main(int argc, char** argv)
{
int width, height, ch;
int mode = GLFW_WINDOWED;
GLFWmonitor monitor = NULL;
GLFWwindow window;
while ((ch = getopt(argc, argv, "fh")) != -1)
@@ -109,7 +109,7 @@ int main(int argc, char** argv)
exit(EXIT_SUCCESS);
case 'f':
mode = GLFW_FULLSCREEN;
monitor = glfwGetPrimaryMonitor();
break;
default:
@@ -124,10 +124,10 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
if (mode == GLFW_FULLSCREEN)
if (monitor)
{
GLFWvidmode mode;
glfwGetVideoMode(glfwGetPrimaryMonitor(), &mode);
glfwGetVideoMode(monitor, &mode);
width = mode.width;
height = mode.height;
}
@@ -137,7 +137,7 @@ int main(int argc, char** argv)
height = 0;
}
window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL);
window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -243,7 +243,7 @@ int main(int argc, char** argv)
// We assume here that we stand a better chance of success by leaving all
// possible details of pixel format selection to GLFW
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL);
window = glfwCreateWindow(0, 0, "Version", NULL, NULL);
if (!window)
exit(EXIT_FAILURE);

View File

@@ -78,8 +78,8 @@ static void window_size_callback(GLFWwindow window, int width, int height)
int main(int argc, char** argv)
{
int width, height, ch;
int mode = GLFW_WINDOWED;
GLboolean active = -1, iconified = -1;
GLFWmonitor monitor = NULL;
GLFWwindow window;
while ((ch = getopt(argc, argv, "fh")) != -1)
@@ -91,7 +91,7 @@ int main(int argc, char** argv)
exit(EXIT_SUCCESS);
case 'f':
mode = GLFW_FULLSCREEN;
monitor = glfwGetPrimaryMonitor();
break;
default:
@@ -106,12 +106,12 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
if (mode == GLFW_FULLSCREEN)
if (monitor)
{
GLFWvidmode current_mode;
glfwGetVideoMode(glfwGetPrimaryMonitor(), &current_mode);
width = current_mode.width;
height = current_mode.height;
GLFWvidmode mode;
glfwGetVideoMode(monitor, &mode);
width = mode.width;
height = mode.height;
}
else
{
@@ -119,7 +119,7 @@ int main(int argc, char** argv)
height = 0;
}
window = glfwCreateWindow(width, height, mode, "Iconify", NULL);
window = glfwCreateWindow(width, height, "Iconify", monitor, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -186,7 +186,7 @@ int main(void)
exit(EXIT_FAILURE);
}
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Joystick Test", NULL);
window = glfwCreateWindow(0, 0, "Joystick Test", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -144,7 +144,8 @@ static void test_modes(GLFWmonitor monitor)
format_mode(mode));
window_handle = glfwCreateWindow(mode->width, mode->height,
GLFW_FULLSCREEN, "Video Mode Test",
"Video Mode Test",
glfwGetPrimaryMonitor(),
NULL);
if (!window_handle)
{

View File

@@ -92,7 +92,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
static GLboolean open_window(void)
{
window_handle = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL);
window_handle = glfwCreateWindow(0, 0, "Peter Detector", NULL, NULL);
if (!window_handle)
return GL_FALSE;

View File

@@ -41,19 +41,6 @@
static GLFWwindow window_handle = NULL;
static GLboolean closed = GL_FALSE;
static const char* get_mode_name(int mode)
{
switch (mode)
{
case GLFW_WINDOWED:
return "windowed";
case GLFW_FULLSCREEN:
return "fullscreen";
default:
return "unknown";
}
}
static void window_size_callback(GLFWwindow window, int width, int height)
{
glViewport(0, 0, width, height);
@@ -80,22 +67,18 @@ static void key_callback(GLFWwindow window, int key, int action)
}
}
static GLboolean open_window(int width, int height, int mode)
static GLboolean open_window(int width, int height, GLFWmonitor monitor)
{
double base;
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
return GL_FALSE;
}
base = glfwGetTime();
window_handle = glfwCreateWindow(width, height, mode, "Window Re-opener", NULL);
window_handle = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL);
if (!window_handle)
{
fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", get_mode_name(mode), glfwErrorString(glfwGetError()));
fprintf(stderr, "Failed to open %s mode GLFW window: %s\n",
monitor ? "fullscreen" : "windowed",
glfwErrorString(glfwGetError()));
return GL_FALSE;
}
@@ -107,7 +90,7 @@ static GLboolean open_window(int width, int height, int mode)
glfwSetKeyCallback(key_callback);
printf("Opening %s mode window took %0.3f seconds\n",
get_mode_name(mode),
monitor ? "fullscreen" : "windowed",
glfwGetTime() - base);
return GL_TRUE;
@@ -121,17 +104,26 @@ static void close_window(void)
window_handle = NULL;
printf("Closing window took %0.3f seconds\n", glfwGetTime() - base);
glfwTerminate();
}
int main(int argc, char** argv)
{
int count = 0;
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
return GL_FALSE;
}
for (;;)
{
if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED))
GLFWmonitor monitor = NULL;
if (count & 1)
monitor = glfwGetPrimaryMonitor();
if (!open_window(640, 480, monitor))
exit(EXIT_FAILURE);
glMatrixMode(GL_PROJECTION);

View File

@@ -55,7 +55,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share)
{
GLFWwindow window;
window = glfwCreateWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share);
window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share);
if (!window)
return NULL;

View File

@@ -70,7 +70,7 @@ int main(void)
exit(EXIT_FAILURE);
}
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL);
window = glfwCreateWindow(0, 0, "", NULL, NULL);
if (!window)
{
glfwTerminate();

View File

@@ -90,9 +90,8 @@ int main(void)
for (i = 0; i < count; i++)
{
threads[i].window = glfwCreateWindow(200, 200,
GLFW_WINDOWED,
threads[i].title,
NULL);
NULL, NULL);
if (!threads[i].window)
{
fprintf(stderr, "Failed to open GLFW window: %s\n",

View File

@@ -47,7 +47,7 @@ int main(void)
exit(EXIT_FAILURE);
}
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL);
window = glfwCreateWindow(0, 0, "English 日本語 русский язык 官話", NULL, NULL);
if (!window)
{
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));

View File

@@ -55,7 +55,7 @@ int main(void)
for (i = 0; i < 4; i++)
{
windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL);
if (!windows[i])
{
fprintf(stderr, "Failed to open GLFW window: %s\n",