Esempio n. 1
0
void Choreo3DApp::setupEnviron( int xSize, int zSize, int spacing )
{
    CI_ASSERT( ( spacing <= xSize ) && ( spacing <= zSize ) );
    
    // Cut in half and adjust for spacing.
    xSize = ( ( xSize / 2 ) / spacing ) * spacing;
    zSize = ( ( zSize / 2 ) / spacing ) * spacing;
    
    const int xMax = xSize + spacing;
    const int zMax = zSize + spacing;
//    const ColorA defaultColor( 0.9f, 0.9f, 0.9f,0.1f);
    gridColor = ColorA( 0.9f, 0.9f, 0.9f,0.1f);
    const ColorA black( 0, 0, 0, 1 );
    
    mGridMesh = gl::VertBatch::create( GL_LINES );
    
    // Add x lines.
    for( int xVal = -xSize; xVal < xMax; xVal += spacing ) {
        mGridMesh->color( gridColor );
        mGridMesh->vertex( (float)xVal, 0, (float)-zSize );
        mGridMesh->vertex( (float)xVal, 0, (float)zSize );
    }// end for each x dir line
    
    // Add z lines.
    for( int zVal = -zSize; zVal < zMax; zVal += spacing ) {
        mGridMesh->color( gridColor );
        mGridMesh->vertex( (float)xSize, 0, (float)zVal );
        mGridMesh->vertex( (float)-xSize, 0, (float)zVal );
    }// end for each z dir line
    
    //SETUP THE CAMERA
    mCamera.lookAt( vec3( 500, 500, 0 ), vec3( 0 ) );
    mCamera.setEyePoint(vec3(500,1000,0));
    mCamera.setFarClip(20000);
}
Esempio n. 2
0
void TessellationShaderApp::setup()
{
	mTessLevelInner = mTessLevelOuter = 4;
	int maxPatchVertices = 0;
	glGetIntegerv( GL_MAX_PATCH_VERTICES, &maxPatchVertices );
	app::console() << "Max supported patch vertices " << maxPatchVertices << std::endl;



#if ! defined( CINDER_GL_ES )
	fs::path glDir = "ogl";
	mRadius = 200.0f;

	mParams = params::InterfaceGl::create( "Settings", ivec2( 200, 200 ) );
	mParams->addParam( "Radius", &mRadius, "step=1.0" );
	mParams->addParam( "Tess level inner", &mTessLevelInner, "min=0" );
	mParams->addParam( "Tess level outer", &mTessLevelOuter, "min=0" );
#else
	fs::path glDir = "es31a";
	mRadius = 400.0f;
#endif
	
	try {
		mGlsl = gl::GlslProg::create( gl::GlslProg::Format()
									 .vertex( loadAsset( glDir / "0_vert.glsl" ) )
									 .tessellationCtrl( loadAsset( glDir / "1_tess_ctrl.glsl" ) )
									 .tessellationEval( loadAsset( glDir / "2_tess_eval.glsl" ) )
#if defined( CINDER_GL_ES )
									 .geometry( loadAsset( glDir / "x_geom.glsl" ) )
#endif
									 .fragment( loadAsset( glDir / "3_frag.glsl" ) ) );
	}
	catch( const std::exception &ex ) {
		console() << ex.what() << endl;
		//quit();
	}

	mBatch = gl::VertBatch::create( GL_PATCHES );
	mBatch->color( 1.0f, 0.0f, 0.0f );
	mBatch->vertex( vec2( 1, -1 ) );
	mBatch->color( 0.0f, 1.0f, 0.0f );
	mBatch->vertex( vec2( 0 , 1 ) );
	mBatch->color( 0.0f, 0.0f, 1.0f );
	mBatch->vertex( vec2( -1, -1 ) );
	
	gl::patchParameteri( GL_PATCH_VERTICES, 3 );
}
Esempio n. 3
0
void GeometryApp::createGrid()
{
	mGrid = gl::VertBatch::create( GL_LINES );
	mGrid->begin( GL_LINES );
	for( int i = -10; i <= 10; ++i ) {
		mGrid->color( Color( 0.25f, 0.25f, 0.25f ) );
		mGrid->color( Color( 0.25f, 0.25f, 0.25f ) );
		mGrid->color( Color( 0.25f, 0.25f, 0.25f ) );
		mGrid->color( Color( 0.25f, 0.25f, 0.25f ) );

		mGrid->vertex( float( i ), 0.0f, -10.0f );
		mGrid->vertex( float( i ), 0.0f, +10.0f );
		mGrid->vertex( -10.0f, 0.0f, float( i ) );
		mGrid->vertex( +10.0f, 0.0f, float( i ) );
	}
	mGrid->end();
}
void GeometryShaderIntroApp::setup()
{
	mNumSides = 2;
	mRadius = 100;

	// setup shader
	try {
		mGlsl = gl::GlslProg::create( gl::GlslProg::Format().vertex( loadAsset( "basic.vert" ) )
									 .fragment( loadAsset( "basic.frag" ) )
									 .geometry( loadAsset( "basic.geom" ) ) );
	}
	catch( gl::GlslProgCompileExc ex ) {
		cout << ex.what() << endl;
		quit();
	}

	// setup VertBatch with a single point at the origin
	mBatch = gl::VertBatch::create();
	mBatch->vertex( vec2( 0 ) );
	mBatch->color( 1, 0, 0 );
}
Esempio n. 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();
}