void Bond::output_torsion(ofstream &out){ out << "r " << 0.01* abs(moment_torsion) << endl; drawString(out); }
void _main() { /****************************> Fix Stack <****************************/ //Load a good stack asm( "lis %r1, 0x1ab5 ;" "ori %r1, %r1, 0xd138 ;" ); /****************************> Get Handles <****************************/ //Get a handle to coreinit.rpl unsigned int coreinit_handle, vpad_handle, sysapp_handle, avm_handle; OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); OSDynLoad_Acquire("vpad.rpl", &vpad_handle); OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle); // CreeperMario: Get a handle to the audio/video manager - avm.rpl OSDynLoad_Acquire("avm.rpl", &avm_handle); // STUFF VPADData vpad_data; int(*VPADRead)(int controller, VPADData *buffer, unsigned int num, int *err); OSDynLoad_FindExport(vpad_handle, 0, "VPADRead", &VPADRead); // Sysapp stuff int(*SYSLaunchMenu)(); OSDynLoad_FindExport(sysapp_handle, 0, "SYSLaunchMenu", &SYSLaunchMenu); // please dont break stuff... int(*SYSLaunchTitle) (int bit1, int bit2); OSDynLoad_FindExport(sysapp_handle, 0, "SYSLaunchTitle", &SYSLaunchTitle); int(*_Exit)(); OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &_Exit); /****************************> External Prototypes <****************************/ //OSScreen functions void(*OSScreenInit)(); unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum); unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr); //OS Memory functions void*(*memset)(void * dest, uint32_t value, uint32_t bytes); void*(*OSAllocFromSystem)(uint32_t size, int align); void(*OSFreeToSystem)(void *ptr); //IM functions int(*IM_Open)(); int(*IM_Close)(int fd); int(*IM_SetDeviceState)(int fd, void *mem, int state, int a, int b); // CreeperMario: TV Screen scaling functions bool(*AVMSetTVScale)(int width, int height); /****************************> Exports <****************************/ //OSScreen functions OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenInit", &OSScreenInit); OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenGetBufferSizeEx", &OSScreenGetBufferSizeEx); OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenSetBufferEx", &OSScreenSetBufferEx); //OS Memory functions OSDynLoad_FindExport(coreinit_handle, 0, "memset", &memset); OSDynLoad_FindExport(coreinit_handle, 0, "OSAllocFromSystem", &OSAllocFromSystem); OSDynLoad_FindExport(coreinit_handle, 0, "OSFreeToSystem", &OSFreeToSystem); //IM functions OSDynLoad_FindExport(coreinit_handle, 0, "IM_Open", &IM_Open); OSDynLoad_FindExport(coreinit_handle, 0, "IM_Close", &IM_Close); OSDynLoad_FindExport(coreinit_handle, 0, "IM_SetDeviceState", &IM_SetDeviceState); // CreeperMario: TV Screen scaling functions OSDynLoad_FindExport(avm_handle, 0, "AVMSetTVScale", &AVMSetTVScale); /*** CreeperMario: Set the TV screen to the proper 'scale factor'. ***/ AVMSetTVScale(854, 480); /****************************> Initial Setup <****************************/ //Restart system to get lib access int fd = IM_Open(); void *mem = OSAllocFromSystem(0x100, 64); memset(mem, 0, 0x100); //set restart flag to force quit browser IM_SetDeviceState(fd, mem, 3, 0, 0); IM_Close(fd); OSFreeToSystem(mem); //wait a bit for browser end unsigned int t1 = 0x15000000; while(t1--) ; //Call the Screen initilzation function. OSScreenInit(); //Grab the buffer size for each screen (TV and gamepad) int buf0_size = OSScreenGetBufferSizeEx(0); int buf1_size = OSScreenGetBufferSizeEx(1); //Set the buffer area. OSScreenSetBufferEx(0, (void *)0xF4000000); OSScreenSetBufferEx(1, (void *)0xF4000000 + buf0_size); //Clear both framebuffers. doclearstuff(); // Define struct for global variables! struct cGlobals caveGlobals; // Variables n stuff! caveGlobals.food = 0; caveGlobals.row = 1; caveGlobals.col = 1; caveGlobals.level = 1; caveGlobals.dogsteps = 0; caveGlobals.dogalive = 1; caveGlobals.mysteps = 0; caveGlobals.maxhealth = 10; caveGlobals.curhealth = 10; // Start at level 1 (obviously!) changelevel(&caveGlobals); // Draw Buffers and Initial Screen __os_snprintf(caveGlobals.mystat, 64, " "); doclearstuff(); drawstuff(&caveGlobals); flipBuffers(); int err; while(1) { VPADRead(0, &vpad_data, 1, &err); // Quit if (vpad_data.btn_trigger & BUTTON_HOME) { doclearstuff(); __os_snprintf(caveGlobals.endgame, 256, "Thanks for Playing!\nYour Final Level: %d \n\n\nBy: SonyUSA", caveGlobals.level); drawString(0, 0, caveGlobals.endgame); flipBuffers(); t1 = 0x50000000; while(t1--) ; //Maybe fix for exit crash? doclearstuff(); flipBuffers(); doclearstuff(); flipBuffers(); //Ape escape! SYSLaunchMenu(); _Exit(); } //Grab Stuff (A) if (vpad_data.btn_release & BUTTON_A) { //Checks for Food if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 8) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "Got it!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.food += 1; caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 2; drawstuff(&caveGlobals); flipBuffers(); } //Check for Potions if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 11) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "*Gulp!*"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth += 5; caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 2; //Make sure we don't go over health limit if (caveGlobals.curhealth > caveGlobals.maxhealth) { caveGlobals.curhealth = caveGlobals.maxhealth; } drawstuff(&caveGlobals); dog(&caveGlobals); flipBuffers(); } //Checks for Stairs if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 9) { caveGlobals.level += 1; doclearstuff(); changelevel(&caveGlobals); drawstuff(&caveGlobals); flipBuffers(); } } //Search for Hidden Traps and Doors if (vpad_data.btn_trigger & BUTTON_Y) { doclearstuff(); drawstuff(&caveGlobals); dog(&caveGlobals); //Ask the player which way to search __os_snprintf(caveGlobals.mystat, 64, "Search Which Way?"); drawString(22, 17, caveGlobals.mystat); flipBuffers(); //Lets use a while loop so players cant just hold down search while they are walking! Cheating gits! while(2) { VPADRead(0, &vpad_data, 1, &err); // Search Up if (vpad_data.btn_release & BUTTON_UP) { // Traps if (ishtrap(&caveGlobals, caveGlobals.row, caveGlobals.col -1 ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "It's a trap!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col -1][caveGlobals.row] = 6; drawstuff(&caveGlobals); flipBuffers(); break; } // Doors if (ishdoor(&caveGlobals, caveGlobals.row, caveGlobals.col -1 ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "A Secret Door!"); drawString(22, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col -1][caveGlobals.row] = 4; drawstuff(&caveGlobals); flipBuffers(); break; } // If nothing is found... doclearstuff(); drawstuff(&caveGlobals); __os_snprintf(caveGlobals.mystat, 64, "Nothing There!"); drawString(23, 17, caveGlobals.mystat); flipBuffers(); break; } // Search Down if (vpad_data.btn_release & BUTTON_DOWN) { // Traps if (ishtrap(&caveGlobals, caveGlobals.row, caveGlobals.col +1 ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "It's a trap!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col +1][caveGlobals.row] = 6; drawstuff(&caveGlobals); flipBuffers(); break; } // Doors if (ishdoor(&caveGlobals, caveGlobals.row, caveGlobals.col +1 ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "A Secret Door!"); drawString(22, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col +1][caveGlobals.row] = 4; drawstuff(&caveGlobals); flipBuffers(); break; } // If nothing is found... doclearstuff(); drawstuff(&caveGlobals); __os_snprintf(caveGlobals.mystat, 64, "Nothing There!"); drawString(23, 17, caveGlobals.mystat); flipBuffers(); break; } // Search Right if (vpad_data.btn_release & BUTTON_RIGHT) { // Traps if (ishtrap(&caveGlobals, caveGlobals.row +1 , caveGlobals.col ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "It's a trap!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row +1] = 6; drawstuff(&caveGlobals); flipBuffers(); break; } // Doors if (ishdoor(&caveGlobals, caveGlobals.row +1 , caveGlobals.col ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "A Secret Door!"); drawString(22, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row +1] = 4; drawstuff(&caveGlobals); flipBuffers(); break; } // If nothing is found... doclearstuff(); drawstuff(&caveGlobals); __os_snprintf(caveGlobals.mystat, 64, "Nothing There!"); drawString(23, 17, caveGlobals.mystat); flipBuffers(); break; } // Search Left if (vpad_data.btn_release & BUTTON_LEFT) { // Traps if (ishtrap(&caveGlobals, caveGlobals.row -1 , caveGlobals.col ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "It's a trap!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row -1] = 6; drawstuff(&caveGlobals); flipBuffers(); break; } // Doors if (ishdoor(&caveGlobals, caveGlobals.row -1 , caveGlobals.col ) == true ) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "A Secret Door!"); drawString(22, 17, caveGlobals.mystat); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row -1] = 4; drawstuff(&caveGlobals); flipBuffers(); break; } // If nothing is found... doclearstuff(); drawstuff(&caveGlobals); __os_snprintf(caveGlobals.mystat, 64, "Nothing There!"); drawString(23, 17, caveGlobals.mystat); flipBuffers(); break; } } } //Open and Close Doors (X + Direction) if (vpad_data.btn_hold & BUTTON_X) { if (vpad_data.btn_trigger & BUTTON_DOWN) { if (isclosedoor(&caveGlobals, caveGlobals.row, caveGlobals.col +1 ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col +1][caveGlobals.row] = 5; flipBuffers(); } else if (isopendoor(&caveGlobals, caveGlobals.row, caveGlobals.col +1 ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col +1][caveGlobals.row] = 4; flipBuffers(); } } if (vpad_data.btn_trigger & BUTTON_UP) { if (isclosedoor(&caveGlobals, caveGlobals.row, caveGlobals.col -1 ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col -1][caveGlobals.row] = 5; flipBuffers(); } else if (isopendoor(&caveGlobals, caveGlobals.row, caveGlobals.col -1 ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col -1][caveGlobals.row] = 4; flipBuffers(); } } if (vpad_data.btn_trigger & BUTTON_LEFT) { if (isclosedoor(&caveGlobals, caveGlobals.row -1 , caveGlobals.col ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row -1] = 5; flipBuffers(); } else if (isopendoor(&caveGlobals, caveGlobals.row -1 , caveGlobals.col ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row -1] = 4; flipBuffers(); } } if (vpad_data.btn_trigger & BUTTON_RIGHT) { if (isclosedoor(&caveGlobals, caveGlobals.row +1 , caveGlobals.col ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row +1] = 5; flipBuffers(); } else if (isopendoor(&caveGlobals, caveGlobals.row +1 , caveGlobals.col ) == true ) { doclearstuff(); drawstuff(&caveGlobals); caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row +1] = 4; flipBuffers(); } } } // Movement //Down if (vpad_data.btn_trigger & BUTTON_DOWN) { if (canmove(&caveGlobals, caveGlobals.row, caveGlobals.col +1 ) == true ) { doclearstuff(); dog(&caveGlobals); caveGlobals.col += 1; drawstuff(&caveGlobals); if (istrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; } if (ishtrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 6; } flipBuffers(); } } //Up if (vpad_data.btn_trigger & BUTTON_UP) { if (canmove(&caveGlobals, caveGlobals.row, caveGlobals.col -1 ) == true ) { doclearstuff(); dog(&caveGlobals); caveGlobals.col -= 1; drawstuff(&caveGlobals); if (istrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; } if (ishtrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 6; } flipBuffers(); } } //Left if (vpad_data.btn_trigger & BUTTON_LEFT) { if (canmove(&caveGlobals, caveGlobals.row -1 , caveGlobals.col ) == true ) { doclearstuff(); dog(&caveGlobals); caveGlobals.row -= 1; drawstuff(&caveGlobals); if (istrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; } if (ishtrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 6; } flipBuffers(); } } //Right if (vpad_data.btn_trigger & BUTTON_RIGHT) { if (canmove(&caveGlobals, caveGlobals.row +1 , caveGlobals.col ) == true ) { doclearstuff(); dog(&caveGlobals); caveGlobals.row += 1; drawstuff(&caveGlobals); if (istrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; } if (ishtrap(&caveGlobals, caveGlobals.row, caveGlobals.col ) == true ) { __os_snprintf(caveGlobals.mystat, 64, "Ouch!"); drawString(25, 17, caveGlobals.mystat); caveGlobals.curhealth -= 1; caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 6; } flipBuffers(); } } //Feed the doggy if (vpad_data.btn_trigger & BUTTON_PLUS) { if (caveGlobals.dogalive == 1) { if (caveGlobals.food >= 1) { doclearstuff(); __os_snprintf(caveGlobals.mystat, 64, "*crunch* Woof!"); drawString(24, 17, caveGlobals.mystat); caveGlobals.food -= 1; caveGlobals.dogsteps -= 60; //Make sure we don't go negative in dog health if (caveGlobals.dogsteps <= 0) { caveGlobals.dogsteps = 0;} drawstuff(&caveGlobals); dog(&caveGlobals); flipBuffers(); } } } // Check if the player is dead if(caveGlobals.curhealth == 0) { doclearstuff(); __os_snprintf(caveGlobals.endgame, 256, "You're Dead!\nNow how will you get iosu? :/ \n\nThanks for Playing! \n\n\nBy: SonyUSA"); drawString(0, 0, caveGlobals.endgame); flipBuffers(); t1 = 0x80000000; while(t1--) ; SYSLaunchMenu(); _Exit(); } // Cheat and go to next level with Minus key if(vpad_data.btn_release & BUTTON_MINUS) { caveGlobals.level += 1; doclearstuff(); changelevel(&caveGlobals); drawstuff(&caveGlobals); flipBuffers(); } } }
static void drawSample(int x, int y, int w, int h, struct formatInfo *format, struct envModeInfo *envMode) { glViewport(x, y, w, h); glScissor(x, y, w, h); glClearColor(0.1, 0.1, 0.1, 1.0); glClear(GL_COLOR_BUFFER_BIT); begin2D(w, h); drawString(format->name, 10, h - 15, labelInfoColor); drawString(envMode->name, 10, 5, labelInfoColor); end2D(); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode->mode); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, envColors[envColor]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); loadTexture(textureWidth, textureHeight, format); if (drawBackground) { drawCheck(15, 15, lightCheck, darkCheck); } if (drawBlended) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); } if (drawSmooth) { glShadeModel(GL_SMOOTH); } if (drawTextured) { glEnable(GL_TEXTURE_2D); } glBegin(GL_QUADS); glColor4f(1.0, 0.0, 0.0, 1.0); glTexCoord2f(0.0, 0.0); glVertex2f(-0.8, -0.8); glColor4f(0.0, 1.0, 0.0, 1.0); glTexCoord2f(1.0, 0.0); glVertex2f(0.8, -0.8); glColor4f(0.0, 0.0, 1.0, 1.0); glTexCoord2f(1.0, 1.0); glVertex2f(0.8, 0.8); glColor4f(1.0, 1.0, 1.0, 1.0); glTexCoord2f(0.0, 1.0); glVertex2f(-0.8, 0.8); glEnd(); glDisable(GL_BLEND); glShadeModel(GL_FLAT); glDisable(GL_TEXTURE_2D); if (displayLevelInfo) { GLint width, height, border, components; #if GL_EXT_texture GLint redSize, greenSize, blueSize, alphaSize; GLint luminanceSize, intensitySize; #endif char buf[255]; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BORDER, &border); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPONENTS, &components); #if GL_EXT_texture glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE_EXT, &redSize); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE_EXT, &greenSize); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE_EXT, &blueSize); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE_EXT, &alphaSize); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE_EXT, &luminanceSize); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE_EXT, &intensitySize); #endif begin2D(w, h); sprintf(buf, "dimensions: %d x %d", width, height); drawStringOutline(buf, 15, h / 2 + 20, labelLevelColor0, labelLevelColor1); sprintf(buf, "border: %d", border); drawStringOutline(buf, 15, h / 2 + 10, labelLevelColor0, labelLevelColor1); sprintf(buf, "components: 0x%04X", components); drawStringOutline(buf, 15, h / 2, labelLevelColor0, labelLevelColor1); sprintf(buf, "sizes:"); drawStringOutline(buf, 15, h / 2 - 10, labelLevelColor0, labelLevelColor1); #if GL_EXT_texture sprintf(buf, " %d/%d/%d/%d/%d/%d", redSize, greenSize, blueSize, alphaSize, luminanceSize, intensitySize); drawStringOutline(buf, 15, h / 2 - 20, labelLevelColor0, labelLevelColor1); #endif end2D(); } }
Vec2i drawString (const String& str, const Vec2f& pos, U32 abgr) { return drawString(str, Vec4f(pos, 0.0f, 1.0f), 0.5f, abgr); }
//----------------------------------------------------------------------------- // name: render_2() // desc: ... //----------------------------------------------------------------------------- void AudicleFaceShredder::render_2( t_CKFLOAT delta ) { Shred_Stat * stat = NULL; Shred_Data * data = NULL; Color4D c; Point3D p, v, a; Point3D b; t_CKFLOAT theta; static char buffer[2048]; char * t; char * d; int i; // loop through t_CKFLOAT y = 1.15; for( i = 0; i < m_stats.size(); i++ ) { stat = m_stats[i]; data = (Shred_Data *)stat->data; data->pos2[1] = y; y -= .15; } // loop through Shred_Stat * s; t_CKFLOAT srate = Digitalio::sampling_rate() / 1000.0; for( i = 0; i < m_stats.size(); i++ ) { s = m_stats[i]; data = m_stats[i]->data; c = data->color; p = data->pos2; switch( s->state ) { case 0: t = "inactive"; break; case 1: t = "active"; break; case 2: t = "waiting"; break; case 3: t = "done"; break; default: t = "none"; break; } sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)", s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate ); // push the name glPushName( data->name ); glPushMatrix(); glColor4f( c[0], c[1], c[2], c[3] ); glTranslatef( p[0], p[1], p[2] ); glutSolidSphere( data->radius2, 15, 15 ); glTranslatef( .1, -.033, 0.0 ); glPushMatrix(); glColor4f( 0.0, 0.0, 0.0, 1.0 ); scaleFont( .052 ); drawString( buffer ); glPopMatrix(); glPopMatrix(); glPopName(); } // loop through map<Shred_Stat *, Shred_Stat *>::iterator iter; for( iter = m_done.begin(); iter != m_done.end(); iter++ ) { s = (*iter).second; data = (Shred_Data *)(*iter).second->data; c = data->color; data->pos2[1] = y; y -= .15; p = data->pos2; switch( s->state ) { case 0: t = "inactive"; break; case 1: t = "active"; break; case 2: t = "waiting"; break; case 3: t = "done"; break; default: t = "none"; break; } sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)", s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate ); // push the name glPushName( data->name ); glPushMatrix(); glColor4f( c[0], c[1], c[2], c[3] ); glTranslatef( p[0], p[1], p[2] ); glutSolidSphere( data->radius2, 15, 15 ); glTranslatef( .1, -.033, 0.0 ); glPushMatrix(); glDisable( GL_LIGHTING ); glColor4f( 0.4, 0.4, 0.4, 1.0 ); scaleFont( .052 ); drawString( buffer ); glEnable( GL_LIGHTING ); glPopMatrix(); glPopMatrix(); glPopName(); } }
void SettingsSetTimeScreen::renderHour() { // numToStr(GetHour()); twodigit(buf, GetHour()); drawString(110, 175, buf, WHITE, BLACK, 2); }
void tsCalibCenterText(char* text, uint16_t y, uint16_t color) { drawString((lcdGetWidth() - drawGetStringWidth(&dejaVuSans9ptFontInfo, text)) / 2, y, color, &dejaVuSans9ptFontInfo, text); }
gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align, bool draw) { gfx::Point pt(0, rc.y); if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) { gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false); if (align & JI_MIDDLE) pt.y = rc.y + rc.h/2 - preSize.h/2; else if (align & JI_BOTTOM) pt.y = rc.y + rc.h - preSize.h; } gfx::Size calculatedSize(0, 0); size_t beg, end, new_word_beg, old_end; std::string line; // Draw line-by-line for (beg=end=0; end != std::string::npos; ) { pt.x = rc.x; // Without word-wrap if ((align & JI_WORDWRAP) == 0) { end = str.find('\n', beg); } // With word-wrap else { old_end = std::string::npos; for (new_word_beg=beg;;) { end = str.find_first_of(" \n", new_word_beg); // If we have already a word to print (old_end != npos), and // we are out of the available width (rc.w) using the new "end", if ((old_end != std::string::npos) && (pt.x+m_font->textLength(str.substr(beg, end-beg).c_str()) > rc.w)) { // We go back to the "old_end" and paint from "beg" to "end" end = old_end; break; } // If we have more words to print... else if (end != std::string::npos) { // Force line break, now we have to paint from "beg" to "end" if (str[end] == '\n') break; // White-space, this is a beginning of a new word. new_word_beg = end+1; } // We are in the end of text else break; old_end = end; } } // Get the entire line to be painted line = str.substr(beg, end-beg); gfx::Size lineSize( m_font->textLength(line.c_str()), m_font->height()); calculatedSize.w = MAX(calculatedSize.w, lineSize.w); // Render the text if (draw) { int xout; if ((align & JI_CENTER) == JI_CENTER) xout = pt.x + rc.w/2 - lineSize.w/2; else if ((align & JI_RIGHT) == JI_RIGHT) xout = pt.x + rc.w - lineSize.w; else xout = pt.x; drawString(line, fg, bg, gfx::Point(xout, pt.y)); if (!gfx::is_transparent(bg)) fillAreaBetweenRects(bg, gfx::Rect(rc.x, pt.y, rc.w, lineSize.h), gfx::Rect(xout, pt.y, lineSize.w, lineSize.h)); } pt.y += lineSize.h; calculatedSize.h += lineSize.h; beg = end+1; } // Fill bottom area if (draw && !gfx::is_transparent(bg)) { if (pt.y < rc.y+rc.h) fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y)); } return calculatedSize; }
void drawPause() { char *psChr = "PAUSE"; if ( (psCnt&63) < 32 ) { drawString(psChr, 252, LAYER_HEIGHT/3, 20, 0, 200, 200, 180); } }
int main(void) { //video mode 3, activate background 2 *REG_DISPCNT = MODE3 | BG2_ENABLE; paddle.x = 113; oldPaddle.x = 113; //ball starts on top of paddle setBallOnPaddle(); lives = 3; bricksLeft = NUM_OF_BRICKS; sprintf(livesString, "%d", lives); //store lives as a string sprintf(bricksString, "%d", bricksLeft); //store bricks left as a string drawBackground3(startscreen); drawString(10, 125, "Press any key", WHITE); drawString(10, 135, "to start", WHITE); while(!ANY_KEY_DOWN) { //press key to advance } fillScreen(BLACK); waitForVblank(); drawRect(GAME_WIDTH, 0, SCREEN_WIDTH - GAME_WIDTH, SCREEN_HEIGHT, RGB(6, 0, 6)); instantiateBrickArray(); drawString(205, 20, "Lives", WHITE); drawString(215, 35, livesString, WHITE); drawString(202, 60, "Bricks", WHITE); drawString(208, 70, "left", WHITE); drawString(215, 85, bricksString, WHITE); while(lives > 0 && bricksLeft > 0) { updatePositions(); drawEverything(); } if (bricksLeft <= 0) { drawBackground3(win); } else { drawBackground3(lose); } while(TRUE) { //do nothing } }
/** * CBitmapFont::drawStringView * @date Modified Apr 04, 2006 */ void CBitmapFont::drawStringView(CString str, RECT rView, unsigned int unOffset, D3DCOLOR dwColor, bool bHandleSprite) { std::vector<CString> vLines, vWords, vColors; unsigned int unWidth = rView.right - rView.left, unHeight = rView.bottom - rView.top, unWordWidth = 0; RECT rWord; float fX = (float)rView.left, fY = (float)rView.top; str.ToList(vLines, "\r\n"); if(bHandleSprite) beginSprite(); // Calculate max number of lines unsigned int unLineCount = unHeight / m_cLineHeight; // Iterate lines in string. size_t i = ((vLines.size() <= unLineCount) ? 0 : max(vLines.size() - unOffset - unLineCount, 0)); for(; i < ((vLines.size() <= unLineCount) ? vLines.size() : vLines.size() - unOffset); ++i) { // Iterate words in string. vLines[i].ToList(vWords, " "); for(size_t j = 0; j < vWords.size(); ++j) { bool bFirst = false; vWords[j].ToList(vColors, "{}"); if(vWords[j].GetChar(0) == '{') bFirst = true; if(vColors.size()) { for(size_t k = 0; k < vColors.size(); ++k) { if((bFirst && k % 2 == 0) || (!bFirst && k % 2 == 1)) { dwColor = vColors[k].ToUlongFromHex(); continue; } // Take line length into consideration unWordWidth = measureString(vColors[k], &rWord); if(fX + unWordWidth >= unWidth) { fX = (float)rView.left; fY += m_cLineHeight; drawString(vColors[k], fX, fY, dwColor, false); } else { drawString(vColors[k], fX, fY, dwColor, false); fX += unWordWidth + m_mCharMap[' ']; } } } else { // Take line length into consideration unWordWidth = measureString(vWords[j], &rWord); if(fX + unWordWidth >= unWidth) { fX = (float)rView.left; fY += m_cLineHeight; drawString(vWords[j], fX, fY, dwColor, false); } else { drawString(vWords[j], fX, fY, dwColor, false); fX += unWordWidth + m_mCharMap[' ']; } } } fX = (float)rView.left; fY += m_cLineHeight; } if(bHandleSprite) endSprite(); }
void updatePositions() { oldPaddle = paddle; oldBall = ball; if (KEY_DOWN_NOW(BUTTON_RIGHT)) { paddle.x = min(paddle.x + PADDLE_SPEED, GAME_WIDTH - PADDLE_WIDTH); if (ball.onPaddle) ball.x = paddle.x + PADDLE_WIDTH / 2; } if (KEY_DOWN_NOW(BUTTON_LEFT)) { paddle.x = max(paddle.x - PADDLE_SPEED, 0); if (ball.onPaddle) ball.x = paddle.x + PADDLE_WIDTH / 2; } //release ball from paddle if (ball.onPaddle && KEY_DOWN_NOW(BUTTON_A)) { ball.onPaddle = FALSE; ball.xspeed = 1; ball.yspeed = -3; ball.y -= 1; //give it one pixel of space so it doesn't "collide" with paddle right away } //--------------------------CHECK FOR COLLISIONS-------------------------------// //check collision with right boundary if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, GAME_WIDTH, 0, GAME_WIDTH + 10, GAME_HEIGHT)) { ball.xspeed = -ball.xspeed; ball.x -= 2; } //check collision with top boundary if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, 0, -10, GAME_WIDTH, 0)) { ball.yspeed = -ball.yspeed; ball.y += 2; } //check collision with left boundary if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, -10, 0, 0, GAME_HEIGHT)) { ball.xspeed = -ball.xspeed; ball.x += 2; } //check collision with bricks for (int i = 0; i < NUM_OF_BRICKS; i++) { if (brickArray[i].health && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, brickArray[i].x, brickArray[i].y, brickArray[i].x + BRICK_WIDTH, brickArray[i].y + BRICK_HEIGHT)) { int ballxmid = ball.x + BALL_SIZE/2; int ballymid = ball.y + BALL_SIZE/2; int brickxmid = brickArray[i].x + BRICK_WIDTH/2; int brickymid = brickArray[i].y + BRICK_HEIGHT/2; //slope of the vector pointing from the ball to the brick int deltax = brickxmid - ballxmid; int deltay = brickymid - ballymid; //below or above brick if (abs(deltax) < 2 * abs(deltay) + 2) // abs(dy/dx) > 1/2 (visual->) \_____/ { ball.yspeed = -ball.yspeed; ball.y += signOf(ball.yspeed) * 2; //"push it out of brick just a bit" } //side of brick else { ball.xspeed = -ball.xspeed; ball.x += signOf(ball.xspeed) * 2; //"push it out of brick just a bit" } brickArray[i].health -= 1; if (!brickArray[i].health) { //draw part of the background image that was previously hidden drawImageExt3(brickArray[i].x, brickArray[i].y, brickArray[i].x, brickArray[i].y, BRICK_WIDTH, BRICK_HEIGHT, gtech); bricksLeft --; sprintf(bricksString, "%d", bricksLeft); //store lives as a string waitForVblank(); drawRect(215, 85, 12, 8, RGB(6, 0, 6)); drawString(215, 85, bricksString, WHITE); } } } //check collision with paddle if (!ball.onPaddle && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, paddle.x, PADDLE_Y, paddle.x + PADDLE_WIDTH, PADDLE_Y + PADDLE_HEIGHT)) { setNewBallSpeed(); } //check for death if (ball.y > GAME_HEIGHT) { lives--; sprintf(livesString, "%d", lives); //store lives as a string //draw new lives number waitForVblank(); drawRect(215, 35, 6, 8, RGB(6, 0, 6)); drawString(215, 35, livesString, WHITE); setBallOnPaddle(); } ball.x += ball.xspeed; ball.y += ball.yspeed; }
void Hud::Rebuild(int width, int height) { _requiresRebuildStatic = false; _windowWidth = width; _windowHeight = height; _staticVboSource.clear(); int x, y; // add UI elements for (std::vector<Item>::const_iterator it = _labels.begin(); it != _labels.end(); ++it) { getWindowPos(*it, &x, &y); drawString(_staticVboSource, x, y, 1, 1, 1, it->label.c_str()); } for (std::vector<RadioButton>::const_iterator it = _radioButtons.begin(); it != _radioButtons.end(); ++it) { getWindowPos(*it, &x, &y); if (it->checked) { x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_RADIO_BUTTON_ON); drawString(_staticVboSource, x, y, 1, 1, 0, it->label.c_str()); } else { x = drawChar(_staticVboSource, x, y, 1, 1, 1, ' '); drawString(_staticVboSource, x, y, .5f, .5f, .5f, it->label.c_str()); } } for (std::vector<CheckBox>::const_iterator it = _checkBoxes.begin(); it != _checkBoxes.end(); ++it) { getWindowPos(*it, &x, &y); if (it->checked) { x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_CHECK_BOX_ON); drawString(_staticVboSource, x, y, 1, 1, 0, it->label.c_str()); } else { x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_CHECK_BOX_OFF); drawString(_staticVboSource, x, y, .5f, .5f, .5f, it->label.c_str()); } } for (std::vector<Slider>::const_iterator it = _sliders.begin(); it != _sliders.end(); ++it) { getWindowPos(*it, &x, &y); int sx = x; x = drawString(_staticVboSource, x, y, 1, 1, 1, it->label.c_str()); char value[16]; snprintf(value, 16, " : %.2f", it->value); drawString(_staticVboSource, x, y, 1, 1, 1, value); // new line y += FONT_CHAR_HEIGHT; x = sx; x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_LEFT); int nw = it->w / FONT_CHAR_WIDTH; for (int i = 1; i < nw; ++i) { x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_MIDDLE); } drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_RIGHT); int pos = (int)((it->value/float(it->max-it->min))*it->w); drawChar(_staticVboSource, sx+pos, y, 1, 1, 0, FONT_SLIDER_CURSOR); } drawString(_staticVboSource, _windowWidth-80, _windowHeight-48, .5, .5, .5, "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"); drawString(_staticVboSource, _windowWidth-80, _windowHeight-32, .5, .5, .5, "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"); }
void configureCFW(const char *configPath, const char *firm90Path){ initScreens(); drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); drawString("Press A to select, START to save and reboot", 10, 30, COLOR_WHITE); const char *optionsText[] = { "( ) Updated SysNAND mode (A9LH-only)", "( ) Use pre-patched FIRMs", "( ) Force A9LH detection", "( ) Use 9.0 FIRM as default", "( ) Use second EmuNAND as default", "( ) Show current NAND in System Settings" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); struct option options[optionsAmount]; //Read and parse the existing configuration u32 tempConfig = 0; fileRead(&tempConfig, configPath, 3); for(u32 i = 0; i < optionsAmount; i++) options[i].enabled = (tempConfig >> i) & 0x1; //Pre-select the first configuration option u32 selectedOption = 0; //Boring configuration menu while(1){ u16 pressed = 0; do{ for(u32 i = 0; i < optionsAmount; i++){ options[i].posY = drawString(optionsText[i], 10, !i ? 60 : options[i - 1].posY + SPACING_Y, selectedOption == i ? COLOR_RED : COLOR_WHITE); drawCharacter('x', 10 + SPACING_X, options[i].posY, options[i].enabled ? (selectedOption == i ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK); } pressed = waitInput(); } while(!(pressed & MENU_BUTTONS)); switch(pressed){ case BUTTON_UP: selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1; break; case BUTTON_DOWN: selectedOption = selectedOption == optionsAmount - 1 ? 0 : selectedOption + 1; break; case BUTTON_LEFT: selectedOption = 0; break; case BUTTON_RIGHT: selectedOption = optionsAmount - 1; break; case BUTTON_A: options[selectedOption].enabled = !options[selectedOption].enabled; break; } if(pressed == BUTTON_START) break; } //If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM if(((tempConfig >> 16) & 0x1) && ((tempConfig & 0x1) != options[0].enabled)) fileDelete(firm90Path); //Preserve the last-used boot options (last 12 bits) tempConfig &= 0xFFF000; //Parse and write the selected options for(u32 i = 0; i < optionsAmount; i++) tempConfig |= options[i].enabled << i; fileWrite(&tempConfig, configPath, 3); //Zero the last booted FIRM flag CFG_BOOTENV = 0; //Reboot i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(1); }
void StatusScreen::render() { uint16_t stacolor = color565(51,153,204); //blue fillScreen(stacolor); makeRectangle(5,5, 225,310, BLACK, 4); char* status = "STATUS"; drawString(225,50 , status, BLACK, stacolor, 2); makeRectangle(85,15, 135, 300, BLACK, 3); makeRectangle(15,15, 75, 300, BLACK, 3); drawString(210, 20, "Adapters", BLACK, stacolor, 2); drawString(85, 20, "Sensors ", BLACK, stacolor, 2); makeRectangle(100,50, 50,45, BLUE, 3); makeRectangle(100,95, 50,45, BLUE, 3); makeRectangle(100,180, 50,45, BLUE, 3); makeRectangle(100,225, 50,45, BLUE, 3); makeRectangle(155,50, 50,45, BLUE, 3); makeRectangle(155,95, 50,45, BLUE, 3); makeRectangle(155,180, 50,45, BLUE, 3); makeRectangle(155,225, 50,45, BLUE, 3); drawString(120, 58, "-3-", BLACK, stacolor,2); drawString(120, 188, "-4-", BLACK, stacolor, 2); drawString(178, 58, "-1-", BLACK, stacolor, 2); drawString(178, 188, "-2-", BLACK, stacolor, 2); drawString(120, 113, "ON", BLACK, stacolor,2); drawString(120, 233, "OFF", BLACK, stacolor, 2); drawString(178 , 102, "AUT", BLACK, stacolor, 2); drawString(178, 233, "OFF", BLACK, stacolor, 2); drawString(20, 30 , "2. ", BLACK, stacolor, 2); drawString(50, 30, "1. ", BLACK, stacolor, 2); drawString(20, 55, "ENABLED", BLACK, stacolor, 2); drawString(50, 55, "DISABLED", BLACK, stacolor, 2); }
void ONScripterLabel::setupAnimationInfo( AnimationInfo *anim, FontInfo *info ) { anim->deleteSurface(); anim->abs_flag = true; if ( anim->trans_mode == AnimationInfo::TRANS_STRING ){ FontInfo f_info = sentence_font; if (info) f_info = *info; if ( anim->font_size_xy[0] >= 0 ){ // in case of Sprite, not rclick menu f_info.setTateyokoMode(0); f_info.top_xy[0] = anim->pos.x * screen_ratio2 / screen_ratio1; f_info.top_xy[1] = anim->pos.y * screen_ratio2 / screen_ratio1; if (anim->is_single_line) f_info.setLineArea( strlen(anim->file_name)/2+1 ); f_info.clear(); f_info.pitch_xy[0] = f_info.pitch_xy[0] - f_info.font_size_xy[0] + anim->font_size_xy[0]; f_info.font_size_xy[0] = anim->font_size_xy[0]; f_info.pitch_xy[1] = f_info.pitch_xy[1] - f_info.font_size_xy[1] + anim->font_size_xy[1]; f_info.font_size_xy[1] = anim->font_size_xy[1]; if ( anim->font_pitch >= 0 ) f_info.pitch_xy[0] = anim->font_pitch; f_info.ttf_font = NULL; } SDL_Rect pos; if (anim->is_tight_region){ drawString( anim->file_name, anim->color_list[ anim->current_cell ], &f_info, false, NULL, &pos ); } else{ int xy_bak[2]; xy_bak[0] = f_info.xy[0]; xy_bak[1] = f_info.xy[1]; int xy[2] = {0, 0}; f_info.setXY(f_info.num_xy[0], f_info.num_xy[1]); pos = f_info.calcUpdatedArea(xy, screen_ratio1, screen_ratio2); f_info.xy[0] = xy_bak[0]; f_info.xy[1] = xy_bak[1]; } if (info != NULL){ info->xy[0] = f_info.xy[0]; info->xy[1] = f_info.xy[1]; } anim->allocImage( pos.w*anim->num_of_cells, pos.h ); anim->fill( 0, 0, 0, 0 ); f_info.setRubyOnFlag(anim->is_ruby_drawable); f_info.top_xy[0] = f_info.top_xy[1] = 0; for ( int i=0 ; i<anim->num_of_cells ; i++ ){ f_info.clear(); drawString( anim->file_name, anim->color_list[i], &f_info, false, NULL, NULL, anim ); f_info.top_xy[0] += anim->pos.w * screen_ratio2 / screen_ratio1; } } else{ bool has_alpha; SDL_Surface *surface = loadImage( anim->file_name, &has_alpha ); SDL_Surface *surface_m = NULL; if (anim->trans_mode == AnimationInfo::TRANS_MASK) surface_m = loadImage( anim->mask_file_name ); anim->setupImage(surface, surface_m, has_alpha); if ( surface ) SDL_FreeSurface(surface); if ( surface_m ) SDL_FreeSurface(surface_m); } }
void SettingsSetTimeScreen::renderDay() { // numToStr(GetDate()); twodigit(buf, GetDate()); drawString(110, 68, buf, WHITE, BLACK, 2); }
int game(int seed) { REG_DISPCTL = MODE3 | BG2_ENABLE; int live = 5; char buffer[41]; int speed = 1; int num = 100; int objx = 70; int objy = 50; drawPicture(black); WALL wall0; wall0.i = 80; wall0.gate = 90; wall0.gateSize = 10; wall0.color = WHITE; WALL wall1; wall1.i = 100; wall1.gate = 90; wall1.gateSize = 10; wall1.color = MAGENTA; WALL wall2; wall2.i = 120; wall2.gate = 30; wall2.gateSize = 30; wall2.color = RED; WALL wall3; wall3.i = 140; wall3.gate = 150; wall3.gateSize = 30; wall3.color = BLUE; WALL wall4; wall4.i = 160; wall4.gate = 0; wall4.gateSize = 20; wall4.color = GREEN; WALL wall5; wall5.i = 180; wall5.gate = 130; wall5.gateSize = 20; wall5.color = BLUE; WALL wall6; wall6.i = 200; wall6.gate = 130; wall6.gateSize = 15; wall6.color = CYAN; // Game Loop while(1) { int oldx = objx; int oldy = objy; drawRect(oldx,oldy,1,1, BLACK); if(KEY_DOWN_NOW(BUTTON_SELECT)) { objx = 70; objy = 50; live = 5; drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 0", YELLOW); } if(KEY_DOWN_NOW(BUTTON_UP)) { objx-=speed; if(objx < 0) { objx = 0; } } if(KEY_DOWN_NOW(BUTTON_DOWN)) { objx+=speed; if(objx > 159) { objx = 159; } } if(KEY_DOWN_NOW(BUTTON_A)) { speed = 2; } if(KEY_DOWN_NOW(BUTTON_B)) { speed = 1; } if(KEY_DOWN_NOW(BUTTON_RIGHT)) { objy++; } if(KEY_DOWN_NOW(BUTTON_LEFT)) { objy--; if(objy <= 0) { objy= 0; } } drawRect(objx,objy,1,1, RED); drawWall(wall0.i, wall0.gate, wall0.gateSize, wall0.color); if(num < 50) { if(num <= 0) { num = 100; } drawWall(wall1.i, wall1.gate++, wall1.gateSize, wall1.color); drawWall(wall2.i, wall2.gate-=2, wall2.gateSize, wall2.color); drawWall(wall3.i, wall3.gate+=3, wall3.gateSize, wall3.color); drawWall(wall4.i, wall4.gate-=3, wall4.gateSize, wall4.color); drawWall(wall5.i, wall5.gate+=3, wall5.gateSize, wall5.color); drawWall(wall6.i, wall6.gate+=3, wall6.gateSize, wall6.color); } else { drawWall(wall1.i, wall1.gate--, wall1.gateSize, wall1.color); drawWall(wall2.i, wall2.gate+=2, wall2.gateSize, wall2.color); drawWall(wall3.i, wall3.gate-=3, wall3.gateSize, wall3.color); drawWall(wall4.i, wall4.gate+=3, wall4.gateSize, wall4.color); drawWall(wall5.i, wall5.gate-=3, wall5.gateSize, wall5.color); drawWall(wall6.i, wall6.gate-=3, wall6.gateSize, wall6.color); } num--; if(objy < wall0.i) { drawString(150, 0, "Score: 0", YELLOW); } if(objy == wall0.i) { if(objx < wall0.gate || objx > wall0.gate + wall0.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 1", YELLOW); } if(objy == wall1.i) { if(objx < wall1.gate || objx > wall1.gate + wall1.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 2", YELLOW); } if(objy == wall2.i) { if(objx < wall2.gate || objx > wall2.gate + wall2.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 3", YELLOW); } if(objy == wall3.i) { if(objx < wall3.gate || objx > wall3.gate + wall3.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 4", YELLOW); } if(objy == wall4.i) { if(objx < wall4.gate || objx > wall4.gate + wall4.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 5", YELLOW); } if(objy == wall5.i) { if(objx < wall5.gate || objx > wall5.gate + wall5.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 6", YELLOW); } if(objy == wall6.i) { if(objx < wall6.gate || objx > wall6.gate + wall6.gateSize) { live--; objy-=10; drawRect(objx,objy ,1,1, RED); if (live == 0) { return LOSE; } } drawRect(150,0,60,30,BLACK); drawString(150, 0, "Score: 7", YELLOW); } if(objy > wall6.i +5) { return WIN; } drawRect(5,5,60,30,BLACK); waitForVblank(); drawImage3(0,0,30,30,heart); sprintf(buffer, " %d", live); drawString(10, 30, buffer, YELLOW); drawString(80,210, "EXIT", YELLOW); } }
void SettingsSetTimeScreen::renderMinute() { // numToStr(GetMinute()); twodigit(buf, GetMinute()); drawString(110, 228, buf, WHITE, BLACK, 2); }
int main() { REG_DISPCTL = MODE3 | BG2_ENABLE; reset(); while(1) { waitForVblank(); switch (state) { case START: drawImage3(0, 0, 240, 160, StartScreen); //The start screen state = READY; break; case READY: if (KEY_DOWN_NOW(BUTTON_B)) { drawBg(); state = PLAY; } break; case PLAY: if(KEY_DOWN_NOW(BUTTON_A)) { reset(); } eraseImage3(150, 0, 240, 10); sprintf(buffer, "%d bugs left", bugsNum); drawString(150, 0, buffer, red); sprintf(buffer, "%d lives left", lives); drawString(150, 100, buffer, red); sprintf(buffer, "level %d", level); drawString(150, 190, buffer, red); updateShip(&ship); updateBugs(bugs, &ship, &state); if (bugsNum == 0 && lives > 0) { state = WON; } break; case WON: if (level == 1) { drawString(100, 10, "Almost there! Press enter to continue!", red); if(KEY_DOWN_NOW(BUTTON_A)) { reset(); } if (KEY_DOWN_NOW(BUTTON_START)) { level++; drawBg(); setShip(&ship); setBugs(bugs); state = PLAY; } } else { drawImage3(0, 0, 240, 160, Win); if (KEY_DOWN_NOW(BUTTON_START) || KEY_DOWN_NOW(BUTTON_A)) { reset(); } } break; case DIE: drawBg(); sprintf(buffer, "%d lives left", lives); drawString(50, 75, buffer, red); if(KEY_DOWN_NOW(BUTTON_A)) { reset(); } if (KEY_DOWN_NOW(BUTTON_START)) { drawBg(); state = PLAY; ship.x = START_X; ship.y = START_Y; for (int i = 0; i < bugsNum; i++) { bugs[i].y = bugs[i].startY; bugs[i].charge = 0; } } break; case LOSE: drawImage3(0, 0, 240, 160, Ending); if(KEY_DOWN_NOW(BUTTON_A)) { reset(); } if (KEY_DOWN_NOW(BUTTON_START)) { reset(); } break; } } return 0; }
void drawString2(float x, float y, std::string text) { drawString(x, y, text.c_str()); }
void Engine::showInventory() { bool quit = false; int selecteditem = 0; std::vector< Item*> *inv = m_Player->getInventory(); while(!quit) { m_Screen->clear(); sf::Event event; while(m_Screen->pollEvent(event)) { if(event.type == sf::Event::KeyPressed) { if(event.key.code == sf::Keyboard::Escape) quit = true; else if(event.key.code == sf::Keyboard::Down) selecteditem++; else if(event.key.code == sf::Keyboard::Up) selecteditem--; else if(event.key.code == sf::Keyboard::Return) { //if using liquid container if( (*inv)[selecteditem]->getType() == OBJ_ITEM_CONTAINER_LIQUID) { ContainerLiquid *cptr = dynamic_cast<ContainerLiquid*>( (*inv)[selecteditem]); //if liquid container is not empty if(!cptr->isEmpty() ) { if(m_Player->drink(cptr->getLiquidType())) { cptr->removeLiquid(1); } } } } } } if(selecteditem < 0) selecteditem = int(inv->size()-1); else if(selecteditem >= int(inv->size())) selecteditem = 0; //draw if(inv->empty()) { drawString(0,0,"You have nothing!\n"); } else { drawString(0,0, "You are carrying:"); drawString(0,1, "-----------------"); for(int i = 0; i < int(inv->size()); i++) { std::stringstream istring; istring << (*inv)[i]->getName(); //if item is a container if( (*inv)[i]->getType() == OBJ_ITEM_CONTAINER) { //get container pointer Container *cptr = NULL; cptr = dynamic_cast<Container*>((*inv)[i]); //if container is empty if(cptr->getInventory()->empty()) istring << " (empty)"; } else if( (*inv)[i]->getType() == OBJ_ITEM_CONTAINER_LIQUID) { ContainerLiquid *cptr = dynamic_cast<ContainerLiquid*>( (*inv)[i]); if(cptr->getCurrentVolume() <= 0) istring << " (empty)"; else { istring << " (" << cptr->getCurrentVolume() << "/" << cptr->getMaxVolume() << " of " << cptr->getLiquidType()->getName() << ")"; } } if(selecteditem == i) { drawString(0, i+2, istring.str(), COLOR_BLACK, COLOR_WHITE); } else drawString(0, i+2, istring.str()); } } //update m_Screen->display(); } }
void SimpleSimulator::drawFrame() { if(!running) return; glClear(GL_COLOR_BUFFER_BIT); char id[3]; // draw the cursors std::list<TuioCursor*> cursorList = tuioServer->getTuioCursors(); for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) { TuioCursor *tcur = (*iter); std::list<TuioPoint> path = tcur->getPath(); if (path.size()>0) { TuioPoint last_point = path.front(); glBegin(GL_LINES); glColor3f(0.0, 0.0, 1.0); for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) { glVertex3f(last_point.getScreenX(width), last_point.getScreenY(height), 0.0f); glVertex3f(point->getScreenX(width), point->getScreenY(height), 0.0f); last_point.update(point->getX(),point->getY()); } glEnd(); // draw the finger tip glColor3f(0.75, 0.75, 0.75); std::list<TuioCursor*>::iterator joint = std::find( jointCursorList.begin(), jointCursorList.end(), tcur ); if( joint != jointCursorList.end() ) { glColor3f(0.5, 0.5, 0.5); } glPushMatrix(); glTranslatef(last_point.getScreenX(width), last_point.getScreenY(height), 0.0f); glBegin(GL_TRIANGLE_FAN); for(double a = 0.0f; a <= 2*M_PI; a += 0.2f) { glVertex2d(cos(a) * height/100.0f, sin(a) * height/100.0f); } glEnd(); glPopMatrix(); glColor3f(0.0, 0.0, 0.0); glRasterPos2f(tcur->getScreenX(width),tcur->getScreenY(height)); sprintf(id,"%d",tcur->getCursorID()); drawString(id); } } if (help) { glColor3f(0.0, 0.0, 1.0); glRasterPos2f(10,20); drawString("h - toggle help display"); glRasterPos2f(10,35); if (verbose) drawString("v - disable verbose mode"); else drawString("v - enable verbose mode"); glRasterPos2f(10,50); drawString("r - reset session"); glRasterPos2f(10,65); if (tuioServer->fullUpdateEnabled()) drawString("f - disable full update"); else drawString("f - enable full update"); glRasterPos2f(10,80); if (tuioServer->periodicMessagesEnabled()) drawString("p - disable periodic messages"); else drawString("p - enable periodic messages"); glRasterPos2f(10,95); drawString("SHIFT click - create persistent cursor"); glRasterPos2f(10,110); drawString("CTRL click - add to cursor group"); glRasterPos2f(10,125); if (fullscreen) drawString("F1 - exit fullscreen mode"); else drawString("F1 - enter fullscreen mode"); glRasterPos2f(10,140); drawString("ESC - Quit"); } SDL_GL_SwapBuffers(); }
std::vector<Item*> Engine::selectMultipleItemsFromInventory(std::vector<Item*> *source, std::string promptstr, std::vector<int> itemfilter) { bool quit = false; std::vector<Item*> selecteditems; std::vector<bool> bselecteditems; int selecteditemindex = 0; //get player inventory list std::vector<Item*> *inv = source; std::vector<Item*> filteredlist; //build item list based on filter for(int i = 0; i < int(inv->size()); i++) { //for each inventory item, check to see if it matches filter criteria for(int n = 0; n < int(itemfilter.size()); n++) { //if filter matches or OBJ_TOTAL filter is used, add item to filtered items list if( (*inv)[i]->getType() == itemfilter[n] || itemfilter[n] == OBJ_TOTAL) { filteredlist.push_back( (*inv)[i]); bselecteditems.push_back(false); break; } } } while(!quit) { sf::Event event; m_Screen->clear(); while(m_Screen->pollEvent(event)) { if(event.type == sf::Event::KeyPressed) { if(event.key.code == sf::Keyboard::Escape) quit = true; else if(event.key.code == sf::Keyboard::Down) selecteditemindex++; else if(event.key.code == sf::Keyboard::Up) selecteditemindex--; else if(event.key.code == sf::Keyboard::Return) { //toggle selected item bselecteditems[selecteditemindex] = !bselecteditems[selecteditemindex]; } } } //resolve selected item index if out of bounds if(selecteditemindex >= int(filteredlist.size()) ) selecteditemindex = 0; else if(selecteditemindex < 0) selecteditemindex = int(filteredlist.size()-1); //draw drawString(0,0, promptstr); //draw all items in filtered items list for(int i = 0; i < int(filteredlist.size()); i++) { std::stringstream inamestr; if(bselecteditems[i]) inamestr << " + "; else inamestr << " - "; inamestr << filteredlist[i]->getName(); if(selecteditemindex == i) drawString(0, i+2, inamestr.str(), COLOR_BLACK, COLOR_WHITE); else drawString(0, i+2, inamestr.str()); } //display m_Screen->display(); } //put selected items into list for(int i = 0; i < int(filteredlist.size()); i++) { if(bselecteditems[i]) selecteditems.push_back(filteredlist[i]); } return selecteditems; }
void FontManager::drawString(float x, float y, float z, std::string face, float size, std::string text) { drawString(x, y, z, getFaceID(face), size, text); }
void TextEdit::redrawTextRectangle( int x, int y, int w, int h, bool createGC /* = false */ ) { int x1 = x + w; if (w == INT_MAX) x1 = INT_MAX; int y1 = y + h; if (h == INT_MAX) y1 = INT_MAX; int x0 = x; if (x0 < windowX) x0 = windowX; int y0 = y; if (y0 < windowY) y0 = windowY; if (x1 > windowX + windowWidth) x1 = windowX + windowWidth; if (y1 > windowY + windowHeight) y1 = windowY + windowHeight; if (x1 <= x || y1 <= y) return; GC savedGC; if (createGC) { // Save the previous graphic contex, create a temporary GC savedGC = m_GC; m_GC = XCreateGC(m_Display, m_Window, 0, 0); setFont(textFont); } int left = leftMargin + (x0 - windowX) * dx; int top = topMargin + (y0 - windowY) * dy; int width = (x1 - x0) * dx; int height = (y1 - y0) * dy; if (left + width > m_IWinRect.width()) width -= (left + width - m_IWinRect.width()); if (top + height > m_IWinRect.height()) height -= (top + height - m_IWinRect.height()); if (!createGC) { redrawRectangle( I2Rectangle(left, top, width, height) ); } else { // Erase a window setForeground(bgColor); fillRectangle( I2Rectangle(left, top, width, height) ); // Draw a text in a window setForeground(fgColor); int iy = top + ascent; for (int yy = y0; yy < y1; yy++, iy += dy) { const TextLine* currentLine; if (yy > text.size()) { break; } else if (yy == text.size()) { currentLine = &(endOfText); } else { currentLine = &(text.getLine(yy)); } int len = currentLine->length(); if (len > x0) { len -= x0; if (len > x1 - x0) len = x1 - x0; drawString( left, iy, currentLine->getString() + x0, len ); } } } if (createGC) { // Release the temporary graphic contex, restore the previous GC XFreeGC(m_Display, m_GC); m_GC = savedGC; } }
void drawmap(struct cGlobals *caveGlobals) { // Matrix Pieces #define TILE_VOID 0 #define TILE_WALL 1 #define TILE_FLOOR 2 #define TILE_WATER 3 #define TILE_CLOSEDOOR 4 #define TILE_OPENDOOR 5 #define TILE_TRAP 6 #define TILE_HTRAP 7 #define TILE_FOOD 8 #define TILE_STAIRS 9 #define TILE_SDOOR 10 #define TILE_POTION 11 // Draw each element in the matrix using a viewscope of 4 tiles around the player int y; int x; // Make sure we don't look outside the matrix on accident... int yy = caveGlobals->col-4; if (yy < 0) { yy = 0;} int xx = caveGlobals->row-4; if (xx < 0) { xx = 0;} // Now draw everything! for( y = yy; y < caveGlobals->col+5 && y < 17; y++ ) { for( x = xx; x < caveGlobals->row+5 && x < 62; x++ ) { switch ( caveGlobals->nMapArray[y][x] ) { case TILE_VOID: __os_snprintf(caveGlobals->mapbuff, 2800, "."); drawString(x, y, caveGlobals->mapbuff); break; case TILE_WALL: __os_snprintf(caveGlobals->mapbuff, 2800, "#"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_FLOOR: __os_snprintf(caveGlobals->mapbuff, 2800, " "); drawString(x, y, caveGlobals->mapbuff); break; case TILE_WATER: __os_snprintf(caveGlobals->mapbuff, 2800, "~"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_CLOSEDOOR: __os_snprintf(caveGlobals->mapbuff, 2800, "+"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_OPENDOOR: __os_snprintf(caveGlobals->mapbuff, 2800, "/"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_TRAP: __os_snprintf(caveGlobals->mapbuff, 2800, "*"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_HTRAP: __os_snprintf(caveGlobals->mapbuff, 2800, " "); drawString(x, y, caveGlobals->mapbuff); break; case TILE_FOOD: __os_snprintf(caveGlobals->mapbuff, 2800, "F"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_STAIRS: __os_snprintf(caveGlobals->mapbuff, 2800, ">"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_SDOOR: __os_snprintf(caveGlobals->mapbuff, 2800, "#"); drawString(x, y, caveGlobals->mapbuff); break; case TILE_POTION: __os_snprintf(caveGlobals->mapbuff, 2800, "p"); drawString(x, y, caveGlobals->mapbuff); break; } } } }
void Renderer::render() { Color* custom; Vector3d d(0, 0, 0); Vector3d ep(0, 0, 0); custom = new Color(0.4, 1.0, 0.2, 1.0); glClearColor(0.0, 0.0, 0.0, 1.0); //clear the screen to black glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the color buffer and the depth buffer glLoadIdentity(); //light(); GLfloat blackAmbientLight[] = { 0.0, 0.0, 0.0 }; //set the light ambient to black GLfloat whiteDiffuseLight[] = { 1.0, 1.0, 1.0 }; //set the diffuse light to white glLightfv(GL_LIGHT0, GL_AMBIENT, blackAmbientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteDiffuseLight); gluLookAt(0, 0, zpos, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //camera position, x,y,z, looking at x,y,z, Up Positions of the camera glRotatef(xang, 1.0f, 0.0f, 0.0f); glRotatef(yang, 0.0f, 1.0f, 0.0f); glRotatef(zang, 0.0f, 0.0f, 1.0f); if (settings->renderMethod == RenderMethodExplodeHigherDimensions) { for (int i = 0; i < space->matrixSize; i++) { if (space->getCell(i) == 1) { cursor->moveabs(&pixelVectors[i]); cursor->setcolor(&pixelColors[i]); cursor->pset(); // TODO - pixel shapes } } /* int renderableDimensions = 3; float buffer = .1; // 10% buffer float scale = 1.0; float totalSizePerRenderableDimension[3] = { 1, 1, 1 }; float* dimensionMultipliers = new float[space->dimensions]; float maximumSizeOfRenderableDimensions = 0.0; for (int dimension = 0; dimension < space->dimensions; dimension++) { totalSizePerRenderableDimension[dimension % 3] *= (space->extents[dimension]) * (1.0 + buffer); if (totalSizePerRenderableDimension[dimension % 3] > maximumSizeOfRenderableDimensions) maximumSizeOfRenderableDimensions = totalSizePerRenderableDimension[dimension % 3]; dimensionMultipliers[dimension] = totalSizePerRenderableDimension[dimension % 3]; } scale = 1 / maximumSizeOfRenderableDimensions; int* zeroOrdinates = space->createOrdinates(); int* ordinates = space->createOrdinates(); for (int i = 0; i < space->matrixSize; i++) { unsigned char state = space->getCell(ordinates); if (state == 1) { // Could be made more efficient through caching custom->rgb[0] = space->dimensions >= 1 ? ((float)ordinates[0] / (float)space->extents[0]) : .5f; custom->rgb[1] = space->dimensions >= 2 ? ((float)ordinates[1] / (float)space->extents[1]) : .5f; custom->rgb[2] = space->dimensions >= 3 ? ((float)ordinates[2] / (float)space->extents[2]) : .5f; custom->alpha = 0.8; // Could be made more efficient through caching d.x = 0.0; d.y = 0.0; d.z = 0.0; for (int dimension = 0; dimension < space->dimensions; dimension += 3) { d.x += (((float)ordinates[dimension] / (float)space->extents[dimension]) - 0.5) * dimensionMultipliers[dimension]; if (dimension + 1 < space->dimensions) { d.y += (((float)ordinates[dimension + 1] / (float)space->extents[dimension + 1]) - 0.5) * dimensionMultipliers[dimension + 1]; } if (dimension + 2 < space->dimensions) { d.z += (((float)ordinates[dimension + 2] / (float)space->extents[dimension + 2]) - 0.5) * dimensionMultipliers[dimension + 2]; } } d.x *= scale; d.y *= scale; d.z *= scale; cursor->moveabs(&d); cursor->setcolor(custom); cursor->pset(); // TODO - pixel shapes } space->iterateOverOrdinates(ordinates, zeroOrdinates, space->extents); } delete ordinates; delete zeroOrdinates;*/ } else if (settings->renderMethod == RenderMethodMaxIntensity) { // TODO } else if (settings->renderMethod == RenderMethodMiddleSlice) { // TODO } glRotatef(-xang, 1.0f, 0.0f, 0.0f); glRotatef(-yang, 0.0f, 1.0f, 0.0f); glRotatef(-zang, 0.0f, 0.0f, 1.0f); std::stringstream ss; ss << conway->turn; drawString(GLUT_BITMAP_HELVETICA_18, (char*)ss.str().c_str(), 3, 3, 3); glutSwapBuffers(); }
void TuioDemo::drawObjects() { glClear(GL_COLOR_BUFFER_BIT); char id[3]; // draw the cursors std::list<TuioCursor*> cursorList = tuioClient->getTuioCursors(); tuioClient->lockCursorList(); for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) { TuioCursor *tuioCursor = (*iter); std::list<TuioPoint> path = tuioCursor->getPath(); if (path.size()>0) { TuioPoint last_point = path.front(); glBegin(GL_LINES); glColor3f(0.0, 0.0, 1.0); for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) { glVertex3f(last_point.getScreenX(width), last_point.getScreenY(height), 0.0f); glVertex3f(point->getScreenX(width), point->getScreenY(height), 0.0f); last_point.update(point->getX(),point->getY()); } glEnd(); // draw the finger tip glColor3f(0.75, 0.75, 0.75); glPushMatrix(); glTranslatef(last_point.getScreenX(width), last_point.getScreenY(height), 0.0); glBegin(GL_TRIANGLE_FAN); for(double a = 0.0f; a <= 2*M_PI; a += 0.2f) { glVertex2d(cos(a) * height/100.0f, sin(a) * height/100.0f); } glEnd(); glPopMatrix(); glColor3f(0.0, 0.0, 0.0); glRasterPos2f(tuioCursor->getScreenX(width),tuioCursor->getScreenY(height)); sprintf(id,"%d",tuioCursor->getCursorID()); drawString(id); } } tuioClient->unlockCursorList(); // draw the objects std::list<TuioObject*> objectList = tuioClient->getTuioObjects(); tuioClient->lockObjectList(); for (std::list<TuioObject*>::iterator iter = objectList.begin(); iter!=objectList.end(); iter++) { TuioObject *tuioObject = (*iter); int pos_size = height/25.0f; int neg_size = -1*pos_size; float xpos = tuioObject->getScreenX(width); float ypos = tuioObject->getScreenY(height); float angle = tuioObject->getAngleDegrees(); glColor3f(0.0, 0.0, 0.0); glPushMatrix(); glTranslatef(xpos, ypos, 0.0); glRotatef(angle, 0.0, 0.0, 1.0); glBegin(GL_QUADS); glVertex2f(neg_size, neg_size); glVertex2f(neg_size, pos_size); glVertex2f(pos_size, pos_size); glVertex2f(pos_size, neg_size); glEnd(); glPopMatrix(); glColor3f(1.0, 1.0, 1.0); glRasterPos2f(xpos,ypos+5); sprintf(id,"%d",tuioObject->getSymbolID()); drawString(id); } tuioClient->unlockObjectList(); // draw the blobs std::list<TuioBlob*> blobList = tuioClient->getTuioBlobs(); tuioClient->lockBlobList(); for (std::list<TuioBlob*>::iterator iter = blobList.begin(); iter!=blobList.end(); iter++) { TuioBlob *tuioBlob = (*iter); float blob_width = tuioBlob->getScreenWidth(width)/2; float blob_height = tuioBlob->getScreenHeight(height)/2; float xpos = tuioBlob->getScreenX(width); float ypos = tuioBlob->getScreenY(height); float angle = tuioBlob->getAngleDegrees(); glColor3f(0.25, 0.25, 0.25); glPushMatrix(); glTranslatef(xpos, ypos, 0.0); glRotatef(angle, 0.0, 0.0, 1.0); /*glBegin(GL_QUADS); glVertex2f(blob_width/-2, blob_height/-2); glVertex2f(blob_width/-2, blob_height/2); glVertex2f(blob_width/2, blob_height/2); glVertex2f(blob_width/2, blob_height/-2); glEnd();*/ glBegin(GL_TRIANGLE_FAN); for(double a = 0.0f; a <= 2*M_PI; a += 0.2f) { glVertex2d(cos(a) * blob_width, sin(a) * blob_height); } glEnd(); glPopMatrix(); glColor3f(1.0, 1.0, 1.0); glRasterPos2f(xpos,ypos+5); sprintf(id,"%d",tuioBlob->getBlobID()); drawString(id); } tuioClient->unlockBlobList(); SDL_GL_SwapBuffers(); }
void Bond::output_bending(ofstream &out){ out << "r " << 0.01*moment_bending.norm() << endl; drawString(out); }