Beispiel #1
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 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();
}