1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00

Removed DOS line endings.

This commit is contained in:
Camilla Berglund 2010-10-04 18:19:04 +02:00
parent 99ddce3214
commit 5ca2189f81

View File

@ -1,110 +1,110 @@
//======================================================================== //========================================================================
// Fullscreen window (un)focus test // Fullscreen window (un)focus test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org> // Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
// //
// This software is provided 'as-is', without any express or implied // This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages // warranty. In no event will the authors be held liable for any damages
// arising from the use of this software. // arising from the use of this software.
// //
// Permission is granted to anyone to use this software for any purpose, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it // including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions: // freely, subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; you must not // 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software // claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would // in a product, an acknowledgment in the product documentation would
// be appreciated but is not required. // be appreciated but is not required.
// //
// 2. Altered source versions must be plainly marked as such, and must not // 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software. // be misrepresented as being the original software.
// //
// 3. This notice may not be removed or altered from any source // 3. This notice may not be removed or altered from any source
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// //
// This test is used to test window activation and iconfication for // This test is used to test window activation and iconfication for
// fullscreen windows with a video mode differing from the desktop mode // fullscreen windows with a video mode differing from the desktop mode
// //
//======================================================================== //========================================================================
#include <GL/glfw3.h> #include <GL/glfw3.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static GLboolean running = GL_TRUE; static GLboolean running = GL_TRUE;
static void window_focus_callback(GLFWwindow window, int activated) static void window_focus_callback(GLFWwindow window, int activated)
{ {
printf("%0.3f: Window %s\n", printf("%0.3f: Window %s\n",
glfwGetTime(), glfwGetTime(),
activated ? "activated" : "deactivated"); activated ? "activated" : "deactivated");
} }
static void window_key_callback(GLFWwindow window, int key, int action) static void window_key_callback(GLFWwindow window, int key, int action)
{ {
if (action != GLFW_PRESS) if (action != GLFW_PRESS)
return; return;
switch (key) switch (key)
{ {
case GLFW_KEY_ESC: case GLFW_KEY_ESC:
{ {
printf("%0.3f: User pressed Escape\n", glfwGetTime()); printf("%0.3f: User pressed Escape\n", glfwGetTime());
running = GL_FALSE; running = GL_FALSE;
break; break;
} }
case GLFW_KEY_SPACE: case GLFW_KEY_SPACE:
{ {
printf("%0.3f: User pressed Space\n", glfwGetTime()); printf("%0.3f: User pressed Space\n", glfwGetTime());
glfwIconifyWindow(window); glfwIconifyWindow(window);
break; break;
} }
} }
} }
static int window_close_callback(GLFWwindow window) static int window_close_callback(GLFWwindow window)
{ {
printf("%0.3f: User closed window\n", glfwGetTime()); printf("%0.3f: User closed window\n", glfwGetTime());
return GL_TRUE; return GL_TRUE;
} }
int main(void) int main(void)
{ {
GLFWwindow window; GLFWwindow window;
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
window = glfwOpenWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL); window = glfwOpenWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSwapInterval(1); glfwSwapInterval(1);
glfwEnable(window, GLFW_MOUSE_CURSOR); glfwEnable(window, GLFW_MOUSE_CURSOR);
glfwSetWindowFocusCallback(window, window_focus_callback); glfwSetWindowFocusCallback(window, window_focus_callback);
glfwSetKeyCallback(window, window_key_callback); glfwSetKeyCallback(window, window_key_callback);
glfwSetWindowCloseCallback(window, window_close_callback); glfwSetWindowCloseCallback(window, window_close_callback);
while (running && glfwIsWindow(window) == GL_TRUE) while (running && glfwIsWindow(window) == GL_TRUE)
{ {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers();
glfwWaitEvents(); glfwWaitEvents();
} }
glfwTerminate(); glfwTerminate();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }