aboutsummaryrefslogtreecommitdiff
path: root/3rdparty/glfw/source/tests/timeout.c
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2025-08-16 11:23:49 -0700
committerrtk0c <[email protected]>2025-08-16 11:23:49 -0700
commit047f294de1b4d385b811ac9f5afc393d81cc4ae9 (patch)
treef96100a813a4ffb28dcd074455d3a2f8ee426430 /3rdparty/glfw/source/tests/timeout.c
parent488fb8b4b9da7f99a5cc37e39fff9f1cb700f2a8 (diff)
Copy changes from the no-history fork, generated back in 2023
Original commit message: > commit f138311d2d2e0cc9ba0496d523bb46f2c1c9fb73 > Author: rtk0c <[email protected]> > Date: Wed Sep 20 23:58:58 2023 -0700 > > Copy from the PlasticSCM repo, replace vendored glm wtih conan In reality, this also introduced a few uncommitted changes in the original PlasticSCM repo. See the modified and new files in this patch.
Diffstat (limited to '3rdparty/glfw/source/tests/timeout.c')
-rw-r--r--3rdparty/glfw/source/tests/timeout.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/3rdparty/glfw/source/tests/timeout.c b/3rdparty/glfw/source/tests/timeout.c
deleted file mode 100644
index c273746..0000000
--- a/3rdparty/glfw/source/tests/timeout.c
+++ /dev/null
@@ -1,99 +0,0 @@
-//========================================================================
-// Event wait timeout test
-// Copyright (c) Camilla Löwy <[email protected]>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 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
-// in a product, an acknowledgment in the product documentation would
-// be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-// be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-//========================================================================
-//
-// This test is intended to verify that waiting for events with timeout works
-//
-//========================================================================
-
-#define GLAD_GL_IMPLEMENTATION
-#include <glad/gl.h>
-#define GLFW_INCLUDE_NONE
-#include <GLFW/glfw3.h>
-
-#include <time.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void error_callback(int error, const char* description)
-{
- fprintf(stderr, "Error: %s\n", description);
-}
-
-static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
-{
- if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
- glfwSetWindowShouldClose(window, GLFW_TRUE);
-}
-
-static float nrand(void)
-{
- return (float) rand() / (float) RAND_MAX;
-}
-
-int main(void)
-{
- GLFWwindow* window;
-
- srand((unsigned int) time(NULL));
-
- glfwSetErrorCallback(error_callback);
-
- if (!glfwInit())
- exit(EXIT_FAILURE);
-
- window = glfwCreateWindow(640, 480, "Event Wait Timeout Test", NULL, NULL);
- if (!window)
- {
- glfwTerminate();
- exit(EXIT_FAILURE);
- }
-
- glfwMakeContextCurrent(window);
- gladLoadGL(glfwGetProcAddress);
- glfwSetKeyCallback(window, key_callback);
-
- while (!glfwWindowShouldClose(window))
- {
- int width, height;
- float r = nrand(), g = nrand(), b = nrand();
- float l = (float) sqrt(r * r + g * g + b * b);
-
- glfwGetFramebufferSize(window, &width, &height);
-
- glViewport(0, 0, width, height);
- glClearColor(r / l, g / l, b / l, 1.f);
- glClear(GL_COLOR_BUFFER_BIT);
- glfwSwapBuffers(window);
-
- glfwWaitEventsTimeout(1.0);
- }
-
- glfwDestroyWindow(window);
-
- glfwTerminate();
- exit(EXIT_SUCCESS);
-}
-