From 4f1d0afdc79bdd8fb1b2d864c25a5d3382882b5b Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Thu, 31 Dec 2009 15:35:13 -0800 Subject: [PATCH] install --- intern/Global.cpp | 69 +- intern/Global.h | 5 +- intern/Thingy.cpp | 13 +- intern/jttoolkit.cpp | 2 +- media/move.txt | 4612 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 4680 insertions(+), 21 deletions(-) create mode 100644 media/move.txt diff --git a/intern/Global.cpp b/intern/Global.cpp index 7f3fa2d..0088d85 100755 --- a/intern/Global.cpp +++ b/intern/Global.cpp @@ -20,18 +20,29 @@ Global::Global() glEnable(GL_LINE_SMOOTH); glEnable(GL_POINT_SMOOTH); - glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); for(int i=0;i<10000;i++){ thingies.push_back(new Thingy()); thingies.back()->z = ((rnd[i+7] - .5) * 100000000); } - hideMouse(); - INC = 550; - toggleFullScreen(); + movecount = 0; + //toggleFullScreen(); + //hideMouse(); + + ifstream infile("media/move.txt"); + while( infile.good() ) { + int p; + infile >> p; + move.push_back(p); + } + + + cout << move.size() << endl; + } @@ -43,23 +54,50 @@ Global::~Global() void Global::loop() { vector::iterator it; + + int MPOS = move[movecount]; - INC += (704 - INC) * 0.001; - - int cnt = 0; + + if (movecount != move.size() + 1000) { + movecount++; + } + else { + rnd.clear(); + for(int i=0;i<1000;i++){ + rnd.push_back(randomFloat()); + } + vector::iterator it; + + int cnt = 0; + for(it=thingies.begin();it!=thingies.end();it++) + { + (*it)->resetRandoms(); + (*it)->z = ((rnd[cnt+7] - .5) * 100000000); + cnt++; + } + movecount = 0; + } + + for(int i=0; ix = rnd[i] * width(); thingies[i]->y = rnd[i+3] * height(); // position - thingies[i]->z += ((INC - (width() / 2 )) * .04); + + float ddd = .01; + if (movecount > 3000) { + ddd = .005; + } + + thingies[i]->z += (( MPOS - (width() / 2)) * ddd); thingies[i]->step(); thingies[i]->draw(); } - glColor4f(1, 1, 1, 0.1); + glColor4f(1, 1, 1, 0.03); glBegin(GL_LINE_STRIP); for(it = thingies.begin(); it != thingies.end(); it++) { (*it)->glVertex(); @@ -72,6 +110,10 @@ void Global::loop() (*it)->glVertex(); } glEnd(); + + + //cout << mouseX() << ",\n"; + } @@ -86,7 +128,7 @@ void Global::keyDown(int k, int special) void Global::mouseDown() { - /* +/* rnd.clear(); for(int i=0;i<1000;i++){ rnd.push_back(randomFloat()); @@ -97,10 +139,11 @@ void Global::mouseDown() for(it=thingies.begin();it!=thingies.end();it++) { (*it)->resetRandoms(); - (*it)->z = ((rnd[cnt+7] - .5) * 9000000); + (*it)->z = ((rnd[cnt+7] - .5) * 100000000); cnt++; - }*/ - cout << INC << endl; + } + */ + } diff --git a/intern/Global.h b/intern/Global.h index 4693edf..e052019 100755 --- a/intern/Global.h +++ b/intern/Global.h @@ -25,8 +25,9 @@ class Global{ static Global*instance; vectorthingies; vector rnd; - - float INC; + + int movecount; + vector move; void loop(); void keyDown(int k,int special); diff --git a/intern/Thingy.cpp b/intern/Thingy.cpp index c64d972..a5f3e45 100644 --- a/intern/Thingy.cpp +++ b/intern/Thingy.cpp @@ -19,6 +19,10 @@ Thingy::Thingy(){ dest.z = 0; this->copyFrom(dest); + + + + } void Thingy::resetRandoms(){ @@ -50,11 +54,11 @@ void Thingy::step(){ // (*this)+=JPoint( randomFloat()-0.5, randomFloat()-0.5, randomFloat()-0.5); - size += (destSize - size) * 0.01; + size += (destSize - size) * 0.005; - float xx = (dest.x-x) * .002; - float yy = (dest.y-y) * .002; - float zz = (dest.z-z) * .002; + float xx = (dest.x-x) * .0045; + float yy = (dest.y-y) * .0045; + float zz = (dest.z-z) * .0045; x += xx; y += yy; @@ -76,7 +80,6 @@ void Thingy::draw(){ float rot = sin(ticks() * .01 * rnd[5]) * 3.2; - glBegin(GL_LINE_LOOP); for(int i=0; i #include #include #include #include #define INIT_WINDOW_X 100 #define INIT_WINDOW_Y 100 #define INIT_WINDOW_WIDTH 810 #define INIT_WINDOW_HEIGHT 510 //#include "gl2ps.h" #if defined (__DARWIN__) #include #endif #define use_perspective #define VERBOSE 0 //turn this on and off for speed //---- user-global access functions int ticks(){return _ticks;} int width(){return _width;} int height(){return _height;} int mouseX(){return _mouseX;} int mouseY(){return _mouseY;} void setMouseX(long xx){_mouseX = xx;} void setMouseY(long yy){_mouseY = yy;} void ignoreMouse(int state){_ignoreMouse = state;} //-------------- void *threadFunc(void*stuff){ } //------------------------------------------------------------------------ void initfmod(){ /* if (FSOUND_GetVersion() < FMOD_VERSION){ printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); exit(1); } if(!FSOUND_Init(48000, 1024, FSOUND_INIT_GLOBALFOCUS)){ printf("%s\n",FMOD_ErrorString(FSOUND_GetError())); } */ } //------------------------------------------------------------------------ float friction(){return _friction;} void setFriction(float f){_friction = f;} float frequencyRange(){return _frequencyRange;} void setFrequencyRange(float f){_frequencyRange = f;} void drawUnitSquare(){ glBegin(GL_QUADS); glTexCoord2f(0,0);glVertex2f(0,0); glTexCoord2f(1,0);glVertex2f(1,0); glTexCoord2f(1,1);glVertex2f(1,1); glTexCoord2f(0,1);glVertex2f(0,1); glEnd(); } void drawUnitSquareSlightlySmaller(){ glBegin(GL_QUADS); glTexCoord2f(0.01,0.01);glVertex2f(0,0); glTexCoord2f(0.99,0.01);glVertex2f(1,0); glTexCoord2f(0.99,0.99);glVertex2f(1,1); glTexCoord2f(0.01,0.99);glVertex2f(0,1); glEnd(); } void toggleFullScreen(){ fullscreenmode=!fullscreenmode; if(fullscreenmode){ glutFullScreen(); } else { glutReshapeWindow(INIT_WINDOW_WIDTH,INIT_WINDOW_HEIGHT); glutPositionWindow(0,10); } } char* trimLeft(char*buff){ //count how many to offset backward int whiteCount = 0; for(int i=0;i0){ for(int b=0;b frameRate){ _execute_frame(); lastGlutFrameTime = glutGet(GLUT_ELAPSED_TIME); } */ } void timerFunc(int v) { //if(glutGet(GLUT_ELAPSED_TIME) - lastGlutFrameTime > frameRate){ _execute_frame(); //} glutTimerFunc(frameRate,timerFunc,0); } void preKeyDown(unsigned char k, int special){ if(special){ if(k==11){ toggleFullScreen(); } } else { //non special if(k==27){ //exit(0); }else if (k==KEY_DELETE || k==KEY_BACKSPACE){ } else if (k==6){//ctrl+f on a mac toggleFullScreen(); } else { } } } void keyboardDown(unsigned char k,int x,int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; } preKeyDown(k,0); jttoolkit_keyDown(k,0); } void keyboardUp(unsigned char k,int x,int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; } //printf("keyboardUp: %c %i\n",k); jttoolkit_keyUp(k,0); } void specialFunc(int k,int x,int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; } preKeyDown(k,1); jttoolkit_keyDown(k,1); } void mouseMotionFunc(int x, int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; }else{ ignored_mouseMove(x,y); } } void mousePassiveMotionFunc(int x, int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; }else{ ignored_mouseMove(x,y); } // printf("%i %i\n",_mouseX,_mouseY); } void mouseFunc(int button, int state, int x, int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; if(state==GLUT_DOWN){ jttoolkit_mouseDown(); } else { jttoolkit_mouseUp(); } }else{ if(state==GLUT_DOWN){ ignored_mouseDown(x,y); } else { ignored_mouseUp(x,y); } } } void viewPerspective(float angle){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(angle,(float)width()/(float)height(),0.0001,10000); //glFrustum(-2, 2, -2, 2, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); } void viewOrtho(){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,width(),-height(),0,-10000,10000); glMatrixMode(GL_MODELVIEW); } void reshape(int w,int h){ // if(glutGetWindow()==MainWindowID){ if(1){ _width = w; _height = h; // to keep it propertional & let the window stretch // glMatrixMode(GL_PROJECTION); // glLoadIdentity(); glViewport(0,0,w,h); // if(wdraw(); viewPerspective(90); glLoadIdentity(); } else { //then i can assume for now that it was the output console window. glViewport(0,0,w,h); float r = ((float)w/(float)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //#if defined(use_perspective) //gluPerspective(90,(float)w/(float)h,0.0001,10000); //#else glOrtho(0,w,h,0,-10000,10000); //#endif //glFrustum(-2, 2, -2, 2, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } // jt_resizeDrawBuffer(); } void jt_resizeDrawBuffer(){ // delete [] drawbuffer; // drawbuffer = new unsigned char[width()*height()*4]; } int main(int argc,char** argv){ glutInit(&argc,argv); glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGBA); glutInitWindowSize (INIT_WINDOW_WIDTH,INIT_WINDOW_HEIGHT); glutInitWindowPosition (INIT_WINDOW_X,INIT_WINDOW_Y); int gameMode = 0; if(argc>1){ for(int i=0;ipush((long)p); } void JTTessEnd(){ //FLUSH IT! tobj = gluNewTess(); _tessBind(); if(tesscache!=0){ gluTessBeginPolygon(tobj,NULL); gluTessBeginContour(tobj); for(int i=tessBase;icount ;i++){ // long t = tesscache->get(i); // switch(t){ // case TESSCACHE_NEWCONTOUR:break; // default: //printf("%i\n",t); //printf("%i\n",((GLdouble*)(t))[0]); //delete [] (GLdouble*)t;//i'm leaving this all in memory, but it's dangerous! //tessfreemem->push(t); //break; // } //} //delete tesscache; //tesscache = new Vector(); } else { //it WAS zero. //tesscache = new Vector(); } tessBase += tessPtr;//advance forward. tessPtr = 0; */ } void doTessErrorCheck(){ if(tessPtr+tessBase>tessmax){ printf("error:not enough memory allocated to JTTess",0); exit(0); } } void _tessBind(){ //#if defined (__DARWIN__) //#define TESSTYPE (GLvoid (*)(...)) //#else //typedef GLvoid ( *GluTessCallbackType)(...); //#define TESSTYPE reinterpret_cast //#endif /* gluTessCallback(tobj, GLU_TESS_VERTEX, TESSTYPE(glVertex3dv)); gluTessCallback(tobj, GLU_TESS_BEGIN, TESSTYPE(JTTess_beginCallback)); gluTessCallback(tobj, GLU_TESS_END, TESSTYPE(&JTTess_endCallback)); gluTessCallback(tobj, GLU_TESS_ERROR, TESSTYPE(JTTess_errorCallback)); gluTessCallback(tobj, GLU_TESS_COMBINE, TESSTYPE(JTTess_combineCallback)); gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE); */ } /* the callback routines registered by gluTessCallback() */ void JTTESSCALLBACK JTTess_combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut ){ GLdouble *vertex; int i; doTessErrorCheck(); vertex = tesscache[tessBase+tessPtr];//(GLdouble *) malloc(6 * sizeof(GLdouble)); tessPtr++; vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; for (i = 3; i < 7; i++) vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i] + weight[2] * vertex_data[2][i] + weight[3] * vertex_data[3][i]; *dataOut = vertex; } void JTTESSCALLBACK JTTess_beginCallback(GLenum which){ glBegin(which); } void JTTESSCALLBACK JTTess_endCallback(void) { glEnd(); } void JTTESSCALLBACK JTTess_errorCallback(GLenum errorCode) { const GLubyte *estring; estring = gluErrorString(errorCode); fprintf (stderr, "Tessellation Error: %s\n", estring); exit (0); } /* new callback routines registered by these calls */ void JTTESSCALLBACK JTTess_vertexCallback(GLvoid *vertex){ const GLdouble *pointer; pointer = (GLdouble *) vertex; glColor3dv(pointer+3); glVertex3dv((const GLdouble*)vertex); } JoshFont *getFont(){ return font; } JPoint mouse(){ return JPoint(mouseX(),mouseY(),0); } /** saves the screen to a file. format support provided by image magick. supported formats: http://www.imagemagick.org/script/formats.php */ void saveScreen(char *filename){ using namespace Magick; if(rawpixels==NULL){ rawpixels = new unsigned char[width()*height()*3]; } glReadPixels(0,0,width(),height(), GL_RGB , GL_UNSIGNED_BYTE ,rawpixels); /* //reverse the alpha vals. for(int i=0;iflip(); return image; } /* allocates new storage for an 8-bit image of the specified dimensions */ png_bytep* make_pixels(int width, int height) { int pixel_size = 3; //printf("debug debug debug 1\n",0); png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { return NULL; } //printf("debug debug debug 2\n",0); png_bytep *row_pointers = (unsigned char **)png_malloc(png_ptr, height*sizeof(png_bytep)); for (int i = 0; i < height; i++) row_pointers[i] = (unsigned char *)png_malloc(png_ptr, width*pixel_size); //printf("debug debug debug 3\n",0); return row_pointers; } //-------------------------------------------------------------------------------------------- void jt_frameRate(unsigned long f){ frameRate = f; } void roundedRect(int gl_style,float x1,float y1,float x2,float y2,float radius,int steps){ float inc = (PI*0.5)/steps; glBegin(gl_style); //draw a quarter circle here. for(int i=0;i #include #include #include #include #define INIT_WINDOW_X 0 #define INIT_WINDOW_Y 0 #define INIT_WINDOW_WIDTH 1024 #define INIT_WINDOW_HEIGHT 768 //#include "gl2ps.h" #if defined (__DARWIN__) #include #endif #define use_perspective #define VERBOSE 0 //turn this on and off for speed //---- user-global access functions int ticks(){return _ticks;} int width(){return _width;} int height(){return _height;} int mouseX(){return _mouseX;} int mouseY(){return _mouseY;} void setMouseX(long xx){_mouseX = xx;} void setMouseY(long yy){_mouseY = yy;} void ignoreMouse(int state){_ignoreMouse = state;} //-------------- void *threadFunc(void*stuff){ } //------------------------------------------------------------------------ void initfmod(){ /* if (FSOUND_GetVersion() < FMOD_VERSION){ printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); exit(1); } if(!FSOUND_Init(48000, 1024, FSOUND_INIT_GLOBALFOCUS)){ printf("%s\n",FMOD_ErrorString(FSOUND_GetError())); } */ } //------------------------------------------------------------------------ float friction(){return _friction;} void setFriction(float f){_friction = f;} float frequencyRange(){return _frequencyRange;} void setFrequencyRange(float f){_frequencyRange = f;} void drawUnitSquare(){ glBegin(GL_QUADS); glTexCoord2f(0,0);glVertex2f(0,0); glTexCoord2f(1,0);glVertex2f(1,0); glTexCoord2f(1,1);glVertex2f(1,1); glTexCoord2f(0,1);glVertex2f(0,1); glEnd(); } void drawUnitSquareSlightlySmaller(){ glBegin(GL_QUADS); glTexCoord2f(0.01,0.01);glVertex2f(0,0); glTexCoord2f(0.99,0.01);glVertex2f(1,0); glTexCoord2f(0.99,0.99);glVertex2f(1,1); glTexCoord2f(0.01,0.99);glVertex2f(0,1); glEnd(); } void toggleFullScreen(){ fullscreenmode=!fullscreenmode; if(fullscreenmode){ glutFullScreen(); } else { glutReshapeWindow(INIT_WINDOW_WIDTH,INIT_WINDOW_HEIGHT); glutPositionWindow(0,10); } } char* trimLeft(char*buff){ //count how many to offset backward int whiteCount = 0; for(int i=0;i0){ for(int b=0;b frameRate){ _execute_frame(); lastGlutFrameTime = glutGet(GLUT_ELAPSED_TIME); } */ } void timerFunc(int v) { //if(glutGet(GLUT_ELAPSED_TIME) - lastGlutFrameTime > frameRate){ _execute_frame(); //} glutTimerFunc(frameRate,timerFunc,0); } void preKeyDown(unsigned char k, int special){ if(special){ if(k==11){ toggleFullScreen(); } } else { //non special if(k==27){ //exit(0); }else if (k==KEY_DELETE || k==KEY_BACKSPACE){ } else if (k==6){//ctrl+f on a mac toggleFullScreen(); } else { } } } void keyboardDown(unsigned char k,int x,int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; } preKeyDown(k,0); jttoolkit_keyDown(k,0); } void keyboardUp(unsigned char k,int x,int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; } //printf("keyboardUp: %c %i\n",k); jttoolkit_keyUp(k,0); } void specialFunc(int k,int x,int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; } preKeyDown(k,1); jttoolkit_keyDown(k,1); } void mouseMotionFunc(int x, int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; }else{ ignored_mouseMove(x,y); } } void mousePassiveMotionFunc(int x, int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; }else{ ignored_mouseMove(x,y); } // printf("%i %i\n",_mouseX,_mouseY); } void mouseFunc(int button, int state, int x, int y){ if(!_ignoreMouse){ _mouseX=x; _mouseY=y; if(state==GLUT_DOWN){ jttoolkit_mouseDown(); } else { jttoolkit_mouseUp(); } }else{ if(state==GLUT_DOWN){ ignored_mouseDown(x,y); } else { ignored_mouseUp(x,y); } } } void viewPerspective(float angle){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(angle,(float)width()/(float)height(),0.0001,10000); //glFrustum(-2, 2, -2, 2, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); } void viewOrtho(){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,width(),-height(),0,-10000,10000); glMatrixMode(GL_MODELVIEW); } void reshape(int w,int h){ // if(glutGetWindow()==MainWindowID){ if(1){ _width = w; _height = h; // to keep it propertional & let the window stretch // glMatrixMode(GL_PROJECTION); // glLoadIdentity(); glViewport(0,0,w,h); // if(wdraw(); viewPerspective(90); glLoadIdentity(); } else { //then i can assume for now that it was the output console window. glViewport(0,0,w,h); float r = ((float)w/(float)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //#if defined(use_perspective) //gluPerspective(90,(float)w/(float)h,0.0001,10000); //#else glOrtho(0,w,h,0,-10000,10000); //#endif //glFrustum(-2, 2, -2, 2, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } // jt_resizeDrawBuffer(); } void jt_resizeDrawBuffer(){ // delete [] drawbuffer; // drawbuffer = new unsigned char[width()*height()*4]; } int main(int argc,char** argv){ glutInit(&argc,argv); glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGBA); glutInitWindowSize (INIT_WINDOW_WIDTH,INIT_WINDOW_HEIGHT); glutInitWindowPosition (INIT_WINDOW_X,INIT_WINDOW_Y); int gameMode = 0; if(argc>1){ for(int i=0;ipush((long)p); } void JTTessEnd(){ //FLUSH IT! tobj = gluNewTess(); _tessBind(); if(tesscache!=0){ gluTessBeginPolygon(tobj,NULL); gluTessBeginContour(tobj); for(int i=tessBase;icount ;i++){ // long t = tesscache->get(i); // switch(t){ // case TESSCACHE_NEWCONTOUR:break; // default: //printf("%i\n",t); //printf("%i\n",((GLdouble*)(t))[0]); //delete [] (GLdouble*)t;//i'm leaving this all in memory, but it's dangerous! //tessfreemem->push(t); //break; // } //} //delete tesscache; //tesscache = new Vector(); } else { //it WAS zero. //tesscache = new Vector(); } tessBase += tessPtr;//advance forward. tessPtr = 0; */ } void doTessErrorCheck(){ if(tessPtr+tessBase>tessmax){ printf("error:not enough memory allocated to JTTess",0); exit(0); } } void _tessBind(){ //#if defined (__DARWIN__) //#define TESSTYPE (GLvoid (*)(...)) //#else //typedef GLvoid ( *GluTessCallbackType)(...); //#define TESSTYPE reinterpret_cast //#endif /* gluTessCallback(tobj, GLU_TESS_VERTEX, TESSTYPE(glVertex3dv)); gluTessCallback(tobj, GLU_TESS_BEGIN, TESSTYPE(JTTess_beginCallback)); gluTessCallback(tobj, GLU_TESS_END, TESSTYPE(&JTTess_endCallback)); gluTessCallback(tobj, GLU_TESS_ERROR, TESSTYPE(JTTess_errorCallback)); gluTessCallback(tobj, GLU_TESS_COMBINE, TESSTYPE(JTTess_combineCallback)); gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE); */ } /* the callback routines registered by gluTessCallback() */ void JTTESSCALLBACK JTTess_combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut ){ GLdouble *vertex; int i; doTessErrorCheck(); vertex = tesscache[tessBase+tessPtr];//(GLdouble *) malloc(6 * sizeof(GLdouble)); tessPtr++; vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; for (i = 3; i < 7; i++) vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i] + weight[2] * vertex_data[2][i] + weight[3] * vertex_data[3][i]; *dataOut = vertex; } void JTTESSCALLBACK JTTess_beginCallback(GLenum which){ glBegin(which); } void JTTESSCALLBACK JTTess_endCallback(void) { glEnd(); } void JTTESSCALLBACK JTTess_errorCallback(GLenum errorCode) { const GLubyte *estring; estring = gluErrorString(errorCode); fprintf (stderr, "Tessellation Error: %s\n", estring); exit (0); } /* new callback routines registered by these calls */ void JTTESSCALLBACK JTTess_vertexCallback(GLvoid *vertex){ const GLdouble *pointer; pointer = (GLdouble *) vertex; glColor3dv(pointer+3); glVertex3dv((const GLdouble*)vertex); } JoshFont *getFont(){ return font; } JPoint mouse(){ return JPoint(mouseX(),mouseY(),0); } /** saves the screen to a file. format support provided by image magick. supported formats: http://www.imagemagick.org/script/formats.php */ void saveScreen(char *filename){ using namespace Magick; if(rawpixels==NULL){ rawpixels = new unsigned char[width()*height()*3]; } glReadPixels(0,0,width(),height(), GL_RGB , GL_UNSIGNED_BYTE ,rawpixels); /* //reverse the alpha vals. for(int i=0;iflip(); return image; } /* allocates new storage for an 8-bit image of the specified dimensions */ png_bytep* make_pixels(int width, int height) { int pixel_size = 3; //printf("debug debug debug 1\n",0); png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { return NULL; } //printf("debug debug debug 2\n",0); png_bytep *row_pointers = (unsigned char **)png_malloc(png_ptr, height*sizeof(png_bytep)); for (int i = 0; i < height; i++) row_pointers[i] = (unsigned char *)png_malloc(png_ptr, width*pixel_size); //printf("debug debug debug 3\n",0); return row_pointers; } //-------------------------------------------------------------------------------------------- void jt_frameRate(unsigned long f){ frameRate = f; } void roundedRect(int gl_style,float x1,float y1,float x2,float y2,float radius,int steps){ float inc = (PI*0.5)/steps; glBegin(gl_style); //draw a quarter circle here. for(int i=0;i