本文整理汇总了C++中gl::BatchRef类的典型用法代码示例。如果您正苦于以下问题:C++ BatchRef类的具体用法?C++ BatchRef怎么用?C++ BatchRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BatchRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Color
void Day61App::draw()
{
gl::setMatrices(mCam);
gl::clear( Color( 0.0, 0.0, 0.0 ) );
{
gl::ScopedMatrices scpMtr;
gl::rotate(angleAxis(theta, vec3(0,1,0)));
gl::color(ColorAf(1.,1.,1.,1.));
mSolidSphere->draw();
}
// mBatch->draw();
for (int i = 0 ; i < 20 ; i++)
{
mPos.x = cos(theta + 12*i);
mPos.y = 0.5 - cos(sin(theta + i));
mPos.z = sin(theta + 12*i);
gl::ScopedMatrices push;
gl::translate(mPos);
mBatch->draw();
}
//if(getElapsedFrames() > 240) saveGif();
saveGif();
}
示例2: scopeStencil
void Day59App::draw()
{
gl::setMatrices(mCam);
gl::clear( Color( 0.1, 0.1, 0.1 ) );
gl::color(Color(0.,0.,0.));
gl::clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
mCam.setEyePoint(vec3(0.,0.,fabs(cos(omega) * 50.f)));
mPerlin.setSeed(getElapsedFrames());
// enable stencil test to be able to give the stencil buffers values.
gl::ScopedState scopeStencil( GL_STENCIL_TEST, true );
// gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
for (int i =0; i <NUM_OBJS; i++)
{
vec3 noise = mPerlin.dfBm(mRandomPositions[i]);
gl::ScopedMatrices scpMtx;
gl::translate(mRandomPositions[i]);
{
gl::ScopedMatrices push;
gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
gl::translate(mRandomPositions[i]);
gl::scale(mScales[i]);
//DRAW THE MAIN OBJECT (1ST RENDER PASS) AS NORMAL, FILL THE STENCIL BUFFER
gl::stencilFunc(GL_ALWAYS, 1, 0xFF); //ALL FRAGMENTS MUST UPDATE THE STENCIL BUFFER
gl::stencilMask(0xFF); //ENABLE WRITING TO THE STENCIL BUFFER
mObject->draw();
}
//IF THE STENCIL TEST FAILS, KEEP THE FRAGMENT
//IF STENCIL PASSES AND DEPTH FAILS, KEEP THE FRAGMENT
//IF THE DEPTH TEST AND STENCIL TEST PASS, REPLACE THE FRAGMENT
glStencilOp(GL_KEEP , GL_KEEP, GL_REPLACE);
//2ND RENDER PASS - DRAW OBJECT SLIGHTLY BIGGER, BUT DISABLE STENCIL WRITING. BECAUSE THE STENCIL BUFFER IS FILLED WITH 1s (PARTICULARLY IN THE AREA OF THE ORIGINAL OBJECT), THE ONLY THING THAT WILL BE DRAWN IS THE AREA OF THE 2ND OBJECT, IE. THE SIZE DIFFERENCE
gl::stencilFunc(GL_NOTEQUAL, 1, 0xFF); //don't update the stencil buffer
gl::stencilMask(0x00);
gl::disable(GL_DEPTH_TEST);
{
gl::ScopedMatrices push;
gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
gl::translate(mRandomPositions[i]);
gl::scale(vec3(mScales[i] + vec3(0.1) ));
mBorderObject->draw();
}
}
gl::stencilMask(0xFF);
gl::enable(GL_DEPTH_TEST);
// saveGif();
}
示例3: Color
void Day44App::draw()
{
gl::setMatrices(mCam);
gl::clear( Color( 0.0, 0.0, 0.0 ) );
// gl::rotate(angleAxis(theta, vec3(0.1,1.,0.)));
// gl::rotate(angleAxis(theta, vec3(0.3,0.,0.)));
int counter = 100;
for (vec3 v : mPositions)
{
gl::ScopedMatrices push;
gl::translate(v);
// gl::rotate(counter + theta, vec3(1.,0.,0.));
// gl::rotate(counter + theta, vec3(0.5,0.8,0.));
mBatch->draw();
counter++;
}
// {
// gl::ScopedMatrices push;
// gl::translate(1.5f, 0.f,0.f);
// mBatchB->draw();
// }
{
gl::ScopedMatrices push;
gl::translate(lightPos.x, lightPos.y, lightPos.z);
mLight->draw();
}
if (getElapsedFrames() > 240.f) saveGif();
}
示例4: draw
void EnvironmentTestApp::draw() {
gl::enableDepthRead();
gl::enableDepthWrite();
#ifdef ENABLE_DOF
mDOFFilter->beginRender();
#endif
{
gl::ScopedMatrices mtx;
gl::setMatrices(mCam);
gl::clear(Color::black());
{
gl::ScopedModelMatrix modelMtx;
gl::scale(0.5, 0.5, 0.5);
#ifdef ENABLE_SEM
gl::ScopedTextureBind tex0(mEnvironmentTexture, 0);
gl::ScopedTextureBind tex1(mIlluminationTexture, 1);
#endif
mObjectBatch->draw();
}
gl::ScopedFaceCulling culling(true, GL_FRONT);
gl::ScopedTextureBind environmentTex(mEnvironmentTexture);
mEnvironmentBatch->draw();
}
#ifdef ENABLE_DOF
mDOFFilter->endRender();
mDOFFilter->drawFullscreen();
#endif
#ifdef EXPORT_FRAMES
saveFrame();
#endif
}
示例5: scopedDepth
void ImageBasedLighting_05App::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::setMatrices( mCam );
// enable depth testing
gl::ScopedDepth scopedDepth( true );
// bind the cubemap textures
gl::ScopedTextureBind scopedTexBind0( mTextureRadianceMap, 0 );
gl::ScopedTextureBind scopedTexBind1( mTextureIrradianceMap, 1 );
gl::ScopedTextureBind scopedTexBind2( mNormalMap, 2 );
gl::ScopedTextureBind scopedTexBind3( mRoughnessMap, 3 );
gl::ScopedTextureBind scopedTexBind4( mMetallicMap, 4 );
gl::ScopedTextureBind scopedTexBind5( mColorMap, 5 );
gl::ScopedTextureBind scopedTexBind6( mAOMap, 6 );
gl::ScopedTextureBind scopedTexBind7( mSpecularMap, 7 );
auto shader = mBatchModel->getGlslProg();
shader->uniform( "uRadianceMap", 0 );
shader->uniform( "uIrradianceMap", 1 );
shader->uniform( "uNormalMap", 2 );
shader->uniform( "uRoughnessMap", 3 );
shader->uniform( "uMetallicMap", 4 );
shader->uniform( "uColorMap", 5 );
shader->uniform( "uAOMap", 6 );
shader->uniform( "uSpecularMap", 7);
// sends the base color, the specular opacity,
// the light position, color and radius to the shader
// shader->uniform( "uBaseColor", mBaseColor );
// shader->uniform( "uSpecular", mSpecular );
// shader->uniform( "uNormalMapScale",mNormalMapScale);
// sends the tone-mapping uniforms
shader->uniform( "uExposure", mExposure );
shader->uniform( "uGamma", mGamma );
// render a grid of sphere with different roughness/metallic values and colors
{
// shader->uniform( "uRoughness", mRoughness );
// shader->uniform( "uRoughness4", pow( mRoughness, 4.0f ) );
// shader->uniform( "uMetallic", mMetallic );
mBatchModel->draw();
}
// render skybox
shader = mBatchSkyBox->getGlslProg();
shader->uniform( "uExposure", mExposure );
shader->uniform( "uGamma", mGamma );
mBatchSkyBox->draw();
// DRAW SETTINGS
_params->draw();
}
示例6: drawParticles
void RandomSpawn::drawParticles()
{
mBatch_P->getGlslProg()->uniform("ViewDirection", mCamera.getViewDirection());
mBatch_P->getGlslProg()->uniform("LightPosition", vec3(0, 10, 0));
mBatch_P->getGlslProg()->uniform("SpecPow", 4.0f);
mBatch_P->getGlslProg()->uniform("SpecStr", 2.0f);
mBatch_P->drawInstanced(mPointsParticles.size());
}
示例7: draw
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
}
示例8: loadAsset
void Day72App::setup()
{
mGlsl = gl::GlslProg::create(loadAsset("vertex.vert"), loadAsset("fragment.frag"));
mCamPos = vec3(0,0,4);
mCam.lookAt(mCamPos, vec3(0));
mCam.setPerspective(60.f, getWindowAspectRatio(), 1.f, 1000.f);
mCamUi = CameraUi(&mCam, getWindow());
mSkyBoxTex = gl::TextureCubeMap::create(loadImage(loadAsset("boxy.jpg")));
auto cube = geom::Cube();
mSkyBoxBatch = gl::Batch::create(cube >> geom::Scale(SKY_BOX_SIZE,SKY_BOX_SIZE,SKY_BOX_SIZE), mGlsl);
auto sphere = geom::Sphere().subdivisions(64);
auto c = geom::Cube();
auto torus = geom::Torus().subdivisionsAxis(64).subdivisionsHeight(32);
auto icos = geom::Icosahedron();
mSphere = gl::Batch::create(sphere, mGlsl);
mTorus = gl::Batch::create(torus >> geom::Scale(1.3,1.3,1.3), mGlsl);
mIcos = gl::Batch::create(icos >> geom::Scale(0.8,0.8,0.8), mGlsl);
mCube = gl::Batch::create(c, mGlsl);
//SET THE LOCATION OF THE TEXTURE
mSkyBoxBatch->getGlslProg()->uniform("uCubeMapTex", 0);
mSkyBoxTex->bind();
gl::enableDepth();
}
示例9: draw
void EarthquakeApp::draw()
{
gl::clear( Color( 1, 0, 0 ) );
gl::ScopedDepth depth( true );
gl::ScopedColor color( 1, 1, 1 );
// Draw stars.
if( mShowStars ) {
gl::ScopedTextureBind tex0( mStars, 0 );
gl::ScopedFaceCulling cull( true, GL_FRONT );
mStarSphere->draw();
}
// Draw Earth.
if( mShowEarth ) {
mEarth.draw();
}
// Draw quakes.
if( mShowQuakes ) {
mEarth.drawQuakes();
}
// Draw labels.
if( mShowText ) {
mEarth.drawQuakeLabelsOnSphere( mPov.mEyeNormal, mPov.mDist );
}
if( mSaveFrames ) {
static int currentFrame = 0;
writeImage( getHomeDirectory() / "CinderScreengrabs" / ( "Highoutput_" + toString( currentFrame++ ) + ".png" ), copyWindowSurface() );
}
}
示例10: draw
void InstancedTeapotsApp::draw()
{
gl::clear( Color::black() );
gl::setMatrices( mCam );
mBatch->drawInstanced( NUM_INSTANCES_X * NUM_INSTANCES_Y );
}
示例11: offset
void basic3_batchApp::draw()
{
gl::clear();
gl::enableDepthRead();
gl::enableDepthWrite();
gl::setMatrices(mCam);
int numSpheres = 64;
float maxAngle = M_PI * 7;
float spiralRadius = 1;
float height = 2;
float boxSize = 0.05f;
float anim = getElapsedFrames() / 60.0f;
for (int s = 0; s<numSpheres; ++s) {
float rel = s/(float)numSpheres;
float angle = rel * maxAngle;
float y = fabs(cos(rel*M_PI*anim))*height;
float r = rel * spiralRadius;
vec3 offset(r*cos(angle), y/2, r*sin(angle));
gl::pushModelMatrix();
gl::translate(offset);
gl::scale(vec3(boxSize, y, boxSize));
gl::color(Color(CM_HSV, rel, 1, 1));
mBox->draw();
gl::popModelMatrix();
}
}
示例12: update
void PointCloudApp::update()
{
mCinderRS->update();
mPoints.clear();
Channel16u cChanDepth = mCinderRS->getDepthFrame();
mTexRgb->update(mCinderRS->getRgbFrame());
for (int dy = 0; dy < mDepthDims.y; ++dy)
{
for (int dx = 0; dx < mDepthDims.x; ++dx)
{
float cDepth = (float)*cChanDepth.getData(dx, dy);
if (cDepth > 100 && cDepth < 1000)
{
vec3 cPos = mCinderRS->getDepthSpacePoint(vec3(dx, dy, cDepth));
vec2 cUV = mCinderRS->getColorCoordsFromDepthImage(static_cast<float>(dx),
static_cast<float>(dy),
cDepth);
mPoints.push_back(CloudPoint(cPos, cUV));
}
}
}
mBufferObj->bufferData(mPoints.size()*sizeof(CloudPoint), mPoints.data(), GL_DYNAMIC_DRAW);
mMeshObj = gl::VboMesh::create(mPoints.size(), GL_POINTS, { { mAttribObj, mBufferObj } });
mDrawObj->replaceVboMesh(mMeshObj);
}
示例13: update
void SphericalStereoApp::update()
{
if( mRift ) {
hmd::ScopedRiftBuffer bind{ mRift };
gl::clear();
for( auto eye : mRift->getEyes() ) {
mRift->enableEye( eye );
const auto& pano = mPanos.at( mPanoIndex );
mStereoGlsl->uniform( "uDisplayMode", pano.mDisplayMode );
mStereoGlsl->uniform( "uRightEye", static_cast<int>(eye) );
gl::ScopedTextureBind tex0( pano.mLatLong );
mSphere->draw();
{
auto size = mRift->getFboSize();
gl::ScopedMatrices push;
gl::setMatricesWindow( size.x / 2, size.y );
vec3 latencies = mRift->getLatencies();
stringstream ss;
ss << mPanos.at( mPanoIndex ).mName << std::endl;
ss << " " << std::endl;
ss << "App fps: " << toString( getAverageFps() ) << std::endl;
ss << "Ren: " << latencies.x << std::endl;
ss << "TWrp: " << latencies.y << std::endl;
ss << "PostPresent: " << latencies.z << std::endl;
auto tbox = TextBox().text( ss.str() ).font( Font( "Arial", 20.0f ) ).color( Color::white() ).backgroundColor( Color::black() );
gl::draw( gl::Texture2d::create( tbox.render() ), vec2( size.x / 3, size.y / 2 ) );
}
}
}
}
示例14: Color
void Day48App::draw()
{
gl::setMatrices(mCam);
gl::clear( Color( 0, 0, 0 ) );
gl::color(ColorAf(1.0f,1.f,1.f,1.f));
//gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
for (int i = 0; i < NUM_OBJS; i++)
{
gl::ScopedMatrices push;
gl::translate(mPositions[i]);
mBatch->draw();
}
//COLOUR AND DRAW THE POINT LIGHTS
for (int i = 0; i < mPointLights.size(); i++)
{
switch (i){
case 0:
gl::color(Color(1.,1.,1.));
break;
case 1: //RED
gl::color(Color(1.,0.,0.));
break;
case 2: //BLUE
gl::color(Color(0.,1.,0.));
break;
case 3: //GREEN
gl::color(Color(0.,0.,1.));
break;
}
gl::ScopedMatrices push;
gl::translate(mPointLights[i]);
mLight->draw();
}
}
示例15: draw
void ArcballTestApp::draw()
{
CameraPersp &cam = ( mUsingCameraUi ) ? mDebugCam : mCam;
gl::clear( Color( 0, 0.0f, 0.15f ) );
gl::setMatrices( cam );
// draw the earth
gl::enableDepthRead();
gl::enableDepthWrite();
gl::translate( mEarthSphere.getCenter() );
gl::rotate( mArcball.getQuat() );
mEarthTex->bind();
mEarth->draw();
// draw constraint axis
if( mArcball.isUsingConstraint() ) {
gl::setMatrices( cam );
gl::color( 1, 1, 0 );
gl::translate( mEarthSphere.getCenter() );
gl::rotate( glm::rotation( vec3( 0, 1, 0 ), mArcball.getConstraintAxis() ) );
mConstraintAxis->draw();
}
gl::disableDepthRead();
// draw from vector marker
gl::setMatrices( cam );
gl::color( 0, 1, 0.25f );
gl::translate( mEarthSphere.getCenter() + mArcball.getFromVector() * mEarthSphere.getRadius() );
mMarker->draw();
// draw to vector marker
gl::setMatrices( cam );
gl::color( 1, 0.5f, 0.25f );
gl::translate( mEarthSphere.getCenter() + mArcball.getToVector() * mEarthSphere.getRadius() );
mMarker->draw();
// draw the elliptical axes
gl::setMatricesWindow( getWindowSize() );
gl::color( 1, 0, 0 );
vec2 center, axisA, axisB;
mCam.calcScreenProjection( mEarthSphere, getWindowSize(), ¢er, &axisA, &axisB );
gl::drawLine( center - axisA, center + axisA );
gl::drawLine( center - axisB, center + axisB );
}