예제 #1
0
void OGL2_Renderer::UpdateScreen()
{
	glViewport( 0, 0, (GLsizei)Engine->p_Window->GetSize().x, (GLsizei)Engine->p_Window->GetSize().y );
	Clear( true, true, vec4(0,0.74,0.52,1) );

	//m_Camera.angles = vec3(2,0,0);
	CalculateProjectionMatrix( m_Camera.origin, m_Camera.angles, m_Camera.fov, m_Camera.zNear, m_Camera.zFar );

	Engine->p_Renderer->SetBlending( BLEND_DISABLED, BLEND_DISABLED );
	Engine->p_Renderer->SetCulling( CULL_FRONT );

	p_MainShader->Bind();

	p_MainShader->SendUniform1i( p_MainShader->FindUniform("ColorMap"), 0 );
	p_MainShader->SendUniform4f( p_MainShader->FindUniform("Color"), vec4(1) );

	p_MainShader->SendMatrix4( p_MainShader->GetCoreUniform(0), ProjectionMatrix );
	p_MainShader->SendMatrix4( p_MainShader->GetCoreUniform(1), ViewMatrix );


	glPushAttrib( GL_ALL_ATTRIB_BITS );
	{
		glEnable( GL_POLYGON_OFFSET_FILL );
		glPolygonOffset( -2.5f, -2.5f );
		glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
		glLineWidth( 4.0f );

		p_MainShader->SendUniform4f( p_MainShader->FindUniform("Color"), vec4(0,0,0,0) ); // outline color

		DrawWorld();

		// Set the polygon mode to be filled triangles
		glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
		//glEnable( GL_LIGHTING );
		// Set the colour to the background
		p_MainShader->SendUniform4f( p_MainShader->FindUniform("Color"), vec4(1,1,1,1) );

		DrawWorld();
	}
	glPopAttrib();

	p_MainShader->Unbind();



	p_Ortho->OrthoProjection();


	if( Game->level.gameState != GS_PLAYING/* || Engine->UI->IsMenuOpen( "main" ) || Engine->UI->IsMenuOpen( "play" ) */)
	{
		BindImage(0);
		p_MenuBgShader->Bind();
		p_MenuBgShader->SendUniform2f( p_MenuBgShader->FindUniform("resolution"), Engine->p_Window->GetSize() );
		p_MenuBgShader->SendUniform1f( p_MenuBgShader->FindUniform("time"), Engine->p_Timer->GetTime() );
		p_Ortho->DrawQuad( vec4(0,0,640,480), vec4(1,1,1,1) );
		p_MenuBgShader->Unbind();
	}

	Engine->UI->Draw();

	glColor4f(1,1,1,1);
}
예제 #2
0
void OGL2_Renderer::FreeImage( unsigned int index )
{
	if( CRenderer::currentTexture == index && index != 0 )
		BindImage( 0 );
	glDeleteTextures( 1, &index );
}
예제 #3
0
 /// Binds as image.
 ///
 /// Without redundancy checking! Does not perform checks if texture format is valid (see http://docs.gl/gl4/glBindImageTexture)!
 /// (TODO)
 void BindImage(GLuint _slotIndex, ImageAccess _access, GLint _level = 0) const {
     BindImage(_slotIndex, _access, m_format, _level);
 }