コード例 #1
0
ファイル: serpentsengine.cpp プロジェクト: dezGusty/serpents
  bool SerpEngine::renderCompleteScene()
  {
    // This is basically a copy of the standard OGRE root function "renderOneFrame".
    // What it does in addition to the aforementioned function is to add a mutex lock for
    // loading and rendering operations.
    // The function should be called from the rendering thread!

    if (NULL == frameListenerPtr_)
    {
      return false;
    }

    guslib::Timer myTimer;
    myTimer.reset();

    GTRACE(5, "Engine: render complete scene() entered.");
    if (isExiting())
    {
      return false;
    }

    // Trigger the FrameListener's "frameStarted" function to render the 3D scene.
    if (false == rootPtr_->_fireFrameStarted())
    {
      GTRACE(1, "GBaseEngine::renderCompleteScene received error from _fireFrameStarted");
      return false;
    }

    if (isExiting())
    {
      return false;
    }

    try
    {
      if (false == rootPtr_->_updateAllRenderTargets())
      {
        GTRACE(1, "GBaseEngine::renderCompleteScene received error from _updateAllRenderTargets");
        return false;
      }
    }
    catch (Ogre::Exception & e)
    {
      GTRACE(1, "Exception caught! GBaseEngine::renderCompleteScene(): " << e.getFullDescription());
    }

    if (isExiting())
    {
      return false;
    }

    // Trigger the FrameListener's "frameEnded" function.
    bool returnValue = rootPtr_->_fireFrameEnded();

    GTRACE(5, "Engine: render complete scene() exiting. Render took: "<< myTimer.elapsed()<< " time units.");
    GTRACE(6, "GBaseEngine::renderCompleteScene() releasing mutex(loadAndRenderMutex)");
    return returnValue;
  }
コード例 #2
0
ファイル: NvAppBase.cpp プロジェクト: 151706061/OpenGLSamples
void NvAppBase::mainLoop() {
    bool hasInitializedGL = false;

    while (getPlatformContext()->isAppRunning() && !isExiting()) {
        bool needsReshape = false;

        getPlatformContext()->pollEvents(this);

        NvPlatformContext* ctx = getPlatformContext();

        update();

        // If the context has been lost and graphics resources are still around,
        // signal for them to be deleted
        if (ctx->isContextLost()) {
            if (hasInitializedGL) {
                shutdownRendering();
                hasInitializedGL = false;
            }
        }

        // If we're ready to render (i.e. the GL is ready and we're focused), then go ahead
        if (ctx->shouldRender()) {
            // If we've not (re-)initialized the resources, do it
            if (!hasInitializedGL) {
                NvImage::setAPIVersion(getGLContext()->getConfiguration().apiVer);

                initRendering();
                hasInitializedGL = true;
                needsReshape = true;
            } else if (ctx->hasWindowResized()) {
                needsReshape = true;
            }

            if (needsReshape) {
                reshape(getGLContext()->width(), getGLContext()->height());
            }

            if (!isExiting()) {
                draw();

                getGLContext()->swap();
            }
        }
    }

    if (hasInitializedGL) {
        shutdownRendering();
        hasInitializedGL = false;
    }
}
コード例 #3
0
ファイル: Game.cpp プロジェクト: luckyk7/Chess
void Game::start(void)
{
	if (_gameState != Uninitialized)
		return;

	_mainWindow.create(sf::VideoMode(800, 600, 32),"Chess");
	_mainWindow.setPosition(sf::Vector2i(0, 0));

	//Where we will load all objects then place in gameobjectmanager
	VisibleGameObject *boardImage = new VisibleGameObject();
	boardImage->Load("images/Board.png");
	boardImage->setPostion(0, 0);

	VisibleGameObject *Rook = new VisibleGameObject();
	Rook->Load("images/WhiteRook.png");
	Rook->setPostion(15, 15);

	_gameObjectManager.add("Board", boardImage);
	_gameObjectManager.add("WR1", Rook);
	_gameState = Game::ShowingSplash;

	while (!isExiting())
	{
		loop();
	}

	_mainWindow.close();
}
コード例 #4
0
ファイル: Engine.cpp プロジェクト: simon445561/SDL_Game
void Engine::start( )
{
    if( engineState != initializing )
        return;

    apply_surface( 0, 0, background, screen );

    for( int i=0; i<4; i++ )
    {
        for( int j=0; j<6; j++ )
        {
            square[i][j].SetPosition( ( j*170 ) +28, ( i*170 )+150 );
        }
    }

    square[3][0].Undead = true;
    square[0][5].Undead = true;
    square[3][0].Load( true );
    square[0][5].Load( true );
    square[3][0].setClip( 0 );
    square[0][5].setClip( 0 );

    engineState = Engine::showingSplash;

    while( !isExiting( ) )
    {
        EngineLoop();
    }

    SDL_Quit();
}
コード例 #5
0
ファイル: Game.cpp プロジェクト: anneomcl/MyGame
void Game::start_loss()
{
	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));

	PlayerCharacter * player = (PlayerCharacter *)_gameObjectManager.getByTypeSingle("PlayerCharacter");
	player->setPosition(500, 1000);
	player->coins = 0;
	player->lives = 0;
	player->grounded = true;


	reset_mystery_blocks();


	_gameState = Game::ShowingSplashLoss;

	while (!isExiting())
	{
		gameLoop();
	}
	_mainWindow.close();
}
コード例 #6
0
ファイル: serpentsengine.cpp プロジェクト: dezGusty/serpents
  bool SerpEngine::keyPressed(const OIS::KeyEvent &arg)
  {
    if (isExiting())
    {
      return true;
    }

    if (arg.key == OIS::KC_ESCAPE)
    {
      // TODO: add exit!
      shutDown();
    }

    // key down
    utils::CEGUIHelperUtil::injectKeyDown(arg.key);

    // now character
    utils::CEGUIHelperUtil::injectChar(arg.text);

    GTRACE(5, "keyPressed, " << arg.key << " thread : " << boost::this_thread::get_id());

    // TODO: this limits the possibilities of subclasses a lot; should consider sending the full event.
    stateManager_.reactToKeyPress(arg.key);
    return true;
  }
コード例 #7
0
ファイル: Game.cpp プロジェクト: vindow/Dodge-and-Load
void Game::start(void)
{
	if (gameState_ != Uninitialized)
		return;

	mainWindow_.create(sf::VideoMode(1024, 768, 32), "Dodge and Load");
	mainWindow_.setFramerateLimit(60);

	init();

	float frameTime = 1.0f / 60.0f;
	float currTime = 0.0f;
	while (!isExiting())
	{
		if (currTime > frameTime)
		{
			gameLoop();
			currTime = 0.0f;
		}
		currTime += clock_.getElapsedTime().asSeconds();
		clock_.restart().asSeconds();
	}

	mainWindow_.close();
}
コード例 #8
0
GlobalUISession::GlobalUISession() :
   localHuman_(0), localEngine_(0), localHuman1_(0), localHuman2_(0),
   gameSession_(0), keyRemapIdx_(-1), menuType_(menuNone)
{
   initialize();
   //
   initialPosition_ = ChessPosition::fromString(toStdString(g_settings.initialPositionFen()));
   initialPosition_.setChess960(g_settings.isChess960());
   //
   QObject::connect(&g_settings, SIGNAL(playerNameChanged()), this, SLOT(playerNameChanged()), Qt::UniqueConnection);
   QObject::connect(&g_settings, SIGNAL(engineChanged()), this, SLOT(engineChanged()), Qt::UniqueConnection);
   QObject::connect(&g_settings, SIGNAL(ponderingChanged()), this, SLOT(ponderingChanged()), Qt::UniqueConnection);
   QObject::connect(&g_settings, SIGNAL(localeChanged()), this, SLOT(localeChanged()), Qt::UniqueConnection);
   QObject::connect(&g_localChessGui, SIGNAL(keyPressed(Qt::Key,Qt::KeyboardModifiers)), this, SLOT(keyPressed(Qt::Key, Qt::KeyboardModifiers)), Qt::UniqueConnection);
   QObject::connect(&g_localChessGui, SIGNAL(isExiting()), this, SLOT(isExiting()));
}
コード例 #9
0
ファイル: llapp.cpp プロジェクト: Barosonix/AstraViewer
// static
void LLApp::setQuitting()
{
	if (!isExiting())
	{
		// If we're already exiting, we don't want to reset our state back to quitting.
		llinfos << "Setting app state to QUITTING" << llendl;
		setStatus(APP_STATUS_QUITTING);
	}
}
コード例 #10
0
ファイル: serpentsengine.cpp プロジェクト: dezGusty/serpents
  bool SerpEngine::keyReleased(const OIS::KeyEvent &arg)
  {
    GTRACE(5, "keyReleased, " << arg.key);
    if (isExiting())
    {
      return true;
    }
    utils::CEGUIHelperUtil::injectKeyUp(arg.key);

    // TODO: this limits the possibilities of subclasses a lot; should consider sending the full event.
    stateManager_.reactToKeyRelease(arg.key);
    return true;
  }
コード例 #11
0
ファイル: Game.cpp プロジェクト: Sour/CodeDump
void Game::start(void)
{
	if(_gameState != Uninitialized)
		return;

	_mainWindow.create(VideoMode(640, 480, 32), "Breakout");

	

	_gameState = Game::Playing;

	while(!isExiting())
		gameLoop();
	_mainWindow.close();
}
コード例 #12
0
ファイル: Game.cpp プロジェクト: nairn1983/game2
void Game::start() {
	if(gameState == UNINITIALISED) {
	    setupGameObjects();

		mainWindow.create(sf::VideoMode(1024, 768, 32), "Game2");
		mainWindow.display();

		while(!isExiting()) {
			gameLoop();
		}

		DEBUG("Closing main window");
		mainWindow.close();
	}
}
コード例 #13
0
ファイル: KinectScene2.cpp プロジェクト: pierrep/Sound-Vision
// called when scene is exiting
void KinectScene2::updateExit() {
		
	// called on first exit update
	if(isExitingFirst()) {
		ofLogNotice("KinectScene2") << "update exit";
	}
			
	// fade scene calculates normalized alpha value for us
	ofxFadeScene::updateExit();
			
	// finished exiting?
	if(!isExiting()) {
		ofLogNotice("KinectScene2") << "update exit done";
	}
}
コード例 #14
0
ファイル: Game.cpp プロジェクト: anneomcl/MyGame
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();
}
コード例 #15
0
void GameScreen::start()
{
    if (_isRunning)
    {
        _logger.logMessage(" Already Running....Can not start again...");
    }
    _isRunning = true;
    _rendererThread = new boost::thread(boost::bind(&GameScreen::render, this));
    //boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
    _logger.logMessage(" Starting Game....");
    while (!isExiting())
    {
        gameLoop();
    }
    _rendererThread->join();
    _logger.logMessage(" Stopping Game....");
}
コード例 #16
0
void GameScreen::render()
{
    try
    {
        while (!isExiting())
        {
            switch (_currentState)
            {
            case PLAYING:
            {
                _window.clear(sf::Color::White);

                // Test Draw String
                sf::Font font;
                font.loadFromFile("/Users/ankithbti/Development/Quand_tu_dors_.otf");
                sf::Text text;
                text.setFont(font);
                text.setString("Testing the screen drawing for Game....");
                text.setCharacterSize(2.0f);
                _window.draw(text);

                // For All Game entities
                _gameEntityManager.drawAll(_window);

                _window.display();
            }
                break;
            default:
            {
                boost::this_thread::sleep(boost::posix_time::milliseconds(500));
            }
                break;
            }
        }
    }
    catch (const boost::thread_interrupted& err)
    {
        // Ignore
    }
    catch (...)
    {
        // Ignore
    }
    _logger.logMessage("Ending Render Thread....");
}
コード例 #17
0
ファイル: Game.cpp プロジェクト: anneomcl/MyGame
void Game::start_victory(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));

	PlayerCharacter * player = (PlayerCharacter *) _gameObjectManager.getByTypeSingle("PlayerCharacter");
	player->setPosition(500, 1000);
	player->coins = 0;
	player->lives = 0;
	player->grounded = true;


	reset_mystery_blocks();

	/*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::ShowingSplashVictory;

	while (!isExiting())
	{
		gameLoop();
	}
	_mainWindow.close();
}