mirror of
https://github.com/glfw/glfw.git
synced 2025-06-15 20:22:15 +00:00
Fixed tests not compiling on VS10.
This commit is contained in:
parent
f96d9fe8a4
commit
f970fe23fb
@ -86,7 +86,7 @@ static void command_callback(int key)
|
|||||||
int w = cursorSize[currentSize].w;
|
int w = cursorSize[currentSize].w;
|
||||||
int h = cursorSize[currentSize].h;
|
int h = cursorSize[currentSize].h;
|
||||||
int x, y, i = 0;
|
int x, y, i = 0;
|
||||||
unsigned char image[4 * w * h];
|
unsigned char *image = malloc(4 * w * h);
|
||||||
|
|
||||||
for (y = 0; y < h; y++)
|
for (y = 0; y < h; y++)
|
||||||
{
|
{
|
||||||
@ -100,8 +100,8 @@ static void command_callback(int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursor = glfwCreateCursor(w, h, w / 2, h / 2, 0, image);
|
cursor = glfwCreateCursor(w, h, w / 2, h / 2, 0, image);
|
||||||
|
|
||||||
currentSize = (currentSize + 1) % SizeCount;
|
currentSize = (currentSize + 1) % SizeCount;
|
||||||
|
free(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -32,25 +32,33 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define SIZE 64
|
#ifdef min
|
||||||
|
#undef min
|
||||||
|
#endif
|
||||||
|
#ifdef max
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SIZE 64 // cursor size (width & height)
|
||||||
|
#define N 60 // number of frames
|
||||||
|
|
||||||
unsigned char buffer[4 * SIZE * SIZE];
|
unsigned char buffer[4 * SIZE * SIZE];
|
||||||
|
|
||||||
static inline float max(float a, float b) { return a > b ? a : b; }
|
static float max(float a, float b) { return a > b ? a : b; }
|
||||||
static inline float min(float a, float b) { return a < b ? a : b; }
|
static float min(float a, float b) { return a < b ? a : b; }
|
||||||
|
|
||||||
static float star(int x, int y, float t)
|
static float star(int x, int y, float t)
|
||||||
{
|
{
|
||||||
float c = SIZE / 2.0f;
|
float c = SIZE / 2.0f;
|
||||||
|
|
||||||
float i = (0.25f * sin(2.0f * 3.1415926f * t) + 0.75f);
|
float i = (0.25f * (float)sin(2.0f * 3.1415926f * t) + 0.75f);
|
||||||
float k = SIZE * 0.046875f * i;
|
float k = SIZE * 0.046875f * i;
|
||||||
|
|
||||||
float dist = sqrt((x - c) * (x - c) + (y - c) * (y - c));
|
float dist = (float)sqrt((x - c) * (x - c) + (y - c) * (y - c));
|
||||||
|
|
||||||
float salpha = 1.0f - dist / c;
|
float salpha = 1.0f - dist / c;
|
||||||
float xalpha = (float)x == c ? c : k / fabs(x - c);
|
float xalpha = (float)x == c ? c : k / (float)fabs(x - c);
|
||||||
float yalpha = (float)y == c ? c : k / fabs(y - c);
|
float yalpha = (float)y == c ? c : k / (float)fabs(y - c);
|
||||||
|
|
||||||
return max(0.0f, min(1.0f, i * salpha * 0.2f + salpha * xalpha * yalpha));
|
return max(0.0f, min(1.0f, i * salpha * 0.2f + salpha * xalpha * yalpha));
|
||||||
}
|
}
|
||||||
@ -66,7 +74,7 @@ static GLFWcursor* load_frame(float t)
|
|||||||
buffer[i++] = 255;
|
buffer[i++] = 255;
|
||||||
buffer[i++] = 255;
|
buffer[i++] = 255;
|
||||||
buffer[i++] = 255;
|
buffer[i++] = 255;
|
||||||
buffer[i++] = 255 * star(x, y, t);
|
buffer[i++] = (unsigned char)(255 * star(x, y, t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +83,6 @@ static GLFWcursor* load_frame(float t)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
const int N = 60;
|
|
||||||
int i;
|
int i;
|
||||||
double t0, t1, frameTime = 0.0;
|
double t0, t1, frameTime = 0.0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user