# HG changeset patch # User John Tsiombikas # Date 1349574164 -7200 # Node ID 45172d087ebe252c396162d8f83335858f96099a # Parent 1141a325cb7393a8a7fb92d0cc12a95167cb7909 fixed some windows compatibility crap fixed a terrible stack overrun in psys (TODO: remember to fix in libpsys too) diff -r 1141a325cb73 -r 45172d087ebe prototype/prototype.vcxproj --- a/prototype/prototype.vcxproj Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/prototype.vcxproj Sun Oct 07 03:42:44 2012 +0200 @@ -52,13 +52,13 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)\vmath;$(SolutionDir)\drawtext;$(SolutionDir)\kdtree;%(AdditionalIncludeDirectories) - 4996 + $(SolutionDir);$(SolutionDir)\src;$(SolutionDir)\vmath;$(SolutionDir)\drawtext;$(SolutionDir)\kdtree;$(SolutionDir)\imago2;%(AdditionalIncludeDirectories) + 4996;4244 Console true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;assimp.lib;glut32.lib;glew32.lib;libimago2.lib;zlib.lib;jpeglib.lib;libpng.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;assimp.lib;glut32.lib;glew32.lib;zlib.lib;jpeglib.lib;libpng.lib;freetype.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;OpenAL32.lib;%(AdditionalDependencies) @@ -70,22 +70,39 @@ true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)\vmath;$(SolutionDir)\drawtext;$(SolutionDir)\kdtree;%(AdditionalIncludeDirectories) - 4996 + $(SolutionDir);$(SolutionDir)\src;$(SolutionDir)\vmath;$(SolutionDir)\drawtext;$(SolutionDir)\kdtree;$(SolutionDir)\imago2;%(AdditionalIncludeDirectories) + 4996;4244 Console true true true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;assimp.lib;glut32.lib;glew32.lib;libimago2.lib;zlib.lib;jpeglib.lib;libpng.lib;%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;assimp.lib;glut32.lib;glew32.lib;zlib.lib;jpeglib.lib;libpng.lib;freetype.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;OpenAL32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + @@ -124,9 +141,20 @@ + + + + + + + + + + + diff -r 1141a325cb73 -r 45172d087ebe prototype/prototype.vcxproj.filters --- a/prototype/prototype.vcxproj.filters Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/prototype.vcxproj.filters Sun Oct 07 03:42:44 2012 +0200 @@ -20,6 +20,15 @@ {a1933fec-b18b-4122-a680-4da3e97a2d88} + + {23054168-9ccf-414e-8c00-2d8205e8ae2d} + + + {d76c7356-d473-4aeb-b7d8-6a577100d636} + + + {22905ba8-8498-4dc4-8be2-6f4def2528f3} + @@ -142,6 +151,57 @@ libs\drawtext + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\imago2 + + + libs\anim + + + libs\anim + + + libs\anim + + + libs\psys + + + libs\psys + + + libs\psys + + + libs\psys + + + libs\psys + @@ -261,6 +321,39 @@ libs\drawtext + + libs\imago2 + + + libs\imago2 + + + libs\anim + + + libs\anim + + + libs\anim + + + libs\anim + + + libs\psys + + + libs\psys + + + libs\psys + + + libs\psys + + + libs\psys + diff -r 1141a325cb73 -r 45172d087ebe prototype/psys/pattr.c --- a/prototype/psys/pattr.c Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/psys/pattr.c Sun Oct 07 03:42:44 2012 +0200 @@ -166,7 +166,7 @@ } if(!(fp = fopen(fname, "r"))) { - fprintf(stderr, "%s: failed to read file: %s: %s\n", __func__, fname, strerror(errno)); + fprintf(stderr, "%s: failed to read file: %s: %s\n", __FUNCTION__, fname, strerror(errno)); return -1; } res = psys_load_attr_stream(attr, fp); @@ -247,6 +247,9 @@ char *buf, *tmp; struct cfgopt *opt; + /* allocate a working buffer on the stack that could fit the current line */ + buf = alloca(strlen(line) + 1); + line = stripspace((char*)line); if(line[0] == '#' || !line[0]) { return 0; /* skip empty lines and comments */ @@ -263,8 +266,6 @@ *opt->valstr++ = 0; opt->valstr = stripspace(opt->valstr); - /* allocate a working buffer on the stack that could fit the current line */ - buf = alloca(strlen(line) + 1); strcpy(buf, line); buf = stripspace(buf); @@ -274,7 +275,8 @@ float tval; *tmp++ = 0; - opt->name = strdup(buf); + opt->name = malloc(strlen(buf) + 1); + strcpy(opt->name, buf); tval = strtod(tmp, &endp); if(endp == tmp) { /* nada ... */ @@ -285,7 +287,8 @@ opt->tm = (long)tval; } } else { - opt->name = strdup(buf); + opt->name = malloc(strlen(buf) + 1); + strcpy(opt->name, buf); opt->tm = 0; } @@ -331,7 +334,9 @@ { if(opt) { free(opt->name); + opt->name = 0; } + opt = 0; } @@ -341,7 +346,7 @@ int res; if(!(fp = fopen(fname, "w"))) { - fprintf(stderr, "%s: failed to write file: %s: %s\n", __func__, fname, strerror(errno)); + fprintf(stderr, "%s: failed to write file: %s: %s\n", __FUNCTION__, fname, strerror(errno)); return -1; } res = psys_save_attr_stream(attr, fp); diff -r 1141a325cb73 -r 45172d087ebe prototype/psys/psys.c --- a/prototype/psys/psys.c Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/psys/psys.c Sun Oct 07 03:42:44 2012 +0200 @@ -1,7 +1,7 @@ #include #include #include -#include +/*#include */ #include "psys.h" #include "psys_gl.h" @@ -11,7 +11,7 @@ /* particle pool */ static struct psys_particle *ppool; static int ppool_size; -static pthread_mutex_t pool_lock = PTHREAD_MUTEX_INITIALIZER; +/*static pthread_mutex_t pool_lock = PTHREAD_MUTEX_INITIALIZER;*/ static struct psys_particle *palloc(void); static void pfree(struct psys_particle *p); @@ -302,7 +302,7 @@ { struct psys_particle *p; - pthread_mutex_lock(&pool_lock); + /*pthread_mutex_lock(&pool_lock);*/ if(ppool) { p = ppool; ppool = ppool->next; @@ -310,16 +310,16 @@ } else { p = malloc(sizeof *p); } - pthread_mutex_unlock(&pool_lock); + /*pthread_mutex_unlock(&pool_lock);*/ return p; } static void pfree(struct psys_particle *p) { - pthread_mutex_lock(&pool_lock); + /*pthread_mutex_lock(&pool_lock);*/ p->next = ppool; ppool = p; ppool_size++; - pthread_mutex_unlock(&pool_lock); + /*pthread_mutex_unlock(&pool_lock);*/ } diff -r 1141a325cb73 -r 45172d087ebe prototype/psys/psys_gl.c --- a/prototype/psys/psys_gl.c Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/psys/psys_gl.c Sun Oct 07 03:42:44 2012 +0200 @@ -84,7 +84,7 @@ if(!(pixels = img_load_pixels(fname, &xsz, &ysz, IMG_FMT_RGBA32))) { return 0; } - printf("%s: creating texture %s (%dx%d)\n", __func__, fname, xsz, ysz); + printf("%s: creating texture %s (%dx%d)\n", __FUNCTION__, fname, xsz, ysz); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); diff -r 1141a325cb73 -r 45172d087ebe prototype/src/audio/sample.cc --- a/prototype/src/audio/sample.cc Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/audio/sample.cc Sun Oct 07 03:42:44 2012 +0200 @@ -1,5 +1,6 @@ #include #include +#include #include #include #include "openal.h" diff -r 1141a325cb73 -r 45172d087ebe prototype/src/audio/stream.cc --- a/prototype/src/audio/stream.cc Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/audio/stream.cc Sun Oct 07 03:42:44 2012 +0200 @@ -32,7 +32,7 @@ return volume; } -void AudioStream::play(enum PlayMode mode) +void AudioStream::play(PlayMode mode) { loop = (mode == PlayMode::loop); done = false; @@ -153,7 +153,7 @@ mutex.unlock(); - std::chrono::milliseconds dur{poll_interval}; + std::chrono::milliseconds dur(poll_interval); std::this_thread::sleep_for(dur); mutex.lock(); diff -r 1141a325cb73 -r 45172d087ebe prototype/src/audio/stream.h --- a/prototype/src/audio/stream.h Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/audio/stream.h Sun Oct 07 03:42:44 2012 +0200 @@ -38,7 +38,7 @@ void set_volume(float vol); float get_volume() const; - void play(enum PlayMode mode); + void play(PlayMode mode); void stop(); virtual void rewind() = 0; diff -r 1141a325cb73 -r 45172d087ebe prototype/src/main.cc --- a/prototype/src/main.cc Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/main.cc Sun Oct 07 03:42:44 2012 +0200 @@ -1,7 +1,6 @@ #include #include #include -#include #include "opengl.h" #include "psys/psys.h" #include "level.h" diff -r 1141a325cb73 -r 45172d087ebe prototype/src/renderer_deferred.cc --- a/prototype/src/renderer_deferred.cc Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/renderer_deferred.cc Sun Oct 07 03:42:44 2012 +0200 @@ -61,11 +61,11 @@ height = ysz; if(!GLEW_ARB_texture_float) { - fprintf(stderr, "%s: error: no floating point texture support\n", __func__); + fprintf(stderr, "%s: error: no floating point texture support\n", __FUNCTION__); return false; } if(!GLEW_ARB_draw_buffers) { - fprintf(stderr, "%s: error: no multiple render target support\n", __func__); + fprintf(stderr, "%s: error: no multiple render target support\n", __FUNCTION__); return false; } @@ -73,7 +73,7 @@ glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_buf); printf("max draw buffers: %d\n", max_draw_buf); if(max_draw_buf < MRT_COUNT) { - fprintf(stderr, "%s: error: not enough draw buffers (%d), %d required\n", __func__, max_draw_buf, MRT_COUNT); + fprintf(stderr, "%s: error: not enough draw buffers (%d), %d required\n", __FUNCTION__, max_draw_buf, MRT_COUNT); return false; } num_draw_bufs = MRT_COUNT; diff -r 1141a325cb73 -r 45172d087ebe prototype/src/renderer_multipass.cc --- a/prototype/src/renderer_multipass.cc Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/renderer_multipass.cc Sun Oct 07 03:42:44 2012 +0200 @@ -32,7 +32,7 @@ height = ysz; if(!GLEW_ARB_texture_float) { - fprintf(stderr, "%s: error: no floating point texture support\n", __func__); + fprintf(stderr, "%s: error: no floating point texture support\n", __FUNCTION__); return false; } diff -r 1141a325cb73 -r 45172d087ebe prototype/src/timer.cc --- a/prototype/src/timer.cc Sun Oct 07 02:05:11 2012 +0300 +++ b/prototype/src/timer.cc Sun Oct 07 03:42:44 2012 +0200 @@ -1,3 +1,4 @@ +#ifndef _MSC_VER #include #include "timer.h" @@ -16,3 +17,11 @@ auto dur = steady_clock::now() - start_time; return duration_cast(dur).count(); } +#else +#include + +unsigned long get_time_msec(void) +{ + return GetTickCount(); +} +#endif \ No newline at end of file