本文整理汇总了C++中gl::GlslProg::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ GlslProg::bind方法的具体用法?C++ GlslProg::bind怎么用?C++ GlslProg::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl::GlslProg
的用法示例。
在下文中一共展示了GlslProg::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawIntoPositionFbo
void RepulsionApp::drawIntoPositionFbo()
{
gl::setMatricesWindow( mFboSize, false );
gl::setViewport( mFboBounds );
mPositionFbos[ mThisFbo ].bindFramebuffer();
mPositionFbos[ mPrevFbo ].bindTexture( 0, 0 );
mPositionFbos[ mPrevFbo ].bindTexture( 1, 1 );
mVelocityFbos[ mThisFbo ].bindTexture( 2, 0 );
mVelocityFbos[ mThisFbo ].bindTexture( 3, 1 );
mPositionShader.bind();
mPositionShader.uniform( "pos0Tex", 0 );
mPositionShader.uniform( "pos1Tex", 1 );
mPositionShader.uniform( "vel0Tex", 2 );
mPositionShader.uniform( "vel1Tex", 3 );
mPositionShader.uniform( "dt", mRoom.getTimeDelta() );
gl::drawSolidRect( mFboBounds );
mPositionShader.unbind();
mPositionFbos[ mThisFbo ].unbindFramebuffer();
}
示例2: update
void gpuPSApp::update()
{
if (mStep) {
computeAttractorPosition();
gl::setMatricesWindow( mSwapFbo.getSize(), false ); // false to prevent vertical flipping
gl::setViewport( mSwapFbo.getBounds() );
mSwapFbo.updateBind();
mParticlesShader.bind();
mParticlesShader.uniform( "positions", 0 );
mParticlesShader.uniform( "velocities", 1 );
mParticlesShader.uniform( "attractorPos", mAttractor);
gl::drawSolidRect(mSwapFbo.getBounds());
mParticlesShader.unbind();
mSwapFbo.updateUnbind();
mSwapFbo.swap();
}
}
示例3: draw
void ScreenShadersApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
// bind the Fbo
mFbo.bindFramebuffer();
// match the viewport to the Fbo dimensions
gl::setViewport( mFbo.getBounds() );
// setup an ortho projection
gl::setMatricesWindow( mFbo.getWidth(), mFbo.getHeight() );
// clear the Fbo
gl::clear( Color( 0, 0, 0 ) );
if ( mTexture ) {
gl::draw( mTexture );
}
// unbind the Fbo
mFbo.unbindFramebuffer();
gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
float kernelRes = 21.0f;
mBlurShader.bind();
mBlurShader.uniform( "kernelRes", kernelRes );
mBlurShader.uniform( "invKernelRes", 1.0f / kernelRes );
mBlurShader.uniform( "fboTex", 0 );
mBlurShader.uniform( "kernelTex", 1 );
mBlurShader.uniform( "orientationVector", Vec2f( 1.0f, 1.0f ) );
mBlurShader.uniform( "blurAmt", 1.0f );
mBlurShader.uniform( "colMulti", 1.0f );
mBlurKernel.bind( 1 );
gl::draw( mFbo.getTexture(0), Rectf( 0, getWindowHeight(), getWindowWidth(), 0 ) );
mBlurShader.unbind();
}
示例4: renderNormalMap
void SmoothDisplacementMappingApp::renderNormalMap()
{
if( mNormalMapShader && mNormalMapFbo )
{
mNormalMapFbo.bindFramebuffer();
{
// setup viewport and matrices
glPushAttrib( GL_VIEWPORT_BIT );
gl::setViewport( mNormalMapFbo.getBounds() );
gl::pushMatrices();
gl::setMatricesWindow( mNormalMapFbo.getSize(), false );
// clear the color buffer
gl::clear();
// bind the displacement map
mDispMapFbo.getTexture().bind(0);
// render the normal map
mNormalMapShader.bind();
mNormalMapShader.uniform( "texture", 0 );
mNormalMapShader.uniform( "amplitude", 4.0f );
Area bounds = mNormalMapFbo.getBounds(); //bounds.expand(-1, -1);
gl::drawSolidRect( bounds );
mNormalMapShader.unbind();
// clean up after ourselves
mDispMapFbo.getTexture().unbind();
gl::popMatrices();
glPopAttrib();
}
mNormalMapFbo.unbindFramebuffer();
}
}
示例5: draw
void gpuPSApp::draw()
{
gl::setMatrices( mCam );
gl::setViewport( getWindowBounds() );
gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 1.0f ) );
mFBO[mCurrentFBO].bindTexture(0,0);
mDisplShader.bind();
mDisplShader.uniform("displacementMap", 0 );
gl::pushModelView();
gl::translate( Vec3f( 0.0f, 0.0f, getWindowHeight() / 2.0f ) );
gl::rotate( mArcball.getQuat() );
gl::draw( mVboMesh );
gl::popModelView();
mDisplShader.unbind();
mFBO[mCurrentFBO].unbindTexture();
gl::setMatricesWindow(getWindowSize());
gl::drawString( toString( SIDE*SIDE ) + " vertices", Vec2f(32.0f, 32.0f));
gl::drawString( toString((int) getAverageFps()) + " fps", Vec2f(32.0f, 52.0f));
}
示例6: draw
void ___PACKAGENAMEASIDENTIFIER___App::draw()
{
// clear out the window with black
gl::clear( kClearColor );
if( !mTexture ) return;
mFbo.bindFramebuffer();
mTexture.enableAndBind();
mShader.bind();
mShader.uniform( "tex", 0 );
mShader.uniform( "mixColor", Vec3d( mMixColorRed, mMixColorGreen, mMixColorBlue ) );
gl::drawSolidRect( getWindowBounds() );
mTexture.unbind();
mShader.unbind();
mFbo.unbindFramebuffer();
gl::Texture fboTexture = mFbo.getTexture();
fboTexture.setFlipped();
gl::draw( fboTexture );
params::InterfaceGl::draw();
}
示例7: update
void RDiffusionApp::update()
{
const int ITERATIONS = 25;
// normally setMatricesWindow flips the projection vertically so that the upper left corner is 0,0
// but we don't want to do that when we are rendering the FBOs onto each other, so the last param is false
gl::setMatricesWindow( mFBOs[0].getSize(), false );
gl::setViewport( mFBOs[0].getBounds() );
for( int i = 0; i < ITERATIONS; i++ ) {
mCurrentFBO = ( mCurrentFBO + 1 ) % 2;
mOtherFBO = ( mCurrentFBO + 1 ) % 2;
mFBOs[ mCurrentFBO ].bindFramebuffer();
mFBOs[ mOtherFBO ].bindTexture();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
mShader.bind();
mShader.uniform( "texture", 0 );
mShader.uniform( "srcTexture", 1 );
mShader.uniform( "width", (float)FBO_WIDTH );
mShader.uniform( "ru", mReactionU );
mShader.uniform( "rv", mReactionV );
mShader.uniform( "k", mReactionK );
mShader.uniform( "f", mReactionF );
gl::drawSolidRect( mFBOs[ mCurrentFBO ].getBounds() );
mShader.unbind();
if( mMousePressed ){
glColor3f( 1.0f, 1.0f, 1.0f );
RectMapping windowToFBO( getWindowBounds(), mFBOs[mCurrentFBO].getBounds() );
gl::drawSolidCircle( windowToFBO.map( mMouse ), 50.0f, 32 );
}
mFBOs[ mCurrentFBO ].unbindFramebuffer();
}
}
示例8: renderVideo
void KinectEcard::renderVideo(){
if( !mVideoSurface )
return;
gl::pushMatrices();
{
//
mVideoFbo.bindFramebuffer();
// clear FBO
gl::clear( Color::black() );
gl::color( Color::white() );
//
gl::Texture tex0( mVideoSurface );
gl::Texture tex1( mCorrectionMap );
mDepthCorrectionShader.bind();
mDepthCorrectionShader.uniform( "tex0", 0 );
mDepthCorrectionShader.uniform( "tex1", 1 );
tex0.bind(0);
tex1.bind(1);
gl::setMatricesWindowPersp( mVideoFbo.getSize() );
// draw video surface
gl::drawSolidRect( mVideoFbo.getBounds() );
//gl::draw( mCorrectionMap );
mDepthCorrectionShader.unbind();
mVideoFbo.unbindFramebuffer();
}
gl::popMatrices();
}
示例9: draw
void SimpleExampleApp::draw()
{
gl::setMatrices( mCam );
gl::clear( Color( 0, 0, 0 ) );
gl::disableAlphaBlending();
if( mTriMesh.getNumTriangles() ) {
gl::pushMatrices();
mShader.bind();
mShader.uniform( "eyeDir", mCam.getViewDirection().normalized() );
gl::draw( mTriMesh );
mShader.unbind();
gl::popMatrices();
}
gl::enableAlphaBlending();
// Simple FPS display
gl::setMatricesWindow( getWindowSize() );
gl::drawString( toString( getAverageFps() ) + " fps", Vec2i( 5, 5 ), ColorA( 1, 1, 1, 0.5f ), Font( "Arial", 18 ) );
}
示例10: draw
void KaleidoscopeApp::draw()
{
gl::clear();
gl::setViewport( getWindowBounds() );
gl::setMatricesWindow( getWindowSize() );
if ( mShader )
{
mShader.bind();
mShader.uniform( "center", mCenter );
mShader.uniform( "numReflectionLines", mNumReflectionLines );
mShader.uniform( "rotation", mRotation );
mShader.uniform( "txt", 0 );
}
if ( mTexture )
gl::draw( mTexture, getWindowBounds() );
if ( mShader )
mShader.unbind();
mParams.draw();
}
示例11: draw
void TextRenderingApp::draw()
{
// note: when drawing text to an FBO,
// make sure to enable maximum quality multisampling (16x is best)!
// clear out the window
gl::clear( mBackColor );
// draw text box centered inside the window
Area fit = Area::proportionalFit( Area(Vec2i::zero(), mTextBox.getSize()), getWindowBounds(), true, false );
gl::color( mFrontColor );
gl::enableAlphaBlending();
gl::pushModelView();
gl::translate( fit.getUL() );
// bind shader
if(mSdfShader) {
mSdfShader.bind();
mSdfShader.uniform("tex0", 0);
}
mTextBox.draw();
// unbind shader
if(mSdfShader) mSdfShader.unbind();
if(mShowWireframe) mTextBox.drawWireframe();
gl::popModelView();
gl::disableAlphaBlending();
if(mShowBounds)
mTextBox.drawBounds( fit.getUL() );
}
示例12: setFboPositions
void RepulsionApp::setFboPositions( gl::Fbo &fbo )
{
Surface32f pos( fbo.getTexture() );
Surface32f::Iter it = pos.getIter();
while( it.line() ){
while( it.pixel() ){
Vec3f r = mRoom.getRandRoomPos();
float mass = Rand::randFloat( 20.0f, 30.0f );
if( Rand::randFloat() < 0.05f )
mass = Rand::randFloat( 50.0f, 60.0f );
if( it.y() < 5 && it.x() < 50 )
mass = Rand::randFloat( 300.0f, 5000.0f );
else
mass = Rand::randFloat( 50.0f, 300.0f );
it.r() = r.x;
it.g() = r.y;
it.b() = r.z;
it.a() = 100.0f;
}
}
gl::Texture posTexture( pos );
posTexture.bind();
gl::setMatricesWindow( mFboSize, false );
gl::setViewport( mFboBounds );
fbo.bindFramebuffer();
mPosInitShader.bind();
mPosInitShader.uniform( "initTex", 0 );
gl::drawSolidRect( mFboBounds );
mPosInitShader.unbind();
fbo.unbindFramebuffer();
}
示例13: draw
void ObjLoaderApp::draw()
{
gl::enableDepthWrite();
gl::enableDepthRead();
gl::clear( Color( 0.0f, 0.1f, 0.2f ) );
glDisable( GL_CULL_FACE );
gl::setMatrices( mMayaCam.getCamera() );
/* Sphere boundingSphere = Sphere::calculateBoundingSphere( mMesh.getVertices() );
glColor3f( 1.0f, 1.0f, 1.0f );
gl::disableDepthWrite();
mTexture->disable();
mShader.unbind();
gl::draw( boundingSphere, 30 );
gl::enableDepthWrite();
*/
mShader.bind();
gl::pushMatrices();
gl::rotate( mArcball.getQuat() );
gl::draw( mVBO );
gl::popMatrices();
}
示例14: renderSubstractedVideo
void KinectEcard::renderSubstractedVideo(){
mSubstractedVideoFbo.bindFramebuffer();
gl::pushMatrices();
{
// clear FBO
gl::clear( Color::black() );
gl::color( Color::white() );
//
gl::setMatricesWindowPersp( mSubstractedVideoFbo.getSize() );
mSubstractShader.bind();
mSubstractShader.uniform( "tex0", 0 );
mSubstractShader.uniform( "tex1", 1 );
mSubstractShader.uniform( "tex2", 2 );
mSubstractShader.uniform( "tex3", 3 );
mVideoFbo.bindTexture(0);
mDepthFbo.bindTexture(1);
mStoredVideoFbo.bindTexture(2);
mStoredDepthFbo.bindTexture(3);
gl::drawSolidRect( mSubstractedVideoFbo.getBounds() );
mVideoFbo.unbindTexture();
mDepthFbo.unbindTexture();
mStoredVideoFbo.unbindTexture();
mStoredDepthFbo.unbindTexture();
mSubstractShader.unbind();
}
gl::popMatrices();
mSubstractedVideoFbo.unbindFramebuffer();
}
示例15: render
void StereoscopicRenderingApp::render()
{
float seconds = (float) getElapsedSeconds();
// enable 3D rendering
gl::enableDepthRead();
gl::enableDepthWrite();
// set 3D camera matrices
gl::pushMatrices();
gl::setMatrices( mCamera );
if( mShaderPhong && mMeshTrombone && mMeshNote ) {
// enable phong shading
mShaderPhong.bind();
// draw trombone
gl::pushModelView();
{
gl::color( Color(0.7f, 0.6f, 0.0f) );
gl::rotate( Vec3f::yAxis() * 10.0f * seconds );
gl::draw( mMeshTrombone );
// reflection
gl::scale( 1.0f, -1.0f, 1.0f );
gl::draw( mMeshTrombone );
}
gl::popModelView();
// draw animated notes
Rand rnd;
for(int i=-100; i<=100; ++i) {
rnd.seed(i);
float t = rnd.nextFloat() * 200.0f + 2.0f * seconds;
float r = rnd.nextFloat() * 360.0f + 60.0f * seconds;
float z = fmodf( 5.0f * t, 200.0f ) - 100.0f;
gl::pushModelView();
{
gl::color( Color( CM_HSV, rnd.nextFloat(), 1.0f, 1.0f ) );
gl::pushModelView();
gl::translate( i * 0.5f, 0.15f + 1.0f * math<float>::abs( sinf(3.0f * t) ), -z );
gl::rotate( Vec3f::yAxis() * r );
gl::draw( mMeshNote );
gl::popModelView();
// reflection
gl::pushModelView();
gl::scale( 1.0f, -1.0f, 1.0f );
gl::translate( i * 0.5f, 0.15f + 1.0f * math<float>::abs( sinf(3.0f * t) ), -z );
gl::rotate( Vec3f::yAxis() * r );
gl::draw( mMeshNote );
gl::popModelView();
}
gl::popModelView();
}
mShaderPhong.unbind();
}
// draw grid
gl::color( Color(0.8f, 0.8f, 0.8f) );
for(int i=-100; i<=100; ++i) {
gl::drawLine( Vec3f((float) i, 0, -100), Vec3f((float) i, 0, 100) );
gl::drawLine( Vec3f(-100, 0, (float) i), Vec3f(100, 0, (float) i) );
}
// draw floor
gl::enableAlphaBlending();
gl::color( ColorA(1,1,1,0.75f) );
gl::drawCube( Vec3f(0.0f, -0.5f, 0.0f), Vec3f(200.0f, 1.0f, 200.0f) );
gl::disableAlphaBlending();
// restore 2D rendering
gl::popMatrices();
gl::disableDepthWrite();
gl::disableDepthRead();
// render UI
if( mDrawUI ) renderUI();
}