]> Some of my projects - openlase-old.git/commitdiff
Make openlase build on windows with msvc (C++ mode) and clang (C mode) master
authorAPTX <marek321@gmail.com>
Thu, 3 Feb 2011 21:40:16 +0000 (22:40 +0100)
committerAPTX <marek321@gmail.com>
Thu, 3 Feb 2011 21:41:31 +0000 (22:41 +0100)
21 files changed:
CMakeLists.txt
include/ilda.h
include/libol.h
include/text.h
libol/CMakeLists.txt
libol/ilda.cpp [moved from libol/ilda.c with 91% similarity]
libol/libol.cpp [moved from libol/libol.c with 96% similarity]
libol/text.cpp [moved from libol/text.c with 100% similarity]
output/CMakeLists.txt
output/output.cpp
output/output_settings.cpp
tools/CMakeLists.txt
tools/genfont.py
tools/playilda.cpp [moved from tools/playilda.c with 97% similarity]
tools/playvid.cpp [moved from tools/playvid.c with 98% similarity]
tools/simulator.cpp [moved from tools/simulator.c with 100% similarity]
tools/trace.cpp [moved from tools/trace.c with 100% similarity]
tools/trace.h
windeps/include/unistd.h [new file with mode: 0644]
windeps/include/wincompat.h [new file with mode: 0644]
windeps/src/wincompat.cpp [new file with mode: 0644]

index 0b2fc330b73c1e50efdd9b3c3bc90b21e52ab82c..8507a3f5926763d9948265335bd882f22ee9c38a 100644 (file)
@@ -30,4 +30,4 @@ set(CMAKE_C_FLAGS "-Wall -O3 -g")
 add_subdirectory (libol)
 add_subdirectory (output)
 add_subdirectory (tools)
 add_subdirectory (libol)
 add_subdirectory (output)
 add_subdirectory (tools)
-add_subdirectory (examples)
+#add_subdirectory (examples)
index e408de682d9e10e31f37c4cf96caa28d7e1bfce5..9e63071f04c08b627801d68b8435c6cff7b043d8 100644 (file)
@@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <stdint.h>
 
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct {
        float x;
        float y;
 typedef struct {
        float x;
        float y;
@@ -46,4 +50,7 @@ void olDrawIlda(IldaFile *ild);
 void olDrawIlda3D(IldaFile *ild);
 void olFreeIlda(IldaFile *ild);
 
 void olDrawIlda3D(IldaFile *ild);
 void olFreeIlda(IldaFile *ild);
 
+#ifdef __cplusplus
+}
+#endif
 #endif
\ No newline at end of file
 #endif
\ No newline at end of file
index 5a24b35fba68b51261b974f2d7696b898d6f744c..181c6e9634264242ea3bf53d397518a1cb5b7fd4 100644 (file)
@@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <stdint.h>
 
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum {
        OL_LINESTRIP,
        OL_BEZIERSTRIP,
 enum {
        OL_LINESTRIP,
        OL_BEZIERSTRIP,
@@ -139,4 +143,7 @@ typedef void (*LogCallbackFunc)(const char *msg);
 
 void olSetLogCallback(LogCallbackFunc f);
 
 
 void olSetLogCallback(LogCallbackFunc f);
 
+#ifdef __cplusplus
+}
+#endif
 #endif
 #endif
index cd9c155d994415eab3d8522d89906e4c002a7518..d2afdc13ac317894d36e402a8fe27ceb1fbf5442 100644 (file)
@@ -23,6 +23,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #include <stdint.h>
 #include <stddef.h>
 
 #include <stdint.h>
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct {
        int flag;
        float x;
 typedef struct {
        int flag;
        float x;
@@ -47,4 +51,7 @@ float olGetCharOverlap(Font *font, float height);
 float olDrawChar(Font *fnt, float x, float y, float height, uint32_t color, char c);
 float olDrawString(Font *fnt, float x, float y, float height, uint32_t color, const char *s);
 
 float olDrawChar(Font *fnt, float x, float y, float height, uint32_t color, char c);
 float olDrawString(Font *fnt, float x, float y, float height, uint32_t color, const char *s);
 
+#ifdef __cplusplus
+}
+#endif
 #endif
 #endif
index 53b680649d718e5f141f11f768d764251b0b6c1f..79ce717817b1a6bcaae904055726293fce36a4fc 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-include_directories (${CMAKE_SOURCE_DIR}/include)
+include_directories (${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/windeps/include)
 find_package(Threads)
 
 find_package(Threads)
 
-add_library (openlase libol.c text.c ilda.c ${CMAKE_CURRENT_BINARY_DIR}/fontdef.c)
-find_library (PTHREAD pthread)
-target_link_libraries (openlase ${CMAKE_THREAD_LIBS_INIT} jack)
+add_library (openlase libol.cpp text.cpp ilda.cpp ${CMAKE_CURRENT_BINARY_DIR}/fontdef.cpp ${CMAKE_SOURCE_DIR}/windeps/src/wincompat.cpp)
+#find_library (PTHREAD pthread)
+target_link_libraries (openlase ${CMAKE_THREAD_LIBS_INIT} jack)
 
 
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fontdef.c
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fontdef.cpp
     DEPENDS ${CMAKE_SOURCE_DIR}/tools/genfont.py
     MAIN_DEPENDENCY laserfont.svg
     DEPENDS ${CMAKE_SOURCE_DIR}/tools/genfont.py
     MAIN_DEPENDENCY laserfont.svg
-    COMMAND python ${CMAKE_SOURCE_DIR}/tools/genfont.py ${CMAKE_CURRENT_SOURCE_DIR}/laserfont.svg ${CMAKE_CURRENT_BINARY_DIR}/fontdef.c default_font)
+    COMMAND python ${CMAKE_SOURCE_DIR}/tools/genfont.py ${CMAKE_CURRENT_SOURCE_DIR}/laserfont.svg ${CMAKE_CURRENT_BINARY_DIR}/fontdef.cpp default_font)
similarity index 91%
rename from libol/ilda.c
rename to libol/ilda.cpp
index 7019420d68719fe035c7c4802dc2509d744e58dd..e2d2639dc259cc121fb026d9d7274c788f76b394 100644 (file)
@@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #include <sys/param.h>
 #include <sys/stat.h>
 
 #include <sys/param.h>
 #include <sys/stat.h>
 
+#include <wincompat.h>
+
 #if BYTE_ORDER == LITTLE_ENDIAN
 static inline uint16_t swapshort(uint16_t v) {
        return (v >> 8) | (v << 8);
 #if BYTE_ORDER == LITTLE_ENDIAN
 static inline uint16_t swapshort(uint16_t v) {
        return (v >> 8) | (v << 8);
@@ -81,7 +83,7 @@ IldaFile *olLoadIlda(const char *filename)
                return NULL;
        }
 
                return NULL;
        }
 
-       ild = malloc(sizeof(*ild));
+       ild = (IldaFile *) malloc(sizeof(*ild));
 
        memset(ild, 0, sizeof(*ild));
 
 
        memset(ild, 0, sizeof(*ild));
 
@@ -113,10 +115,10 @@ IldaFile *olLoadIlda(const char *filename)
                hdr.framecount = swapshort(hdr.framecount);
 
                switch (hdr.format) {
                hdr.framecount = swapshort(hdr.framecount);
 
                switch (hdr.format) {
-               case 0:
+               case 0: {
                        olLog("ILD: Got 3D frame, %d points\n", hdr.count);
                        olLog("ILD: Got 3D frame, %d points\n", hdr.count);
-                       ild->points = malloc(sizeof(IldaPoint) * hdr.count);
-                       struct icoord3d *tmp3d = malloc(sizeof(struct icoord3d) * hdr.count);
+                       ild->points = (IldaPoint *) malloc(sizeof(IldaPoint) * hdr.count);
+                       struct icoord3d *tmp3d = (struct icoord3d *) malloc(sizeof(struct icoord3d) * hdr.count);
                        if (fread(tmp3d, sizeof(struct icoord3d), hdr.count, fd) != hdr.count) {
                                olLog("ILDA: error while reading frame\n");
                                olFreeIlda(ild);
                        if (fread(tmp3d, sizeof(struct icoord3d), hdr.count, fd) != hdr.count) {
                                olLog("ILDA: error while reading frame\n");
                                olFreeIlda(ild);
@@ -131,11 +133,11 @@ IldaFile *olLoadIlda(const char *filename)
                        }
                        free(tmp3d);
                        ild->count = hdr.count;
                        }
                        free(tmp3d);
                        ild->count = hdr.count;
-                       break;
-               case 1:
+                       break; }
+               case 1: {
                        olLog("Got 2D frame, %d points\n", hdr.count);
                        olLog("Got 2D frame, %d points\n", hdr.count);
-                       ild->points = malloc(sizeof(IldaPoint) * hdr.count);
-                       struct icoord2d *tmp2d = malloc(sizeof(struct icoord2d) * hdr.count);
+                       ild->points = (IldaPoint *) malloc(sizeof(IldaPoint) * hdr.count);
+                       struct icoord2d *tmp2d = (struct icoord2d *) malloc(sizeof(struct icoord2d) * hdr.count);
                        if (fread(tmp2d, sizeof(struct icoord2d), hdr.count, fd) != hdr.count) {
                                olLog("ILDA: error while reading frame\n");
                                olFreeIlda(ild);
                        if (fread(tmp2d, sizeof(struct icoord2d), hdr.count, fd) != hdr.count) {
                                olLog("ILDA: error while reading frame\n");
                                olFreeIlda(ild);
@@ -150,7 +152,7 @@ IldaFile *olLoadIlda(const char *filename)
                        }
                        free(tmp2d);
                        ild->count = hdr.count;
                        }
                        free(tmp2d);
                        ild->count = hdr.count;
-                       break;
+                       break; }
                case 2:
                        olLog("ILDA: Got color palette section, %d entries\n", hdr.count);
                        olLog("ILDA: NOT SUPPORTED\n");
                case 2:
                        olLog("ILDA: Got color palette section, %d entries\n", hdr.count);
                        olLog("ILDA: NOT SUPPORTED\n");
similarity index 96%
rename from libol/libol.c
rename to libol/libol.cpp
index eb2385cce8daeeb01a8920bff70161c29057aa4c..d2efc690bc59c82f162ada5e50f7a3511e4ab71d 100644 (file)
@@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+#include <wincompat.h>
 #include "libol.h"
 #include <jack/jack.h>
 #include <stdio.h>
 #include "libol.h"
 #include <jack/jack.h>
 #include <stdio.h>
@@ -25,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #include <string.h>
 #include <math.h>
 #include <unistd.h>
 #include <string.h>
 #include <math.h>
 #include <unistd.h>
+// Yes this file is needed twice!
+#include <wincompat.h>
 
 typedef jack_default_audio_sample_t sample_t;
 typedef jack_nframes_t nframes_t;
 
 typedef jack_default_audio_sample_t sample_t;
 typedef jack_nframes_t nframes_t;
@@ -113,7 +116,14 @@ int coldp = 0;
 uint32_t cols[MTX_STACK_DEPTH];
 uint32_t curcol;
 
 uint32_t cols[MTX_STACK_DEPTH];
 uint32_t curcol;
 
+#ifdef __cplusplus
+Point __cplusplus_point(float x, float y, uint32_t color)
+{Point p = {x, y, color};return p;}
+#define POINT(x, y, color) __cplusplus_point(x,y,color)
+#else
+// Not really sure why it doesn't just work (just msvc or standard)
 #define POINT(x, y, color) ((Point){x,y,color})
 #define POINT(x, y, color) ((Point){x,y,color})
+#endif
 
 ShaderFunc vpreshader;
 ShaderFunc vshader;
 
 ShaderFunc vpreshader;
 ShaderFunc vshader;
@@ -245,16 +255,16 @@ int olInit(int buffer_count, int max_points)
        first_output_frame = 0;
        memset(&wframe, 0, sizeof(Frame));
        wframe.objmax = 16;
        first_output_frame = 0;
        memset(&wframe, 0, sizeof(Frame));
        wframe.objmax = 16;
-       wframe.objects = malloc(wframe.objmax * sizeof(Object));
+       wframe.objects = (Object *) malloc(wframe.objmax * sizeof(Object));
        wframe.psmax = max_points;
        wframe.psmax = max_points;
-       wframe.points = malloc(wframe.psmax * sizeof(Point));
-       frames = malloc(fbufs * sizeof(RenderedFrame));
+       wframe.points = (Point *) malloc(wframe.psmax * sizeof(Point));
+       frames = (RenderedFrame *) malloc(fbufs * sizeof(RenderedFrame));
        for (i=0; i<fbufs; i++) {
                memset(&frames[i], 0, sizeof(RenderedFrame));
                frames[i].pmax = max_points;
        for (i=0; i<fbufs; i++) {
                memset(&frames[i], 0, sizeof(RenderedFrame));
                frames[i].pmax = max_points;
-               frames[i].points = malloc(frames[i].pmax * sizeof(Point));
-               frames[i].audio_l = malloc(frames[i].pmax * sizeof(float));
-               frames[i].audio_r = malloc(frames[i].pmax * sizeof(float));
+               frames[i].points = (Point *) malloc(frames[i].pmax * sizeof(Point));
+               frames[i].audio_l = (float *) malloc(frames[i].pmax * sizeof(float));
+               frames[i].audio_r = (float *) malloc(frames[i].pmax * sizeof(float));
        }
 
        if ((client = jack_client_new ("libol")) == 0) {
        }
 
        if ((client = jack_client_new ("libol")) == 0) {
@@ -330,7 +340,7 @@ void olBegin(int prim)
                return;
        if (wframe.objmax == wframe.objcnt) {
                wframe.objmax *= 2;
                return;
        if (wframe.objmax == wframe.objcnt) {
                wframe.objmax *= 2;
-               wframe.objects = realloc(wframe.objects, wframe.objmax * sizeof(Object));
+               wframe.objects = (Object *) realloc(wframe.objects, wframe.objmax * sizeof(Object));
        }
        dstate.curobj = wframe.objects + wframe.objcnt;
        memset(dstate.curobj, 0, sizeof(Object));
        }
        dstate.curobj = wframe.objects + wframe.objcnt;
        memset(dstate.curobj, 0, sizeof(Object));
@@ -905,6 +915,7 @@ void olScale(float sx, float sy)
        olMultMatrix(scale);
 }
 
        olMultMatrix(scale);
 }
 
+#define new result
 void olMultMatrix(float m[9])
 {
        float new[3][3];
 void olMultMatrix(float m[9])
 {
        float new[3][3];
@@ -921,6 +932,7 @@ void olMultMatrix(float m[9])
 
        memcpy(&mtx2d[0][0], &new[0][0], sizeof(mtx2d));
 }
 
        memcpy(&mtx2d[0][0], &new[0][0], sizeof(mtx2d));
 }
+#undef new
 
 void olPushMatrix(void)
 {
 
 void olPushMatrix(void)
 {
@@ -1001,6 +1013,7 @@ void olScale3(float sx, float sy, float sz)
        olMultMatrix3(trans);
 }
 
        olMultMatrix3(trans);
 }
 
+#define new result
 void olMultMatrix3(float m[16])
 {
        float new[4][4];
 void olMultMatrix3(float m[16])
 {
        float new[4][4];
@@ -1024,6 +1037,7 @@ void olMultMatrix3(float m[16])
 
        memcpy(&mtx3d[0][0], &new[0][0], sizeof(mtx3d));
 }
 
        memcpy(&mtx3d[0][0], &new[0][0], sizeof(mtx3d));
 }
+#undef new
 
 void olPushMatrix3(void)
 {
 
 void olPushMatrix3(void)
 {
similarity index 100%
rename from libol/text.c
rename to libol/text.cpp
index a18622da78615b25ce2980e9671b930dd522991a..f16da03a9d6ecdfdbf6f3eb025ed189c546f3e2c 100644 (file)
 
 include(${QT_USE_FILE})
 
 
 include(${QT_USE_FILE})
 
-QT4_WRAP_UI(output_UIS_H output_settings.ui)
-QT4_AUTOMOC(output_settings.cpp output.cpp)
+set(SOURCES output.cpp output_settings.cpp ${CMAKE_SOURCE_DIR}/windeps/src/wincompat.cpp)
+set(HEADERS output.h output_settings.h)
+set(FROMS output_settings.ui)
 
 
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+qt4_wrap_cpp(MOC ${HEADERS})
+qt4_wrap_ui(UI ${FORMS})
 
 
-add_executable(output output.cpp output_settings.cpp ${output_UIS_H})
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/windeps/include)
+
+add_executable(output ${SOURCES} ${MOC} ${UI})
 target_link_libraries(output ${JACK_LIBRARIES} ${QT_LIBRARIES})
 
 target_link_libraries(output ${JACK_LIBRARIES} ${QT_LIBRARIES})
 
index 4fbda9b2f28318f0b2bacb0147584069a1c0ec6b..a1eaa924a6dc11921fc1138f8f60c7fbe37241b7 100644 (file)
@@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+#include <wincompat.h>
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
index c98acfc5e53d54da159d96b2215f3033bb9b8b13..5826282d595e458767c09d68387c4185e9356ed0 100644 (file)
@@ -17,7 +17,8 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
-#include "output_settings.moc"
+#include "output_settings.h"
+
 #include <QMessageBox>
 #include <QGraphicsLineItem>
 
 #include <QMessageBox>
 #include <QGraphicsLineItem>
 
index 7643ab31890e64500e1a63b482326c4a0619c048..0900465c84b403cf37c308a8739b712fd31a3184 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-include_directories (${CMAKE_SOURCE_DIR}/include)
-link_directories (${CMAKE_BINARY_DIR}/libol)
+include_directories (${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/windeps/include)
+link_directories (${CMAKE_BINARY_DIR}/libol ${CMAKE_SOURCE_DIR}/windeps/lib)
 
 
-add_executable(playilda playilda.c)
+add_executable(playilda playilda.cpp ${CMAKE_SOURCE_DIR}/windeps/src/wincompat.cpp)
 target_link_libraries(playilda ${JACK_LIBRARIES})
 
 target_link_libraries(playilda ${JACK_LIBRARIES})
 
-add_executable(playvid playvid.c trace.c)
-target_link_libraries(playvid openlase avformat avcodec)
+add_executable(playvid playvid.cpp trace.cpp ${CMAKE_SOURCE_DIR}/windeps/src/wincompat.cpp)
+target_link_libraries(playvid openlase avformat avcodec avutil)
 
 include_directories (${CMAKE_SOURCE_DIR}/include)
 link_directories (${CMAKE_BINARY_DIR}/libol)
 
 include_directories (${CMAKE_SOURCE_DIR}/include)
 link_directories (${CMAKE_BINARY_DIR}/libol)
@@ -31,7 +31,7 @@ link_directories (${CMAKE_BINARY_DIR}/libol)
 find_package(OpenGL REQUIRED)
 find_package(GLUT REQUIRED)
 
 find_package(OpenGL REQUIRED)
 find_package(GLUT REQUIRED)
 
-add_executable(simulator simulator.c)
+add_executable(simulator simulator.cpp ${CMAKE_SOURCE_DIR}/windeps/src/wincompat.cpp)
 
 include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
 target_link_libraries(simulator ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${JACK_LIBRARIES})
 
 include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
 target_link_libraries(simulator ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${JACK_LIBRARIES})
index 92557cdb0c3714ddab62f04179478d498c5474a5..232abc5d229022b14fb922fd453b7182e15d7bd6 100644 (file)
@@ -424,9 +424,13 @@ for id, x, y, w, h in handler.rects:
                cdefs.append((chrval, w, "NULL"))
 
 output += "\nstatic const FontChar font_chars[256] = {\n"
                cdefs.append((chrval, w, "NULL"))
 
 output += "\nstatic const FontChar font_chars[256] = {\n"
-
-for chrval, width, sym in cdefs:
-       output += "\t['%s'] = {%8.4f, %s},\n"%(chr(chrval),width,sym)
+for i in range(255):
+       for chrval, width, sym in cdefs:
+               if (chrval == i):
+                       output += "\t{%8.4f, %s},\n"%(width,sym)
+                       break
+       else:
+               output += "\t{0, 0},\n"
 
 output += "};\n\n"
 
 
 output += "};\n\n"
 
similarity index 97%
rename from tools/playilda.c
rename to tools/playilda.cpp
index f738c9b63d99b554672da9f5650c490e755addfe..5616da16afe1ebb0a5e1888de526b678abfef649 100644 (file)
@@ -320,10 +320,10 @@ int loadild(const char *fname, struct frame *frame)
                hdr.framecount = swapshort(hdr.framecount);
 
                switch (hdr.format) {
                hdr.framecount = swapshort(hdr.framecount);
 
                switch (hdr.format) {
-               case 0:
+               case 0: {
                        printf("Got 3D frame, %d points\n", hdr.count);
                        printf("Got 3D frame, %d points\n", hdr.count);
-                       frame->points = malloc(sizeof(struct coord3d) * hdr.count);
-                       struct icoord3d *tmp3d = malloc(sizeof(struct icoord3d) * hdr.count);
+                       frame->points = (struct coord3d *) malloc(sizeof(struct coord3d) * hdr.count);
+                       struct icoord3d *tmp3d = (struct icoord3d *) malloc(sizeof(struct icoord3d) * hdr.count);
                        if (fread(tmp3d, sizeof(struct icoord3d), hdr.count, ild) != hdr.count) {
                                fprintf(stderr, "error while reading frame\n");
                                return -1;
                        if (fread(tmp3d, sizeof(struct icoord3d), hdr.count, ild) != hdr.count) {
                                fprintf(stderr, "error while reading frame\n");
                                return -1;
@@ -337,11 +337,11 @@ int loadild(const char *fname, struct frame *frame)
                        }
                        free(tmp3d);
                        frame->count = hdr.count;
                        }
                        free(tmp3d);
                        frame->count = hdr.count;
-                       break;
-               case 1:
+                       break; }
+               case 1: {
                        printf("Got 2D frame, %d points\n", hdr.count);
                        printf("Got 2D frame, %d points\n", hdr.count);
-                       frame->points = malloc(sizeof(struct coord3d) * hdr.count);
-                       struct icoord2d *tmp2d = malloc(sizeof(struct icoord2d) * hdr.count);
+                       frame->points = (struct coord3d *) malloc(sizeof(struct coord3d) * hdr.count);
+                       struct icoord2d *tmp2d = (struct icoord2d *) malloc(sizeof(struct icoord2d) * hdr.count);
                        if (fread(tmp2d, sizeof(struct icoord2d), hdr.count, ild) != hdr.count) {
                                fprintf(stderr, "error while reading frame\n");
                                return -1;
                        if (fread(tmp2d, sizeof(struct icoord2d), hdr.count, ild) != hdr.count) {
                                fprintf(stderr, "error while reading frame\n");
                                return -1;
@@ -355,7 +355,7 @@ int loadild(const char *fname, struct frame *frame)
                        }
                        free(tmp2d);
                        frame->count = hdr.count;
                        }
                        free(tmp2d);
                        frame->count = hdr.count;
-                       break;
+                       break; }
                case 2:
                        printf("Got color palette section, %d entries\n", hdr.count);
                        if (fread(palette, 3, hdr.count, ild) != hdr.count) {
                case 2:
                        printf("Got color palette section, %d entries\n", hdr.count);
                        if (fread(palette, 3, hdr.count, ild) != hdr.count) {
@@ -425,7 +425,7 @@ int loadild(const char *fname, struct frame *frame)
        }
 
        int ocount = frame->count * rate / pointrate;
        }
 
        int ocount = frame->count * rate / pointrate;
-       struct coord3d *opoints = malloc(sizeof(struct coord3d) * ocount);
+       struct coord3d *opoints = (struct coord3d *) malloc(sizeof(struct coord3d) * ocount);
 
        float mul = (float)frame->count / (float)ocount;
 
 
        float mul = (float)frame->count / (float)ocount;
 
similarity index 98%
rename from tools/playvid.c
rename to tools/playvid.cpp
index a4474bcfdec767638794d15de2a19ecb849182c6..888aab47453f2c4912425c25157ce5b42400947b 100644 (file)
@@ -53,8 +53,16 @@ is a hack.
 #include <jack/jack.h>
 #include <math.h>
 
 #include <jack/jack.h>
 #include <math.h>
 
+#include <wincompat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
+#ifdef __cplusplus
+}
+#endif
 
 #define FRAMES_BUF 8
 
 
 #define FRAMES_BUF 8
 
@@ -136,7 +144,7 @@ void moreaudio(float *lb, float *rb, int samples)
 
                        input_samples = bytes / (sizeof(short)*pACodecCtx->channels);
 
 
                        input_samples = bytes / (sizeof(short)*pACodecCtx->channels);
 
-                       buffered_samples = audio_resample(resampler, (void*)oabuf, iabuf, input_samples);
+                       buffered_samples = audio_resample(resampler, (short *) oabuf, iabuf, input_samples);
                        poabuf = oabuf;
                }
 
                        poabuf = oabuf;
                }
 
@@ -465,7 +473,7 @@ int main (int argc, char *argv[])
                        else
                                thresh = thresh_dark;
 
                        else
                                thresh = thresh_dark;
 
-                       obj = trace(frame->data[0], tmp, thresh,
+                       obj = trace(frame->data[0], (uint8_t *) tmp, thresh,
                                                pCodecCtx->width, pCodecCtx->height, frame->linesize[0], decimate);
 
                        ftime = olRenderFrame(100);
                                                pCodecCtx->width, pCodecCtx->height, frame->linesize[0], decimate);
 
                        ftime = olRenderFrame(100);
similarity index 100%
rename from tools/simulator.c
rename to tools/simulator.cpp
similarity index 100%
rename from tools/trace.c
rename to tools/trace.cpp
index 1551a8948ea8f6b51aa2b0ec27f456a5d260d248..641bc3c8cc30256c34b0e172c3979263f07142ea 100644 (file)
@@ -20,6 +20,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #ifndef TRACE_H
 #define TRACE_H
 
 #ifndef TRACE_H
 #define TRACE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int trace(uint8_t *field, uint8_t *tmp, uint8_t thresh, int width, int height, int stride, int decimate);
 
 int trace(uint8_t *field, uint8_t *tmp, uint8_t thresh, int width, int height, int stride, int decimate);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
\ No newline at end of file
 #endif
\ No newline at end of file
diff --git a/windeps/include/unistd.h b/windeps/include/unistd.h
new file mode 100644 (file)
index 0000000..daf4e94
--- /dev/null
@@ -0,0 +1 @@
+#include "wincompat.h"
\ No newline at end of file
diff --git a/windeps/include/wincompat.h b/windeps/include/wincompat.h
new file mode 100644 (file)
index 0000000..c2a73b5
--- /dev/null
@@ -0,0 +1,73 @@
+#ifdef DrawState
+#undef DrawState
+#endif
+
+#ifdef near
+#undef near
+#endif
+
+#ifndef M_PI
+#define M_PI           3.14159265358979323846
+#endif
+
+#ifdef _MSC_VER
+#define __attribute__(x)
+#endif
+
+// Only msvc?
+#ifndef UINT64_C
+#define UINT64_C(x) x##ui64
+#endif
+
+#ifndef HAVE_WINCOMPAT
+#define HAVE_WINCOMPAT
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *HANDLE;
+typedef HANDLE pthread_t;
+
+typedef int int32_t;
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+typedef unsigned long long uint64_t;
+
+
+extern float fmaxf(float a, float b);
+
+/* ----------------------------------------------------------------------------------
+                                                                       usleep
+   ---------------------------------------------------------------------------------- */
+
+extern int usleep(unsigned int useconds);
+
+/* ----------------------------------------------------------------------------------
+                                                                       getopt
+   ---------------------------------------------------------------------------------- */
+
+#define BADCH   (int)'?'
+#define BADARG  (int)':'
+#define EMSG    ""
+   
+extern int  opterr;
+extern int  optind;
+extern int  optopt;
+extern char *optarg;
+
+extern int  optreset;
+
+extern int
+getopt(
+       int         nargc,
+       char       *const * nargv,
+       const char *ostr
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HAVE_WINCOMPAT
\ No newline at end of file
diff --git a/windeps/src/wincompat.cpp b/windeps/src/wincompat.cpp
new file mode 100644 (file)
index 0000000..885060c
--- /dev/null
@@ -0,0 +1,110 @@
+#include <wincompat.h>
+
+float fmaxf(float a, float b)
+{
+       return a < b ? b : a;
+}
+
+/* ----------------------------------------------------------------------------------
+                                                                       usleep
+   ---------------------------------------------------------------------------------- */
+
+#include <windows.h>
+
+int usleep(unsigned int useconds)
+{
+       HANDLE timer;
+       LARGE_INTEGER due;
+
+       due.QuadPart = -(10 * (__int64)useconds);
+
+       timer = CreateWaitableTimer(NULL, TRUE, NULL);
+       SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);
+       WaitForSingleObject(timer, INFINITE);
+       CloseHandle(timer);
+       return 0;
+}
+
+/* ----------------------------------------------------------------------------------
+                                                                       getopt
+   ---------------------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <string.h>
+
+int  opterr = 0;
+int  optind = 1;
+int  optopt = 0;
+char *optarg = 0;
+
+int  optreset = 0;
+
+int
+getopt(
+       int         nargc,
+       char       *const * nargv,
+       const char *ostr
+)
+{
+       static char *place = EMSG;  /* option letter processing */
+       char       *oli;            /* option letter list index */
+
+       if (optreset || !*place)
+       {                           /* update scanning pointer */
+               optreset = 0;
+               if (optind >= nargc || *(place = nargv[optind]) != '-')
+               {
+                       place = EMSG;
+                       return -1;
+               }
+               if (place[1] && *++place == '-' && place[1] == '\0')
+               {                       /* found "--" */
+                       ++optind;
+                       place = EMSG;
+                       return -1;
+               }
+       }                           /* option letter okay? */
+       if ((optopt = (int) *place++) == (int) ':' ||
+               !(oli = strchr((char *) ostr, optopt)))
+       {
+               /*
+               * if the user didn't specify '-' as an option, assume it means -1.
+               */
+               if (optopt == (int) '-')
+               return -1;
+               if (!*place)
+                       ++optind;
+               if (opterr && *ostr != ':')
+                       (void) fprintf(stderr,
+                               "illegal option -- %c\n", optopt);
+               return BADCH;
+       }
+       if (*++oli != ':')
+       {                           /* don't need argument */
+               optarg = NULL;
+               if (!*place)
+                       ++optind;
+       }
+       else
+       {                           /* need an argument */
+               if (*place)             /* no white space */
+                       optarg = place;
+               else if (nargc <= ++optind)
+               {                       /* no arg */
+                       place = EMSG;
+                       if (*ostr == ':')
+                               return BADARG;
+                       if (opterr)
+                               (void) fprintf(stderr,
+                                       "option requires an argument -- %c\n",
+                                       optopt);
+                       return BADCH;
+               }
+               else
+                       /* white space */
+                       optarg = nargv[optind];
+               place = EMSG;
+               ++optind;
+       }
+       return optopt;              /* dump back option letter */
+}
\ No newline at end of file