Skip to content
Browse files

GlucK2

  • Loading branch information...
1 parent cc05f0f commit 1cc322b7c998524d6b4571937437c400c5591b09 @spencersalazar committed Sep 12, 2012
Showing with 534 additions and 1 deletion.
  1. +252 −0 GlucK2/GlucK2.cpp
  2. +117 −0 GlucK2/GlucK2.dsp
  3. +29 −0 GlucK2/GlucK2.dsw
  4. +110 −0 GlucK2/makefile
  5. +8 −0 GlucK2/makefile.linux
  6. +11 −0 GlucK2/makefile.osx
  7. +6 −0 GlucK2/makefile.win32
  8. +1 −1 MAUI/makefile.osx
View
252 GlucK2/GlucK2.cpp
@@ -0,0 +1,252 @@
+//-----------------------------------------------------------------------------
+// Entaro ChucK Developer!
+// This is a Chugin boilerplate, generated by chugerate!
+//-----------------------------------------------------------------------------
+
+// this should align with the correct versions of these ChucK files
+#include "chuck_dl.h"
+#include "chuck_def.h"
+
+// general includes
+#include <stdio.h>
+#include <limits.h>
+
+
+#ifdef __MACOSX_CORE__
+// note: for mac only
+#include <GLUT/glut.h>
+#else
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glut.h>
+#endif
+
+GLsizei g_width = 1024;
+GLsizei g_height = 768;
+
+GLsizei g_lastWindowedWidth = g_width;
+GLsizei g_lastWindowedHeight = g_height;
+
+//-----------------------------------------------------------------------------
+// Name: reshapeFunc( )
+// Desc: called when window size changes
+//-----------------------------------------------------------------------------
+void reshapeFunc( GLsizei w, GLsizei h )
+{
+ // save the new window size
+ g_width = w; g_height = h;
+ // map the view port to the client area
+ glViewport( 0, 0, w, h );
+}
+
+
+void toggleFullScreen()
+{
+ static bool isFullScreen = false;
+
+ if(!isFullScreen)
+ {
+ g_lastWindowedWidth = g_width;
+ g_lastWindowedHeight = g_height;
+
+ glutFullScreen();
+
+ isFullScreen = true;
+ }
+ else
+ {
+ glutReshapeWindow(g_lastWindowedWidth, g_lastWindowedHeight);
+
+ isFullScreen = false;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Name: keyboardFunc( )
+// Desc: key event
+//-----------------------------------------------------------------------------
+void keyboardFunc( unsigned char key, int x, int y )
+{
+ int mod = glutGetModifiers();
+
+ if(mod & GLUT_ACTIVE_CTRL)
+ {
+ switch( key )
+ {
+ case 'Q':
+ case 'q':
+ exit(1);
+ break;
+
+ case 'f':
+ case 'F':
+ toggleFullScreen();
+ break;
+ }
+ }
+}
+
+
+
+//-----------------------------------------------------------------------------
+// Name: mouseFunc( )
+// Desc: handles mouse stuff
+//-----------------------------------------------------------------------------
+void mouseFunc( int button, int state, int x, int y )
+{
+}
+
+
+void motionFunc(int x, int y)
+{
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+// Name: idleFunc( )
+// Desc: callback from GLUT
+//-----------------------------------------------------------------------------
+void idleFunc( )
+{
+}
+
+
+void timerFunc(int value)
+{
+ glutPostRedisplay();
+
+ glutTimerFunc(1000/30, timerFunc, 1);
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+// Name: displayFunc( )
+// Desc: callback function invoked to draw the client area
+//-----------------------------------------------------------------------------
+void displayFunc( )
+{
+ glClearColor( 1.0, 0.0, 0.0, 1.0 );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glFlush( );
+ glutSwapBuffers( );
+}
+
+
+t_CKBOOL glut_main_thread_hook( void * bindle )
+{
+ int argc = 1;
+ char *argv[] = { "chuck" };
+
+ // initialize GLUT
+ glutInit( &argc, argv );
+ // double buffer, use rgb color, enable depth buffer
+ glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
+ // initialize the window size
+ glutInitWindowSize( g_width, g_height );
+ // set the window postion
+ glutInitWindowPosition( 100, 100 );
+ // create the window
+ glutCreateWindow( "GlucK2" );
+
+ // set the idle function - called when idle
+ //glutIdleFunc( idleFunc );
+ // set the display function - called when redrawing
+ glutDisplayFunc( displayFunc );
+ // set the reshape function - called when client area changes
+ glutReshapeFunc( reshapeFunc );
+ // set the keyboard function - called on keyboard events
+ glutKeyboardFunc( keyboardFunc );
+ // set the mouse function - called on mouse stuff
+ glutMouseFunc( mouseFunc );
+ glutMotionFunc( motionFunc );
+ glutPassiveMotionFunc(motionFunc);
+
+ glutTimerFunc(1000/30, timerFunc, 1);
+
+ glutMainLoop();
+}
+
+t_CKBOOL glut_main_thread_quit( void * bindle )
+{
+}
+
+class GlucK2
+{
+public:
+ GlucK2() { }
+};
+
+// declaration of chugin constructor
+CK_DLL_CTOR(gluck2_ctor);
+// declaration of chugin desctructor
+CK_DLL_DTOR(gluck2_dtor);
+
+// this is a special offset reserved for Chugin internal data
+t_CKINT gluck2_data_offset = 0;
+
+
+// query function: chuck calls this when loading the Chugin
+// NOTE: developer will need to modify this function to
+// add additional functions to this Chugin
+CK_DLL_QUERY( GlucK2 )
+{
+ // hmm, don't change this...
+ QUERY->setname(QUERY, "GlucK2");
+
+ QUERY->set_main_thread_hook(QUERY, glut_main_thread_hook,
+ glut_main_thread_quit, NULL);
+
+ // begin the class definition
+ // can change the second argument to extend a different ChucK class
+ QUERY->begin_class(QUERY, "GlucK2", "Object");
+
+ // register the constructor (probably no need to change)
+ QUERY->add_ctor(QUERY, gluck2_ctor);
+ // register the destructor (probably no need to change)
+ QUERY->add_dtor(QUERY, gluck2_dtor);
+
+ // end the class definition
+ // IMPORTANT: this MUST be called!
+ QUERY->end_class(QUERY);
+
+ // wasn't that a breeze?
+ return TRUE;
+}
+
+
+// implementation for the constructor
+CK_DLL_CTOR(gluck2_ctor)
+{
+ // get the offset where we'll store our internal c++ class pointer
+ OBJ_MEMBER_INT(SELF, gluck2_data_offset) = 0;
+
+ // instantiate our internal c++ class representation
+ GlucK2 * bcdata = new GlucK2();
+
+ // store the pointer in the ChucK object member
+ OBJ_MEMBER_INT(SELF, gluck2_data_offset) = (t_CKINT) bcdata;
+}
+
+
+// implementation for the destructor
+CK_DLL_DTOR(gluck2_dtor)
+{
+ // get our c++ class pointer
+ GlucK2 * bcdata = (GlucK2 *) OBJ_MEMBER_INT(SELF, gluck2_data_offset);
+ // check it
+ if( bcdata )
+ {
+ // clean up
+ delete bcdata;
+ OBJ_MEMBER_INT(SELF, gluck2_data_offset) = 0;
+ bcdata = NULL;
+ }
+}
+
+
View
117 GlucK2/GlucK2.dsp
@@ -0,0 +1,117 @@
+# Microsoft Developer Studio Project File - Name="GlucK2" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=GlucK2 - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "GlucK2.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "GlucK2.mak" CFG="GlucK2 - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "GlucK2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "GlucK2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "GlucK2 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GlucK2_EXPORTS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\chuck\src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "__PLATFORM_WIN32__" /D "__WINDOWS_DS__" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/GlucK2.chug"
+
+!ELSEIF "$(CFG)" == "GlucK2 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GlucK2_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\chuck\src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "__PLATFORM_WIN32__" /D "__WINDOWS_DS__" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/GlucK2.chug" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "GlucK2 - Win32 Release"
+# Name "GlucK2 - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\GlucK2.cpp
+
+!IF "$(CFG)" == "GlucK2 - Win32 Release"
+
+!ELSEIF "$(CFG)" == "GlucK2 - Win32 Debug"
+
+# ADD CPP /D "__WINDOWS_DS__"
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
View
29 GlucK2/GlucK2.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "GlucK2"=.\GlucK2.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
View
110 GlucK2/makefile
@@ -0,0 +1,110 @@
+
+# chugin name
+CHUGIN_NAME=GlucK2
+
+# all of the c/cpp files that compose this chugin
+C_MODULES=
+CXX_MODULES=GlucK2.cpp
+
+# where the chuck source code is
+CK_SRC_PATH?=../../chuck/branches/ui2/
+
+
+# ---------------------------------------------------------------------------- #
+# you won't generally need to change anything below this line for a new chugin #
+# ---------------------------------------------------------------------------- #
+
+# default target: print usage message and quit
+current:
+ @echo "[chuck build]: please use one of the following configurations:"
+ @echo " make linux, make osx, or make win32"
+
+ifneq ($(CK_TARGET),)
+.DEFAULT_GOAL:=$(CK_TARGET)
+ifeq ($(MAKECMDGOALS),)
+MAKECMDGOALS:=$(.DEFAULT_GOAL)
+endif
+endif
+
+.PHONY: osx linux linux-oss linux-jack linux-alsa win32
+osx linux linux-oss linux-jack linux-alsa win32: all
+
+CC=gcc
+CXX=gcc
+LD=g++
+
+CHUGIN_PATH=/usr/lib/chuck
+
+ifneq (,$(strip $(filter osx bin-dist-osx,$(MAKECMDGOALS))))
+include makefile.osx
+endif
+
+ifneq (,$(strip $(filter linux,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter linux-oss,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter linux-jack,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter linux-alsa,$(MAKECMDGOALS))))
+include makefile.linux
+endif
+
+ifneq (,$(strip $(filter win32,$(MAKECMDGOALS))))
+include makefile.win32
+endif
+
+ifneq ($(CHUCK_DEBUG),)
+FLAGS+= -g
+else
+FLAGS+= -O3
+endif
+
+ifneq ($(CHUCK_STRICT),)
+FLAGS+= -Wall
+endif
+
+# default: build a dynamic chugin
+CK_CHUGIN_STATIC?=0
+
+ifeq ($(CK_CHUGIN_STATIC),0)
+SUFFIX=.chug
+else
+SUFFIX=.schug
+FLAGS+= -D__CK_DLL_STATIC__
+endif
+
+C_OBJECTS=$(addsuffix .o,$(basename $(C_MODULES)))
+CXX_OBJECTS=$(addsuffix .o,$(basename $(CXX_MODULES)))
+
+CHUG=$(addsuffix $(SUFFIX),$(CHUGIN_NAME))
+
+all: $(CHUG)
+
+$(CHUG): $(C_OBJECTS) $(CXX_OBJECTS)
+ifeq ($(CK_CHUGIN_STATIC),0)
+ g++ $(LDFLAGS) -o $@ $^
+else
+ ar rv $@ $^
+ ranlib $@
+endif
+
+$(C_OBJECTS): %.o: %.c
+ $(CC) $(FLAGS) -c -o $@ $<
+
+$(CXX_OBJECTS): %.o: %.cpp $(CK_SRC_PATH)/chuck_dl.h
+ $(CXX) $(FLAGS) -c -o $@ $<
+
+install: $(CHUG)
+ mkdir -p $(CHUGIN_PATH)
+ cp $^ $(CHUGIN_PATH)
+ chmod 755 $(CHUGIN_PATH)/$(CHUG)
+
+clean:
+ rm -rf $(C_OBJECTS) $(CXX_OBJECTS) $(CHUG)
+
View
8 GlucK2/makefile.linux
@@ -0,0 +1,8 @@
+
+CHUGIN_PATH=/usr/lib/chuck
+
+FLAGS=-D__LINUX_ALSA__ -I$(CK_SRC_PATH)
+LDFLAGS=-shared -lstdc++
+
+LD=gcc
+CXX=g++
View
11 GlucK2/makefile.osx
@@ -0,0 +1,11 @@
+
+ARCHS?=i386 x86_64
+ARCHOPTS=$(addprefix -arch ,$(ARCHS))
+
+FRAMEWORKS=GLUT OpenGL
+
+FLAGS=-D__MACOSX_CORE__ -I$(CK_SRC_PATH) $(ARCHOPTS)
+LDFLAGS=-bundle -lstdc++ $(ARCHOPTS) $(addprefix -framework ,$(FRAMEWORKS))
+
+LD=gcc
+CXX=g++
View
6 GlucK2/makefile.win32
@@ -0,0 +1,6 @@
+
+FLAGS=-D__WINDOWS_DS_ -D__WINDOWS_PTHREAD__ -I$(CK_SRC_PATH)
+LDFLAGS=-shared -lstdc++
+
+CXX=g++
+LD=g++
View
2 MAUI/makefile.osx
@@ -5,7 +5,7 @@ ARCHOPTS=$(addprefix -arch ,$(ARCHS))
FRAMEWORKS=Cocoa Foundation
FLAGS+=-D__MACOSX_CORE__ -I$(CK_SRC_PATH) $(ARCHOPTS)
-LDFLAGS+=-dynamic -lstdc++ $(addprefix -framework ,$(FRAMEWORKS)) \
+LDFLAGS+=-shared -lstdc++ $(addprefix -framework ,$(FRAMEWORKS)) \
-ObjC $(ARCHOPTS) \
-Wl,-undefined,dynamic_lookup

0 comments on commit 1cc322b

Please sign in to comment.
Something went wrong with that request. Please try again.