From e8972149ef905f931152eec248c0d254ced8cbd7 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sun, 22 Jan 2017 16:46:16 +0930 Subject: [PATCH] Fix windows build. --- README.md | 5 +++++ src/array.c | 3 ++- src/bmesh.c | 7 +++++-- src/draw.cpp | 2 +- src/draw.h | 3 ++- src/matrix.c | 4 ++++ src/render.cpp | 2 +- src/vector3d.c | 4 ++++ 8 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 211d9d64..8fc305f4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,11 @@ Build $ cd build $ qmake -spec macx-xcode ``` +*Generate VC Project* +``` +$ cd build +$ qmake -tp vc +``` *Generate Makefile* ``` $ cd build diff --git a/src/array.c b/src/array.c index 813350c1..b5abdee4 100644 --- a/src/array.c +++ b/src/array.c @@ -21,12 +21,13 @@ array *arrayCreate(int nodeSize) { } int arraySetLength(array *arr, int length) { + char *newNodes; if (length > arr->capacity) { int newCapacity = (arr->capacity + 1) * 2; if (newCapacity < length) { newCapacity = length; } - char *newNodes = (char *)realloc(arr->nodes, arr->nodeSize * newCapacity); + newNodes = (char *)realloc(arr->nodes, arr->nodeSize * newCapacity); if (!newNodes) { fprintf(stderr, "%s:Insufficient memory.\n", __FUNCTION__); return -1; diff --git a/src/bmesh.c b/src/bmesh.c index 94f65130..966cd221 100644 --- a/src/bmesh.c +++ b/src/bmesh.c @@ -924,8 +924,11 @@ static int bmeshAddWallsBetweenQuadsToModel(bmesh *bm, vec3 *origin, quad *q1, vec3 o2v; matchTwoFaces(q1, q2); for (i = 0; i < 4; ++i) { - quad wall = {{q1->pt[i], q2->pt[i], - q2->pt[(i + 1) % 4], q1->pt[(i + 1) % 4]}}; + quad wall; + wall.pt[0] = q1->pt[i]; + wall.pt[1] = q2->pt[i]; + wall.pt[2] = q2->pt[(i + 1) % 4]; + wall.pt[3] = q1->pt[(i + 1) % 4]; vec3Normal(&wall.pt[0], &wall.pt[1], &wall.pt[2], &normal); vec3Sub(&wall.pt[0], origin, &o2v); if (vec3DotProduct(&o2v, &normal) < 0) { diff --git a/src/draw.cpp b/src/draw.cpp index 2472ee35..8ceedfee 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -118,7 +118,7 @@ int drawPrintf(int x, int y, const char *fmt, ...) { return drawText(x, y, text); } -static const float drawDebugColors[][4] { +static const float drawDebugColors[][4] = { {1.00, 0.00, 1.00, 1.0}, {0.00, 1.00, 1.00, 1.0}, {1.00, 1.00, 0.00, 1.0}, diff --git a/src/draw.h b/src/draw.h index 05a3cde8..92fe6e72 100644 --- a/src/draw.h +++ b/src/draw.h @@ -3,7 +3,8 @@ #include "3dstruct.h" #ifdef __APPLE__ #include -#else +#elif defined(_WIN32) +#include #include #endif diff --git a/src/matrix.c b/src/matrix.c index c853a13b..3f2ac7e3 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -2,6 +2,10 @@ #include #include +#ifndef M_PI +#define M_PI 3.1415926 +#endif + #define DEG2RAD (M_PI / 180.0) matrix *matrixLoadIdentity(matrix *mat) { diff --git a/src/render.cpp b/src/render.cpp index f2b81aad..e04f14c0 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -9,7 +9,7 @@ #include "vector3d.h" #include "subdivide.h" -static const float bmeshBallColors[][4] { +static const float bmeshBallColors[][4] = { {0.00, 0.78, 1.00, 0.5}, {1.00, 0.00, 0.00, 0.5}, {1.00, 1.00, 1.00, 0.5} diff --git a/src/vector3d.c b/src/vector3d.c index 8fbe3c75..eed5f14a 100644 --- a/src/vector3d.c +++ b/src/vector3d.c @@ -2,6 +2,10 @@ #include "vector3d.h" #include "matrix.h" +#ifndef M_PI +#define M_PI 3.1415926 +#endif + float vec3Length(vec3 *p) { double mag; mag = p->x * p->x + p->y * p->y + p->z * p->z;