static inline void hybrid() { /* hybrid test */ int i, j; SUBTITLE(hybrid); /* allocation phase */ for (i = 0 ; i < MAX_ALLOC ; i ++) { j = (random() % 4); switch(j) { case 0: /* alloc */ my_alloc[i] = al(); break; case 1: /* calloc */ my_alloc[i] = cal(); break; case 2: /* strdup */ my_alloc[i] = sdu(); break; default: /* realloc */ my_alloc[i] = real(); break; } } /* free phase */ fr(); }
void Game::notifyButtonClick(MyGUI::Widget* _sender){ if( mUI.IsWidget(_sender,"Cancel") ){ mUI.close(); }else if( mUI.IsWidget(_sender,"Apply") ){ if( !mNeedReset ){ mUI.close(); return; } try{ SimpleDataUI sdu(mUI["OgreView"]); Ogre::ConfigOptionMap& mp = mRoot->getRenderSystem()->getConfigOptions(); for( Ogre::ConfigOptionMap::iterator i=mp.begin();i!=mp.end();++i ){ SimpleData sd = sdu.get( i->first ); if( sd.type==SimpleData::STRING&&sd.str != i->second.currentValue ){ mRoot->getRenderSystem()->setConfigOption(i->first,sd.str); } } mUI.close(); mRoot->queueEndRendering(); reset(NORMAL); }catch( out_of_range& e ){ WARNING_LOG(e.what()); } } }
static inline void sdup() { /* duplicate string */ int i; SUBTITLE(strdup); /* allocation phase */ for (i = 0 ; i < MAX_ALLOC ; i ++) my_alloc[i] = sdu(); /* free phase */ fr(); }
void Game::showOptionsDialog(){ if( !mUI ){ mUI.load("Options.layout","Game"); try{ if( mUI ){ SimpleDataUI sdu(mUI["OgreView"],MyGUI::newDelegate(this,&Game::simpleDataChange)); assert(mRoot && mRoot->getRenderSystem()); mNeedReset = false; Ogre::ConfigOptionMap& mp = mRoot->getRenderSystem()->getConfigOptions(); for( Ogre::ConfigOptionMap::iterator i=mp.begin();i!=mp.end();++i ){ vector<MyGUI::UString> v(i->second.possibleValues.size()); copy(i->second.possibleValues.begin(),i->second.possibleValues.end(),v.begin()); sdu.add( i->first,SimpleData(i->first,i->second.currentValue,v) ); } sdu.reLayout(2,5); mUI["Cancel"]->eventMouseButtonClick += newDelegate(this, &Game::notifyButtonClick); mUI["Apply"]->eventMouseButtonClick += newDelegate(this, &Game::notifyButtonClick); MyGUI::ComboBox* pcombo = mUI["shadow"]->castType<MyGUI::ComboBox>(false); pcombo->addItem( "None" ); pcombo->addItem( "Stencil" ); pcombo->addItem( "Texture" ); Ogre::ShadowTechnique st = getSceneManager()->getShadowTechnique(); if( st & Ogre::SHADOWDETAILTYPE_STENCIL ) pcombo->setIndexSelected(1); else if( st & Ogre::SHADOWDETAILTYPE_TEXTURE ) pcombo->setIndexSelected(2); else pcombo->setIndexSelected(0); pcombo->eventComboChangePosition += newDelegate(this,&Game::notifyComboChange); pcombo = mUI["lighting"]->castType<MyGUI::ComboBox>(false); pcombo->addItem( "Modulative" ); pcombo->addItem( "Additive" ); if( st & Ogre::SHADOWDETAILTYPE_ADDITIVE ) pcombo->setIndexSelected( 1 ); else if( st & Ogre::SHADOWDETAILTYPE_MODULATIVE ) pcombo->setIndexSelected( 0 ); pcombo->eventComboChangePosition += newDelegate(this,&Game::notifyComboChange); mUI->eventWindowButtonPressed += newDelegate(this, &Game::notifyWindowButtonPressed); } }catch( out_of_range& e ){ WARNING_LOG(e.what()); } } }
void CameraScreen::reinit() { Camera::reinit(); // find the position of the center of the screen in 3D space this->centerScreen = position + (screenDist * direction); double cosrot = cos(rotation); double sinrot = sin(rotation); // compute the directions of the u and v vector along the screen P3S sDir(direction); P3S sdu(P3(cosrot,0.0,sinrot)); P3S sdv(P3(sinrot,0.0,cosrot)); sdu.u += sDir.u + M_PI/2; sdv.v += sDir.v; P3 du(sdu); P3 dv(sdv); du.normalize(); dv.normalize(); // deduce dx and dy this->dx = du; this->dy = - dv; // precompute the top left corner of the screen int width = screen->getWidth(); int height = screen->getHeight(); this->topLeftCornerScreen = centerScreen - ((width/2)*dx) - ((height/2)*dy); }
static inline void ran() { /* random test */ int i, j, r; int total_free; SUBTITLE(random); for (i = 0 ; i < MAX_ALLOC ; i ++) { if (my_alloc[i]) { printf("Warning! allocate buffer[%d] is not clear !\n", i); upnp_free(my_alloc[i]); my_alloc[i] = NULL; } } /* start random free/alloc phase */ total_free = 0; while (total_free < MAX_ALLOC) { r = (random() % MAX_ALLOC); if (my_alloc[r]) { total_free ++; upnp_free(my_alloc[r]); my_alloc[r] = NULL; }else { j = (random() % 4); switch(j) { case 0: /* alloc */ my_alloc[r] = al(); break; case 1: /* calloc */ my_alloc[r] = cal(); break; case 2: /* strdup */ my_alloc[r] = sdu(); break; default: /* realloc */ my_alloc[r] = real(); break; } } } /* free phase */ for (i = 0 ; i < MAX_ALLOC ; i ++) { if (my_alloc[i]) { upnp_free(my_alloc[i]); my_alloc[i] = NULL; } } }