当前位置: 首页>>代码示例>>C++>>正文


C++ PerspectiveCamera::ApplyTransformation方法代码示例

本文整理汇总了C++中PerspectiveCamera::ApplyTransformation方法的典型用法代码示例。如果您正苦于以下问题:C++ PerspectiveCamera::ApplyTransformation方法的具体用法?C++ PerspectiveCamera::ApplyTransformation怎么用?C++ PerspectiveCamera::ApplyTransformation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PerspectiveCamera的用法示例。


在下文中一共展示了PerspectiveCamera::ApplyTransformation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render

void RenderManager::Render( const Simulation &gameSim, const EngineConfig &engineCfg ) const
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //clear the screen buffer

	//render scene to fbo with active camera
    glUseProgram( geometryPassShader.GetProgramHandler() );

		glDepthMask( GL_TRUE ); //enable writing to the depth buffer
		glEnable( GL_DEPTH_TEST );

		BindDeferredFbo();

			glEnable( GL_CULL_FACE );
			glCullFace( GL_BACK );

			//bind the surface texture and pass it to the shader
			glActiveTexture( GL_TEXTURE0 );
			glUniform1i( surfaceTextureId, 0 );

			//render the simulation
			ProjectionState cameraProjection = gameSim.RenderLit();
			//ProjectionState cameraProjection = gameSim.RenderShadowCasters( gameSim.GetStaticLights()[2].GetCameras()[5] ); //for testing light cameras

			int viewportMatrix[4];
			float perspectiveMatrix[16];
			cameraProjection.CopyViewportMatrix( viewportMatrix );
			cameraProjection.CopyPerspectiveMatrix( perspectiveMatrix );

		UnbindDeferredFbo();

	glUseProgram( 0 );

	//render depth buffer to fullscreen quad
	glClear( GL_DEPTH_BUFFER_BIT );
	OrthographicCamera orthoCamera( frmr::Vec3f(), frmr::Vec2f(), engineCfg.GetActiveWidth(), engineCfg.GetActiveHeight() );
	orthoCamera.ApplyTransformation();

    glUseProgram( depthTransferShader.GetProgramHandler() );
		glActiveTexture( GL_TEXTURE0 );
		glBindTexture( GL_TEXTURE_2D, depthTexture );
		glUniform1i( depthId, 0 );
		glCallList( fullscreenQuad );
	glUseProgram( 0 );

    glDepthMask( GL_FALSE ); //disable writing to the depth buffer
    glDisable( GL_DEPTH_TEST );

    //send all the textures, the viewport parameters and the perspective matrix to the deferred rendering shader
    glUseProgram( lightPassShader.GetProgramHandler() );
		glUniform1i( normalsId, 0 );
		glUniform1i( diffuseId, 1 );
		glUniform1i( depthId, 2 );
		glUniform4iv( viewportParamsId, 4, viewportMatrix );
		glUniformMatrix4fv( perspectiveMatrixId, 16, false, perspectiveMatrix );
    glUseProgram( 0 );

    glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

    glEnable( GL_STENCIL_TEST );
    glClearStencil( 0 );

    //const vector<Light> staticLights;// = gameSim.GetStaticLights();
    vector<Light> staticLights = gameSim.GetStaticLights();

	PerspectiveCamera activeCamera = gameSim.GetActiveCamera();

    glDisable( GL_BLEND );

    for ( auto lightIt : staticLights )
    {
    	//if light casts shadows
    	//for each face
    	//render face to fbo

    	if ( lightIt.CastsShadows() )
		{
			glBindFramebuffer( GL_FRAMEBUFFER, shadowFbo );
			glViewport( 0, 0, 1024, 1024 );
			glCullFace( GL_FRONT );

			glUseProgram( shadowPassShader.GetProgramHandler() );

				int cameraIndex = 0;
				for ( auto camIt : lightIt.GetCameras() )
				{
					//if camera frustum intersects activeCamera frustum
					glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + cameraIndex++, shadowMap, 0 );
					glClear( GL_DEPTH_BUFFER_BIT );

					gameSim.RenderShadowCasters( camIt );
				}

			glUseProgram( 0 );
			glBindFramebuffer( GL_FRAMEBUFFER, 0 );
		}

        glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); //disable writing to the color buffer
        glStencilMask( 0xFF ); //enable writing to the stencil buffer

        glClear( GL_STENCIL_BUFFER_BIT );
//.........这里部分代码省略.........
开发者ID:frmr,项目名称:wizmatch,代码行数:101,代码来源:RenderManager.cpp


注:本文中的PerspectiveCamera::ApplyTransformation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。