コード例 #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 );
}