コード例 #1
0
void render( base::ContextPtr context, base::CameraPtr cam )
{
	// render to texture
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	glClearStencil( 0 );
	multisampleFBO->begin( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );

	glDisable( GL_DEPTH_TEST );

	// initialize stencil buffer ---
	glEnable(GL_STENCIL_TEST);
	glEnable( GL_MULTISAMPLE );
	glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
	glEnable(GL_SAMPLE_MASK);
	for(int i = 0; i < 4; ++i)
	{
		glStencilFunc(GL_ALWAYS, i + 1, 0xff);
		glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
		glSampleMaski(0, 0x1 << i);
		context->renderScreen(initializeStencilShader);
	}
	glSampleMaski(0, 0xFFFFFF);
	glDisable(GL_SAMPLE_MASK);
	glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
	glDisable( GL_MULTISAMPLE );


	// now render geometry using stencil routing ---
	glStencilFunc(GL_EQUAL, 1, 0xff);
	glStencilOp(GL_DECR, GL_DECR, GL_DECR );

	context->setCamera( cam );
	context->render( geometry, shader );

	glDisable(GL_STENCIL_TEST);

	multisampleFBO->end();





	//  final render the shader
	// NB: the multisampleTestShader in its pixel section fetches a single sample for each fragment. change the sample index in the
	// fetchTexture function to check the values for the different samples
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	glClearStencil( 0 );

	//we also clear the stencil buffer
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );

	context->renderScreen( multisampleTestShader );



}
コード例 #2
0
ファイル: main.cpp プロジェクト: dkoerner/sandbox
void render( base::CameraPtr cam )
{
	// put rendering code here
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	context->setCamera( cam );

	//context->render( grid, greyShader );

	step();

	glPointSize(5.0f);
	context->render( particles, greyShader );
}
コード例 #3
0
ファイル: Demo.cpp プロジェクト: dkoerner/sandbox
void Demo::render( base::ContextPtr context )
{
	if( m_shots.empty() )
		return;


	float time = context->time();

	// find current shot
	Shot *shot = &m_shots[0];
	for( int i=0, numShots = (int)m_shots.size();i<numShots;++i )
	{
		Shot &s = m_shots[i];
		if( ( time > s.start)&&( time < s.end) )
		{
			shot = &s;
			break;
		}
	}

	//std::cout << shot->scene->getName() << std::endl;
	//std::cout << time << std::endl;
	

	float localTime = shot->getLocalTime(time);
	
	// update camera from shot camera
	if( shot->camera )
	{
		m_camera->m_transform = shot->camera->xform.eval(localTime);
		m_camera->m_fov = math::degToRad(shot->camera->fov);
		m_camera->update();
	}
	//context->setCamera( m_camera );

	m_renderFBO->begin();
	shot->scene->render(context);
	m_renderFBO->end();
	
	m_post->render();



	// debug
	//m_visualiser->render();
}