/** * Changes the window background. * * @param path image file * @param alpha values between 0-255 */ void MEdiText::setBackground(QString path, int alpha) { Background back; QPalette palette; palette.setBrush(this->backgroundRole(), back.getBrush(path, alpha)); this->setPalette(palette); }
void FileSet::initBackgrounds(map<fluorInfo, backgroundPars> bgp){ if(backgrounds.size()){ setBackgroundParameters(bgp); return; } int wcounter = 0; // horrible kludge warning for(set<fluorInfo>::iterator it=flInfo.begin(); it != flInfo.end(); it++){ ImageData* id = new ImageData(this); Background* bg = 0; if(!bgp.count((*it))){ bg = new Background(id, 16, 16, 8, 75); // default background parameters }else{ bg = new Background(id, bgp[(*it)]); } backgrounds.insert(make_pair((*it), bg)); cout << "setting background for " << wcounter << endl; bg->setBackground(wcounter); wcounter++; } // The backgrounds will need to be passed on to the frame-stacks, and so on.. // frameStacks are arranged by x and y position. hence a painful double map for(map<float, map<float, FrameStack*> >::iterator it=frames.begin(); it != frames.end(); it++){ for(map<float, FrameStack*>::iterator jt=it->second.begin(); jt != it->second.end(); jt++){ jt->second->setBackgrounds(backgrounds); } } }
MenuScreen::MenuScreen() { game = NULL; app = NULL; Player *p1 = new Player; Player *p2 = new Player; Player *p3 = new Player; Player *p4 = new Player; Player *p5 = new Player; p1->Init("monster1.png"); p2->Init("monster2.png"); p3->Init("monster3.png"); p4->Init("monster4.png"); p5->Init("monster5.png"); p1->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-65),(float)(Iw2DGetSurfaceHeight()/2-58)); p2->SetPosition((float)((Iw2DGetSurfaceWidth()/2)+10),(float)(Iw2DGetSurfaceHeight()/2-58)); p3->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-92),(float)(Iw2DGetSurfaceHeight()/2+10)); p4->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-28),(float)(Iw2DGetSurfaceHeight()/2+10)); p5->SetPosition((float)((Iw2DGetSurfaceWidth()/2)+38),(float)(Iw2DGetSurfaceHeight()/2+10)); Background *bg = new Background; bg->Init("bg2.png",(float)Iw2DGetSurfaceWidth(),(float)Iw2DGetSurfaceHeight(),true); SetBackGround(bg); AddPlayer("monster1",p1); AddPlayer("monster2",p2); AddPlayer("monster3",p3); AddPlayer("monster4",p4); AddPlayer("monster5",p5); }
void ToyExperiments::addBackground(const Background &bkg) { assert( bkg.nBins() >= Parameters::nBins() ); std::vector<double>::iterator iTot; std::vector<double>::const_iterator iBkg; // Add yields to total background iTot = meanPredictions_.begin(); iBkg = bkg.meanPredictions(); for(; iTot != meanPredictions_.end(); ++iTot, ++iBkg) { *iTot += *iBkg; } // Add uncertainties in quadrature iTot = uncorrelatedUncerts_.begin(); iBkg = bkg.uncorrelatedUncerts(); for(; iTot != uncorrelatedUncerts_.end(); ++iTot, ++iBkg) { double t = *iTot; double b = *iBkg; *iTot = sqrt( t*t + b*b ); } iTot = correlatedUncerts_.begin(); iBkg = bkg.correlatedUncerts(); for(; iTot != correlatedUncerts_.end(); ++iTot, ++iBkg) { double t = *iTot; double b = *iBkg; *iTot = sqrt( t*t + b*b ); } }
void BlenderSync::sync_world(bool update_all) { Background *background = scene->background; Background prevbackground = *background; BL::World b_world = b_scene.world(); if(world_recalc || update_all || b_world.ptr.data != world_map) { Shader *shader = scene->shaders[scene->default_background]; ShaderGraph *graph = new ShaderGraph(); /* create nodes */ if(b_world && b_world.use_nodes() && b_world.node_tree()) { BL::ShaderNodeTree b_ntree(b_world.node_tree()); add_nodes(scene, b_data, b_scene, graph, b_ntree); } else if(b_world) { ShaderNode *closure, *out; closure = graph->add(new BackgroundNode()); closure->input("Color")->value = get_float3(b_world.horizon_color()); out = graph->output(); graph->connect(closure->output("Background"), out->input("Surface")); } /* AO */ if(b_world) { BL::WorldLighting b_light = b_world.light_settings(); if(b_light.use_ambient_occlusion()) background->ao_factor = b_light.ao_factor(); else background->ao_factor = 0.0f; background->ao_distance = b_light.distance(); } shader->set_graph(graph); shader->tag_update(scene); } PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); /* when doing preview render check for BI's transparency settings, * this is so because bledner's preview render routines are not able * to tweak all cycles's settings depending on different circumstances */ if(b_engine.is_preview() == false) background->transparent = get_boolean(cscene, "film_transparent"); else background->transparent = b_scene.render().alpha_mode() == BL::RenderSettings::alpha_mode_TRANSPARENT; background->use = render_layer.use_background; if(background->modified(prevbackground)) background->tag_update(scene); }
Background::Background(Background const & cp) { this->_maxHeight = cp.getHeight(); this->_base = cp.getBase(); this->_nbLine = cp.getNbLine(); this->_win = cp.getWin(); return; }
Background* Background::create(const std::string& filename) { Background *backLayer = new Background(); if (backLayer && backLayer->init(filename)) { backLayer->autorelease(); return backLayer; } CC_SAFE_DELETE(backLayer); return NULL; }
Background* Background::create(std::string backgroundFileName) { Background *pGOL = new Background(); if (pGOL && pGOL->init(backgroundFileName)) { pGOL->autorelease(); return pGOL; } CC_SAFE_DELETE(pGOL); return NULL; }
//static Background* Background::CreateVerticalGradientBackground( const gfx::Color& color1, const gfx::Color& color2) { Background* background = CreateBackgroundPainter( true, Painter::CreateVerticalGradient(color1, color2)); background->SetNativeControlColor( gfx::AlphaBlend(color1, color2, 128)); return background; }
Background* Background::create() { Background *background = new Background(); if (background && background->init()){ background->autorelease(); return background; } CC_SAFE_DELETE(background); return nullptr; }
void BlenderSync::sync_world(bool update_all) { Background *background = scene->background; Background prevbackground = *background; BL::World b_world = b_scene.world(); if(world_recalc || update_all || b_world.ptr.data != world_map) { Shader *shader = scene->shaders[scene->default_background]; ShaderGraph *graph = new ShaderGraph(); /* create nodes */ if(b_world && b_world.use_nodes() && b_world.node_tree()) { PtrSockMap sock_to_node; BL::ShaderNodeTree b_ntree(b_world.node_tree()); add_nodes(scene, b_data, b_scene, graph, b_ntree, sock_to_node); } else if(b_world) { ShaderNode *closure, *out; closure = graph->add(new BackgroundNode()); closure->input("Color")->value = get_float3(b_world.horizon_color()); out = graph->output(); graph->connect(closure->output("Background"), out->input("Surface")); } /* AO */ if(b_world) { BL::WorldLighting b_light = b_world.light_settings(); if(b_light.use_ambient_occlusion()) background->ao_factor = b_light.ao_factor(); else background->ao_factor = 0.0f; background->ao_distance = b_light.distance(); } shader->set_graph(graph); shader->tag_update(scene); } PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); background->transparent = get_boolean(cscene, "film_transparent"); background->use = render_layer.use_background; if(background->modified(prevbackground)) background->tag_update(scene); }
Background* Background::CreateBackground() { do { Background* pRet = new Background; if (pRet && pRet->Init()) { pRet->autorelease(); return pRet; } delete pRet; } while (false); CCLog("Function Background::CreateBackground Error!"); return NULL; }
void StarsApp::draw() { gl::clear( Color::black() ); gl::pushMatrices(); gl::setMatrices( mCamera.getCamera() ); { // draw background mBackground.draw(); // draw grid if(mIsGridVisible) mGrid.draw(); // draw stars mStars.draw(); } gl::popMatrices(); // draw user interface mUserInterface.draw(); // fade in at start of application gl::enableAlphaBlending(); double t = math<double>::clamp( mTimer.getSeconds() / 3.0, 0.0, 1.0 ); float a = ci::lerp<float>(1.0f, 0.0f, (float) t); if( a > 0.0f ) { gl::color( ColorA(0,0,0,a) ); gl::drawSolidRect( getWindowBounds() ); } gl::disableAlphaBlending(); }
//------------------------------------------------------------------------------ void OneHit::Cast(TaggedRay & ray,const RenderableDB & db,const ds::List<Renderable*, mem::KillDel<Light> > & inside,const ds::List<Light*> & ll,const Background & bg) const { if (db.Intercept(ray,ray.hit,ray.inter)) { // Hit an object - respond accordingly... ray.irradiance = bs::ColourRGB(0.0,0.0,0.0); Renderable::MatSpec & ms = ray.hit->mat[ray.inter.coord.material]; if (ms.im) ms.im->Modify(ray.inter); ds::List<Light*>::Cursor targ = ll.FrontPtr(); while (!targ.Bad()) { bs::ColourRGB out; bs::Normal norm = ray.n; norm.Neg(); (*targ)->Calc(norm,ray.inter,*ms.mat,db,out); ray.irradiance += out; ++targ; } } else { // Missed all objects - use the background instead... ray.hit = null<Renderable*>(); bg.Calc(ray,ray.irradiance); } }
void StarsApp::setup() { mTime = getElapsedSeconds(); // create the spherical grid mesh mGrid.setup(); // load the star database and create the VBO mesh mStars.load( loadAsset("hygxyz.csv") ); //mStars.write( writeFile( getAssetPath("") / "hygxyz.dat" ) ); // TODO // load texture and shader mStars.setup(); // create user interface mUserInterface.setup(); // initialize background image mBackground.setup(); // initialize camera mCamera.setup(); // mIsGridVisible = false; // forceHideCursor(); // mTimer.start(); }
/************************************************ update() All update logic goes in this function. update will keep track of the status and location of the player and tiles. *************************************************/ void update(int data) { if(gameActive) { background.Scroll(); //Calculates the frame rate previousTime = currentTime; currentTime = (float)glutGet(GLUT_ELAPSED_TIME); deltaTime = (currentTime - previousTime); enemyCollision(); //Check if the player has collided with an enemy playerMove(deltaTime); //Move the player if (enemies.size() < 7 && enemyCount != 48) loadEnemies(); if (enemies.size() == 1 && enemyCount == 48 && killCount < 20) cleanUp(); /* KILL COUNT FOR LEVEL ! only */ if (player[0]->lives <0) { fadeStarted = true; cleanUp(); } if(enemies.size() == 1 && enemyCount == 48 && killCount >= 20) { killCount = 0; fadeStarted = true; cleanUp(); } } //cout << "X: " << player[0]->getX() << " Y:" << player[0]->getY() << "\n"; glutPostRedisplay(); }
Background *ResourceManager::loadBackground(const Common::String &name) const { // Open the resource Common::SeekableReadStream *stream = createReadStreamForMember(name + ".bg"); if (!stream) return NULL; // Create the new background & load the data Background *bg = new Background(); if (!bg->load(stream)) { delete bg; // stream should be freed by the Background instance return NULL; } return bg; }
void Game::start(void) { if (_gameState != Uninitialized) return; game_victory = 0; _mainWindow.create(sf::VideoMode(1024, 768, 32), "Anne McLaughlin Demo"); _view.reset(sf::FloatRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); _view.setViewport(sf::FloatRect(0, 0, 1.0f, 1.0f)); /*if (!font->loadFromFile("C:/Users/Anne/Documents/Visual Studio 2013/Projects/MyGame/Graphics/AGENTORANGE.TTF")) { std::cout << "error" << std::endl; } coinstring->setFont(*Game::font); coinstring->setString("Coins: "); coinstring->setCharacterSize(72); coinstring->setColor(sf::Color::Black); coinstring->setStyle(sf::Text::Regular); sf::FloatRect textRect = coinstring->getLocalBounds(); coinstring->setOrigin(textRect.width / 2, textRect.height / 2); coinstring->setPosition(sf::Vector2f(SCREEN_WIDTH / 2.0f, SCREEN_HEIGHT / 2.0f));*/ initObject(new PlayerCharacter, sf::Vector2f(/*SCREEN_WIDTH / 4*/ 9*SCREEN_WIDTH/10, 1000), "PlayerCharacter"); Background * bg = new Background(); level_width = bg->getSprite().getGlobalBounds().width; level_height = bg->getSprite().getGlobalBounds().height; createFloor(); _gameObjectManager.add("Background", bg); createLevelBlocks(); rigidBodyCoords = findRigidBodies(); _gameState = Game::ShowingSplash; while (!isExiting()) { gameLoop(); } _mainWindow.close(); }
void MyWindow::Render() { m_bg->Draw(); for (int i = 0; i < NUM_ICONS; i++) m_icons[i]->Draw(); }
int main(int argc, char *argv[]){ Background * background = new Background(); Color * yellow = new Yellow("color yellow"); Color * blue = new Blue("color blue"); Color * red = new Red("color red"); background->setBackground(yellow); background->setBackground(blue); background->setBackground(red); delete background; delete yellow; delete blue; delete red; }
//Called when the program is closed void CloseFunc() { window.window_handle = -1; window.TearDown(); background.TakeDown(); scene7.TearDown(); scene8.TearDown(); //delete mars_texture; }
void GameScreen::Init(std::string name) { Player *p1 = new Player; p1->Init(name+".png"); p1->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-28),(float)(Iw2DGetSurfaceHeight()/2-28)); p1->SetTarget(p1->GetPosition().x,p1->GetPosition().y); p1->SetVelocity(1,1); Background *bg = new Background; bg->Init("bg.png",(float)Iw2DGetSurfaceWidth(),(float)Iw2DGetSurfaceHeight()); SetBackGround(bg); player = name; warpID = name + genRandom(); AddPlayer(warpID,p1); WarpClientRef->connect(warpID); }
Common::Rect Scene::draw(Graphics::Surface *surface) { // Safety checks Common::Rect rect; Common::String sceneName(_name); sceneName.trim(); if (sceneName.empty()) error("Scene::draw: This scene is not a valid drawing scene!"); // Load background Background *background = ((LastExpressEngine *)g_engine)->getResourceManager()->loadBackground(sceneName); if (background) { rect = background->draw(surface); delete background; } return rect; }
BackgroundRenderer::BackgroundRenderer(const Background& background, const WallRenderContext& context, QQuickItem& parentItem) { auto content = background.getContent()->clone(); const auto& uuid = background.getContentUUID(); auto window = std::make_shared<Window>(std::move(content), uuid); const auto wallRect = QRect{QPoint(), context.wallSize}; window->setCoordinates(geometry::adjustAndCenter(*window, wallRect)); auto sync = context.provider.createSynchronizer(*window, context.view); _renderer.reset(new WindowRenderer(std::move(sync), window, parentItem, context.engine.rootContext(), true)); auto emptyGroup = DisplayGroup::create(context.screenRect.size()); const auto helper = VisibilityHelper{*emptyGroup, context.screenRect, context.isAlphaBlendingEnabled()}; _renderer->update(window, helper.getVisibleArea(*window)); }
/********************************************************** MAIN **********************************************************/ int main(int argc, char** argv) { srand(time(NULL)); // set window values win.width = 1024; win.height = 600; win.title = "Graphics Project"; win.field_of_view_angle = 90; win.z_near = 1.0f; win.z_far = 500.0f; //load new game intro text here std::strcpy(quote[0], "Hello Sontaran Protector... this is Sontar Fleet Command."); std::strcpy(quote[1], "Your oath to protect the empress with your life must be upheld."); std::strcpy(quote[2], "At this moment the Glock race has abducted the empress and fled."); std::strcpy(quote[3], "you must begin the treacherous journey of locating and saving the empress"); std::strcpy(quote[4], "The Glock race could hide their important prisoners anywhere in the galaxy"); std::strcpy(quote[5], "I dont have to tell you...every moment passed puts the empress’ life a risk."); std::strcpy(quote[6], "Good luck Protector,"); std::strcpy(quote[7], "and may Zontar's divine wisdom of war and power guide you."); //load 2 models into memory enemyModel.Load("models/eShip3.obj"); player.push_back(new Player()); currentTime = (float) glutGet(GLUT_ELAPSED_TIME); //Create window glutInit(&argc, argv); //Initialize glut glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); //Specify the modes to render your window glutInitWindowSize(win.width, win.height); //Set the window size glutInitWindowPosition(100,100); //Set the position of the window on the screen glutCreateWindow(win.title); //Creates the window and sets the title //Initialize glew glewExperimental = GL_TRUE; //Needed to make glew work glewInit(); //Initialize glew for communication with the gpu if (!(background.LoadGLTextures())) { //load background for the levels printf("error loadin scrolling background"); //dont render game if it doesnt load return 1; } //Initialize the player player[0]->init(); //Call back functions glutDisplayFunc(render); //Draws whatever is passed in to the screen glutKeyboardFunc(key); //Executes event based on the key pressed glutMouseFunc(mouse); //Executes event based on mouse button pressed initialize(); glutMainLoop(); //Main loop of the glut program. Keeps window open return 0; }
/** @details * Ohlídá plameny, pokud hoří, posune sám frame animace. * @return Vrací TRUE pokud je již vhodné objekt odstranit. */ bool Box::move(){ bool withFlame = GAME->field_withObject( x_/CELL_SIZE, y_/CELL_SIZE, FLAME); // je v ohni => hori if(withFlame) burning_=true; // hori, jeste neshorel => obnovim animaci, nastavim jestli shorel if(burning_ && !burned_) burned_ = anim_burning_.update(); // hori, uz shorel, neni na policku ohen // => spalim pozadi pod sebou a koncim if(burning_ && burned_ && !withFlame){ // spali policko na kterym byl Background * bg = static_cast<Background *>( GAME->field_getObject( x_/CELL_SIZE, y_/CELL_SIZE, BACKGROUND) ); if(bg) bg->set_burned(); return true; } return false; }
void StarsApp::update() { double elapsed = getElapsedSeconds() - mTime; mTime += elapsed; // animate camera mCamera.update(elapsed); // update background and user interface mBackground.setCameraDistance( mCamera.getCamera().getEyePoint().length() ); mUserInterface.setCameraDistance( mCamera.getCamera().getEyePoint().length() ); }
void test_panel (void *data, Evas_Object *obj, void *event_info) { Window *win = Window::factory ("panel", ELM_WIN_BASIC); win->setTitle ("Panel"); win->setAutoDel (true); Background *bg = Background::factory (*win); win->addObjectResize (*bg); bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); bg->show (); Box *bx = Box::factory (*win); bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); win->addObjectResize (*bx); bx->show (); Panel *panel = Panel::factory (*win); panel->setOrientation (ELM_PANEL_ORIENT_LEFT); panel->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); panel->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL); GenList *gl = GenList::factory (*win); gl->resize (Eflxx::Size (100, 100)); gl->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); gl->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL); gl->show (); panel->setContent (*gl); bx->packEnd (*panel); panel->show (); _fill_list (gl); #warning TODO: GenList Wrapper cerr << "TODO: GenList Wrapper" << endl; win->resize (Size (300, 300)); win->show (); }
//Called to update the display void DisplayFunc() { float current_time = float(glutGet(GLUT_ELAPSED_TIME)) / 1000.0f; glEnable(GL_CULL_FACE); glEnable(GL_NORMALIZE); glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, window.size.x, window.size.y); background.Draw(window.size); Window::time = (window.paused ? window.time_last_pause_began : current_time) - window.total_time_paused; //Draw the current scene! switch(Window::currentScene){ case 0: scene1.Draw(Window::time); break; case 1: scene2.Draw(Window::time); break; case 2: scene3.Draw(Window::scene3rotation, Window::time); break; case 3: scene4.Draw(Window::time); break; case 4: scene5.Draw(Window::time); break; case 5: scene6.Draw(Window::time); break; case 6: scene7.Draw(Window::time); break; case 7: scene8.Draw(Window::time); break; } glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); DisplayInstructions(); glFlush(); }
Walls::Walls(Background &bg) { /* basic idea: process all the tiles from the Background map (not to be confused with TileMap, which is much cooler) */ TileMap &tilemap = bg.getTileMap(); int i, j; for (j = 0; j < 60; j++) for (i= 0; i < 80; i++) { Point p(i*8, j*8); TileMapEntry *tme = tilemap.index(i,j); assert(tme); tme->setTileType(bg.mapIndex(i, j)); tme->setULCorner(p); tme->setIndex(i,j); addTile(tilemap, *tme); } }