Forráskód Böngészése

Fixed test for invalid timer values.

Fixes #436 (properly).
Camilla Berglund 10 éve
szülő
commit
6e20cda7fd
3 módosított fájl, 8 hozzáadás és 3 törlés
  1. 1 0
      README.md
  2. 6 1
      include/GLFW/glfw3.h
  3. 1 2
      src/input.c

+ 1 - 0
README.md

@@ -184,6 +184,7 @@ skills.
  - Nathan Sweet
  - Nathan Sweet
  - TTK-Bandit
  - TTK-Bandit
  - Sergey Tikhomirov
  - Sergey Tikhomirov
+ - A. Tombs
  - Samuli Tuomola
  - Samuli Tuomola
  - urraka
  - urraka
  - Jari Vetoniemi
  - Jari Vetoniemi

+ 6 - 1
include/GLFW/glfw3.h

@@ -3098,10 +3098,15 @@ GLFWAPI double glfwGetTime(void);
 /*! @brief Sets the GLFW timer.
 /*! @brief Sets the GLFW timer.
  *
  *
  *  This function sets the value of the GLFW timer.  It then continues to count
  *  This function sets the value of the GLFW timer.  It then continues to count
- *  up from that value.  The value must be a positive finite number.
+ *  up from that value.  The value must be a positive finite number less than
+ *  or equal to 18446744073.0, which is approximately 584.5 years.
  *
  *
  *  @param[in] time The new value, in seconds.
  *  @param[in] time The new value, in seconds.
  *
  *
+ *  @remarks The upper limit of the timer is calculated as
+ *  floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
+ *  storing nanoseconds in 64 bits.  The limit may be increased in the future.
+ *
  *  @par Thread Safety
  *  @par Thread Safety
  *  This function may only be called from the main thread.
  *  This function may only be called from the main thread.
  *
  *

+ 1 - 2
src/input.c

@@ -28,7 +28,6 @@
 #include "internal.h"
 #include "internal.h"
 
 
 #include <stdlib.h>
 #include <stdlib.h>
-#include <float.h>
 #if defined(_MSC_VER)
 #if defined(_MSC_VER)
  #include <malloc.h>
  #include <malloc.h>
 #endif
 #endif
@@ -593,7 +592,7 @@ GLFWAPI void glfwSetTime(double time)
 {
 {
     _GLFW_REQUIRE_INIT();
     _GLFW_REQUIRE_INIT();
 
 
-    if (time != time || time - DBL_MAX == time || time < 0.0)
+    if (time != time || time < 0.0 || time > 18446744073.0)
     {
     {
         _glfwInputError(GLFW_INVALID_VALUE, "Invalid time");
         _glfwInputError(GLFW_INVALID_VALUE, "Invalid time");
         return;
         return;