add_subdirectory (libol)
add_subdirectory (output)
add_subdirectory (tools)
-add_subdirectory (examples)
+#add_subdirectory (examples)
#include <stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
float x;
float y;
void olDrawIlda3D(IldaFile *ild);
void olFreeIlda(IldaFile *ild);
+#ifdef __cplusplus
+}
+#endif
#endif
\ No newline at end of file
#include <stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
enum {
OL_LINESTRIP,
OL_BEZIERSTRIP,
void olSetLogCallback(LogCallbackFunc f);
+#ifdef __cplusplus
+}
+#endif
#endif
#include <stdint.h>
#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
int flag;
float x;
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
# 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)
-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} m 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
- 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)
#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);
return NULL;
}
- ild = malloc(sizeof(*ild));
+ ild = (IldaFile *) malloc(sizeof(*ild));
memset(ild, 0, sizeof(*ild));
hdr.framecount = swapshort(hdr.framecount);
switch (hdr.format) {
- case 0:
+ case 0: {
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);
}
free(tmp3d);
ild->count = hdr.count;
- break;
- case 1:
+ break; }
+ case 1: {
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);
}
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");
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 <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;
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})
+#endif
ShaderFunc vpreshader;
ShaderFunc vshader;
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.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;
- 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) {
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));
olMultMatrix(scale);
}
+#define new result
void olMultMatrix(float m[9])
{
float new[3][3];
memcpy(&mtx2d[0][0], &new[0][0], sizeof(mtx2d));
}
+#undef new
void olPushMatrix(void)
{
olMultMatrix3(trans);
}
+#define new result
void olMultMatrix3(float m[16])
{
float new[4][4];
memcpy(&mtx3d[0][0], &new[0][0], sizeof(mtx3d));
}
+#undef new
void olPushMatrix3(void)
{
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})
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <wincompat.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "output_settings.moc"
+#include "output_settings.h"
+
#include <QMessageBox>
#include <QGraphicsLineItem>
# 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})
-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)
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})
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"
hdr.framecount = swapshort(hdr.framecount);
switch (hdr.format) {
- case 0:
+ case 0: {
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;
}
free(tmp3d);
frame->count = hdr.count;
- break;
- case 1:
+ break; }
+ case 1: {
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;
}
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) {
}
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;
#include <jack/jack.h>
#include <math.h>
+#include <wincompat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
+#ifdef __cplusplus
+}
+#endif
#define FRAMES_BUF 8
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;
}
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);
#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);
+#ifdef __cplusplus
+}
+#endif
+
#endif
\ No newline at end of file
--- /dev/null
+#include "wincompat.h"
\ No newline at end of file
--- /dev/null
+#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
--- /dev/null
+#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