Exemple #1
0
//Método principal para atualização do game em tempo real
void Game::gameUpdate(){
	//Limite de Frame Rate
	gameWindow.setFramerateLimit(60);

	//Checa se algum dos players completou as 3 voltas
	isRaceOver();

	//Verifica se a tecla ESC é pressionada, abrindo o menuPause
	renderPause();
	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
		menuPause.abrirMenu();

	//Toca a música que será reproduzida durante a corrida
	raceBGM.playMusic();
	raceBGM.setVolume(100);

	//Ativa os métodos de entrada de keyboard para os controles de ambos os players
	player[0].ativarMovimentos(0);
	player[1].ativarMovimentos(1);

	//Checa todas as colisões possíveis dentro da partida para cada Player
	checkCollision(0);
	checkCollision(1);

	//Checa se os players estão no sentido correto da pista (caso eles percorram ao contrário), seus
	//carros explodirão
	player[0].checarSentido();
	player[1].checarSentido();

	//Checa durante a partida quando a linha de chegada é ultrapassada
	checkLap();
	
	//Centralizando cada câmera em seu respectivo player
	player[0].centralizarCamera();
	player[1].centralizarCamera();

	//Renderizações na tela do Player1
	gameWindow.setView(player[0].getCamera());
	renderMap();
	gameWindow.draw(player[0].getSprite());
	gameWindow.draw(player[1].getSprite());
	renderProjeteis();
	renderGUI(0);
	
	//Renderizações na tela do Player 2
	gameWindow.setView(player[1].getCamera());
	renderMap();
	gameWindow.draw(player[1].getSprite());
	gameWindow.draw(player[0].getSprite());
	renderProjeteis();
	renderGUI(1);

	gameWindow.display();
	gameWindow.clear();
}
Exemple #2
0
/*********************************************
		Does all the 2D rendering
			(fonts, HUD, etc)
**********************************************/
void App::render2D(){
	glShadeModel(GL_FLAT);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	
	drawStatusBar();
	
	if(isConnected()){
		mFlowMgr->render2d();
	}
	
	
	ps()->render2D();
	
	//Render the GUI

#ifdef ENABLE_GUI
	renderGUI();	
#endif

#ifdef ENABLE_CGL_COMPAT

	//Get rid of the system mouse cursor, it's useless
	SDL_ShowCursor(SDL_DISABLE);

	//render a mouse cursor on our end
	int x = iMouseX;
	int y = iMouseY;
	int s = iScreenX / 32;
		
	Texture *tex = texGet("mouse.png");
	LOG("Creating mouse cursor\n");
	
	if(!tex){
		LOG("No mouse cursor texture!\n");
	}else{
		tex->bind();
		
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
		glColor4f(1,1,1,0.0f);
		
		glBegin(GL_QUADS);
			glTexCoord2f(0, 0); glVertex2f(x, y);
			glTexCoord2f(1, 0); glVertex2f(x + s, y);
			glTexCoord2f(1, 1); glVertex2f(x + s, y + s);
			glTexCoord2f(0, 1); glVertex2f(x, y + s);
		glEnd();
		
		glDisable(GL_BLEND);
	}
#endif
	
		
}
void Renderer::render()
{
    updateCamera(); 
    mScene.update();
    mGui.update();

    renderLighting();
    renderScene();
    renderGUI();    

    if(renderStateButton == ButtonType::B_TEXT)
    {
        renderTextState();
    }
}
Exemple #4
0
void Screen_GP_Clung::draw()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

	m_textureProgram.use();

	// Upload texture uniform
	GLint textureUniform = m_textureProgram.getUniformLocation("mySampler");
	glUniform1i(textureUniform, 0);
	glActiveTexture(GL_TEXTURE0);

	// Camera matrix
	glm::mat4 projectionMatrix = m_camera.getCameraMatrix();
	GLint pUniform = m_textureProgram.getUniformLocation("P");
	glUniformMatrix4fv(pUniform, 1, GL_FALSE, &projectionMatrix[0][0]);

	m_spriteBatch.begin();
	
	for (Entity_Clung* e : m_entities) {
		if (m_camera.isBoxInView(e->getPosition() - (e->getDrawDims() / 2.0f), e->getDrawDims())) {
			e->draw(m_spriteBatch);
		}
	}

	for (Item_Clung* e : m_items) {
		if (m_camera.isBoxInView(e->getPosition() - (e->getDrawDims() / 2.0f), e->getDrawDims())) {
			e->draw(m_spriteBatch);
		}
	}

	m_spriteBatch.end();
	m_spriteBatch.renderBatch();
	m_textureProgram.unuse();

	renderGUI(projectionMatrix);

	if (m_debug) renderDebug(projectionMatrix);
}
Exemple #5
0
void App::onGraphics3D(RenderDevice* rd, Array<shared_ptr<Surface> >& allSurfaces) {
    // This implementation is equivalent to the default GApp's. It is repeated here to make it
    // easy to modify rendering. If you don't require custom rendering, just delete this
    // method from your application and rely on the base class.

    if (! scene()) {
        return;
    }

    // Debug visualizations and post-process effects
    rd->pushState(m_framebuffer); {
        // Call to make the App show the output of debugDraw(...)
        rd->setProjectionAndCameraMatrix(activeCamera()->projection(), activeCamera()->frame());
	
	    rd->setColorClearValue(Color3::black());
	    rd->clear();
        const Ray& mouseRay = scene()->eyeRay(activeCamera(), userInput->mouseXY() + Vector2(0.5f, 0.5f), rd->viewport(), Vector2int16(0, 0));
	    m_automata.draw(rd, mouseRay, m_gridColor);
        if (m_showHelp) {
            renderGUI(rd);
        }
        

    } rd->popState();

    if ((submitToDisplayMode() == SubmitToDisplayMode::MAXIMIZE_THROUGHPUT) && (!renderDevice->swapBuffersAutomatically())) {
        // We're about to render to the actual back buffer, so swap the buffers now.
        // This call also allows the screenshot and video recording to capture the
        // previous frame just before it is displayed.
        swapBuffers();
    }

	// Clear the entire screen (needed even though we'll render over it, since
    // AFR uses clear() to detect that the buffer is not re-used.)
    rd->clear();

    // Perform gamma correction, bloom, and SSAA, and write to the native window frame buffer
    m_film->exposeAndRender(rd, activeCamera()->filmSettings(), m_framebuffer->texture(0));
}
Exemple #6
0
void StagePlay::render()
{
	game = Game::instance;
	//set the clear color (the background color)
	glClearColor(0.0, 0.0, 0.0, 1.0);

	// Clear the window and the depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//Put the camera matrices on the stack of OpenGL (only for fixed rendering)
	game->current_camera->set();
	glEnable(GL_DEPTH_TEST);
	world->root->render(game->current_camera);
	world->skybox->render(game->current_camera);

	game->bulletMng->render(game->current_camera);

	game->renderDebug(game->current_camera);

	renderGUI();
	if (game->time_scale == 0) stoppingGame();

	glDisable(GL_DEPTH_TEST);
}