Пример #1
0
void Choreo3DApp::renderScene()
{
    
    // gl::pushMatrices();
    mGridMesh->draw();
    // gl::popMatrices();
}
Пример #2
0
void GeometryApp::draw()
{
	// Prepare for drawing.
	gl::clear();
	gl::setMatrices( mCamera );
	
	// Draw the grid.
	if( mShowGrid && mGrid ) {
		gl::ScopedGlslProg scopedGlslProg( gl::context()->getStockShader( gl::ShaderDef().color() ) );
		// draw the coordinate frame with length 2.
		gl::drawCoordinateFrame( 2 );
		mGrid->draw();
	}

	if( mPrimitive ) {
		gl::ScopedTextureBind scopedTextureBind( mTexture );
		mPhongShader->uniform( "uTexturingMode", mTexturingMode );

		// Rotate it slowly around the y-axis.
		gl::ScopedModelMatrix matScope;
		gl::rotate( float( getElapsedSeconds() / 5 ), 0, 1, 0 );

		// Draw the normals.
		if( mShowNormals && mPrimitiveNormalLines ) {
			gl::ScopedColor colorScope( Color( 1, 1, 0 ) );
			mPrimitiveNormalLines->draw();
		}

		// Draw the primitive.
		gl::ScopedColor colorScope( Color( 0.7f, 0.5f, 0.3f ) );

		if( mViewMode == WIREFRAME ) {
			// We're using alpha blending, so render the back side first.
			gl::ScopedAlphaBlend blendScope( false );
			gl::ScopedFaceCulling cullScope( true, GL_FRONT );

			mWireframeShader->uniform( "uBrightness", 0.5f );
			mPrimitiveWireframe->draw();

			// Now render the front side.
			gl::cullFace( GL_BACK );

			mWireframeShader->uniform( "uBrightness", 1.0f );
			mPrimitiveWireframe->draw();
		}
		else
			mPrimitive->draw();
	}

	// Render the parameter window.
#if ! defined( CINDER_GL_ES )
	if( mParams )
		mParams->draw();
#endif
}
void GeometryShaderIntroApp::draw()
{
	gl::clear();
	
	gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
	gl::translate( getWindowCenter() );

	gl::ScopedGlslProg glslProg( mGlsl );
	mGlsl->uniform( "uNumSides", mNumSides );
	mGlsl->uniform( "uRadius", mRadius );	
	mBatch->draw();
}
Пример #4
0
void TessellationShaderApp::draw()
{
	gl::clear();
#if ! defined( CINDER_GL_ES )
	gl::enableWireframe();
#endif
	
	gl::setMatricesWindow( getWindowSize() );
	gl::translate( getWindowCenter() );
	
	gl::ScopedGlslProg glslProg( mGlsl );
	mGlsl->uniform( "uTessLevelInner", (float)mTessLevelInner );
	mGlsl->uniform( "uTessLevelOuter", (float)mTessLevelOuter );
	mGlsl->uniform( "uRadius", mRadius );	
	
	mBatch->draw();

#if ! defined( CINDER_GL_ES )
	gl::disableWireframe();
	mParams->draw();
#endif
}
Пример #5
0
void ImmediateModeApp::draw()
{
	gl::clear();	

	gl::VertBatch vb( GL_TRIANGLES );
		vb.color( 1, 0, 0 );
		vb.vertex( getWindowWidth() / 2, 50 );
		vb.color( 0, 1, 0 );
		vb.vertex( getWindowWidth() - 50, getWindowHeight() - 50 );
		vb.color( 0, 0, 1 );
		vb.vertex( 50, getWindowHeight() - 50 );
	vb.draw();



	// draw
	mBatch->begin( GL_LINE_STRIP );
	for( const vec2 &point : mPoints ) {
		mBatch->vertex( vec4( point, 0, 1 ), Color( 1.0f, 0.5f, 0.25f ) );
	}
	mBatch->draw();
}
Пример #6
0
void GeometryApp::draw()
{
	// Prepare for drawing.
	gl::clear();
	gl::setMatrices( mCamera );

	// Enable the depth buffer.
	gl::enableDepthRead();
	gl::enableDepthWrite();

	if( mPrimitive ) {
		gl::ScopedTextureBind scopedTextureBind( mTexture );
		mPhongShader->uniform( "uTexturingMode", mTexturingMode );
		mPhongShader->uniform( "uFreq", ( mPrimitiveCurrent == TORUSKNOT ) ? ivec2( 100, 10 ) : ivec2( 20 ) );

		// Rotate it slowly around the y-axis.
		gl::ScopedModelMatrix matScope;
		//gl::rotate( float( getElapsedSeconds() / 5 ), 0, 1, 0 );

		// Draw the normals.
		if( mShowNormals && mPrimitiveNormalLines ) {
			gl::ScopedColor colorScope( Color( 1, 1, 0 ) );
			mPrimitiveNormalLines->draw();
		}

		// Draw the tangents.
		if( mShowTangents && mPrimitiveTangentLines ) {
			gl::ScopedColor colorScope( Color( 0, 1, 0 ) );
			mPrimitiveTangentLines->draw();
		}

		// Draw the wire primitive.
		if( mShowWirePrimitive && mPrimitiveWire ) {
			gl::ScopedColor color( Color( 1, 1, 1 ) );
			gl::ScopedLineWidth linewidth( 2.5f );

			mPrimitiveWire->draw();
		}

		// Draw the primitive.
		if( mShowSolidPrimitive ) {
			gl::ScopedColor colorScope( Color( 1, 1, 1 ) );

			if( mViewMode == WIREFRAME ) {
				// We're using alpha blending, so render the back side first.
				gl::ScopedBlendAlpha blendScope;
				gl::ScopedFaceCulling cullScope( true, GL_FRONT );

				mWireframeShader->uniform( "uBrightness", 0.5f );
				mPrimitiveWireframe->draw();

				// Now render the front side.
				gl::cullFace( GL_BACK );

				mWireframeShader->uniform( "uBrightness", 1.0f );
				mPrimitiveWireframe->draw();
			}
			else {
				gl::ScopedFaceCulling cullScope( mEnableFaceFulling, GL_BACK );

				mPrimitive->draw();
			}
		}
	}

	// 
	gl::disableDepthWrite();

	// Draw the grid.
	if( mShowGrid && mGrid ) {
		gl::ScopedGlslProg scopedGlslProg( gl::context()->getStockShader( gl::ShaderDef().color() ) );

		mGrid->draw();

		// draw the coordinate frame with length 2.
		gl::drawCoordinateFrame( 2 );
	}

	// Disable the depth buffer.
	gl::disableDepthRead();

	// Render the parameter windows.
#if ! defined( CINDER_GL_ES )
	if( mParams ) {
		mParams->draw();
	}
#endif
}