Example #1
0
    //------------------------------------------------------------------------------
    //------------------------------------------------------------------------------
    const Matrix4& CameraComponent::GetProjection() 
    {
        if(m_isProjCacheValid == false)
        {
            m_projMat = CalculateProjectionMatrix();
            m_isProjCacheValid = true;
        }

        return m_projMat;
    }
Example #2
0
void OGL3_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();

    DrawWorld();

	p_MainShader->Unbind();
}
Example #3
0
void Camera::Update(float dt)
{
	bool recalculateViewProjectionMatrix = mRecalculateViewMatrix || mRecalculateProjectionMatrix;
	if(mRecalculateViewMatrix)
	{
		CalculateViewMatrix();
	}

	if(mRecalculateProjectionMatrix)
	{
		CalculateProjectionMatrix();
	}

	if(recalculateViewProjectionMatrix)
	{
		XMMATRIX view = XMLoadFloat4x4(&mViewMatrix);
		XMMATRIX proj = XMLoadFloat4x4(&mProjectionMatrix);
		XMMATRIX viewProj = view * proj;
		XMStoreFloat4x4(&mViewProjectionMatrix, viewProj);
	}
}
Example #4
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);
}