Skip to content

Commit

Permalink
Fix a few Windows errors and warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkoskiv committed Jan 22, 2020
1 parent b2ece87 commit e78f3d6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/c-ray.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void crDestroySDL() {
void crWriteImage() {
char *hash = gitHash(8);
char buf[64];
smartTime(getMs(grenderer->state.timer), buf);
smartTime(getMs(*grenderer->state.timer), buf);
if (currentImage) {
if (!grenderer->state.renderAborted) {
writeImage(currentImage, (struct renderInfo){
Expand Down Expand Up @@ -211,9 +211,9 @@ bool crGetAntialiasing() {
}

void crRenderSingleFrame() {
startTimer(&grenderer->state.timer);
startTimer(grenderer->state.timer);
currentImage = renderFrame(grenderer);
printDuration(getMs(grenderer->state.timer));
printDuration(getMs(*grenderer->state.timer));
}

//Interactive mode
Expand Down
4 changes: 2 additions & 2 deletions src/datatypes/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct vector vecMul(struct vector v1, struct vector v2) {
@return Length of given vector
*/
float vecLength(struct vector v) {
return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
return sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
}

float vecLengthSquared(struct vector v) {
Expand Down Expand Up @@ -229,7 +229,7 @@ struct vector getRandomVecOnPlane(struct vector center, float radius, pcg32_rand

struct coord randomCoordOnUnitDisc(pcg32_random_t *rng) {
float r = sqrtf(rndFloat(rng));
float theta = rndFloatRange(0, 2*PI, rng);
float theta = rndFloatRange(0.0f, 2.0f * PI, rng);
return (struct coord){r * cosf(theta), r * sinf(theta)};
}

Expand Down
6 changes: 3 additions & 3 deletions src/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

//Global constants
#define MAX_CRAY_VERTEX_COUNT 3
#define PIOVER180 0.017453292519943295769236907684886
#define PI 3.141592653589793238462643383279502
#define PIOVER180 0.017453292519943295769236907684886f
#define PI 3.141592653589793238462643383279502f
#define CRAY_MATERIAL_NAME_SIZE 256
#define CRAY_MESH_FILENAME_LENGTH 500

//Some macros
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define invsqrt(x) (1.0 / sqrt(x))
#define invsqrt(x) (1.0f / sqrt(x))

//Master include file
#ifdef __linux__
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ struct renderer *newRenderer() {
r->state.avgTileTime = (time_t)1;
r->state.timeSampleCount = 1;

r->state.timer = calloc(1, sizeof(struct timeval));

//TODO: Do we need all these heap allocs?
r->scene = calloc(1, sizeof(struct world));
r->scene->camera = calloc(1, sizeof(struct camera));
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct threadState {
struct texture *output;
};

struct timeval;

/// Renderer state data
struct state {
struct renderTile *renderTiles; //Array of renderTiles to render
Expand All @@ -48,7 +50,7 @@ struct state {
float avgSampleRate; //In raw single pixel samples per second. (Used for benchmarking)
int timeSampleCount;//Used for render duration estimation, amount of time samples captured
struct threadState *threadStates; //Info about threads
struct timeval timer;
struct timeval *timer;
#ifdef WINDOWS
HANDLE tileMutex; // = INVALID_HANDLE_VALUE;
#else
Expand Down
4 changes: 4 additions & 0 deletions src/utils/filehandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ char *getFileName(char *input) {
return fn;
}

//For Windows
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
char *getFilePath(char *input) {
char *dir = calloc(PATH_MAX, sizeof(char));
#ifdef WINDOWS
Expand Down
1 change: 0 additions & 1 deletion src/utils/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "networking.h"

#include "../utils/logging.h"
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
Expand Down
2 changes: 2 additions & 0 deletions src/utils/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "../datatypes/texture.h"
#include "../datatypes/color.h"

#include <signal.h>

//Signal handling
void (*signal(int signo, void (*func )(int)))(int);
typedef void sigfunc(int);
Expand Down

0 comments on commit e78f3d6

Please sign in to comment.