本文整理汇总了C++中gl::TextureRef类的典型用法代码示例。如果您正苦于以下问题:C++ TextureRef类的具体用法?C++ TextureRef怎么用?C++ TextureRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normalize
void NormalGetterApp::normalize(gl::TextureRef _tex){
{
gl::ScopedMatrices push;
gl::ScopedFramebuffer fbo(mOutputFbo);
gl::clear();
ci::gl::setMatricesWindow( mOutputFbo->getSize() );
ci::gl::ScopedViewport view( ci::vec2(0), mOutputFbo->getSize() );
gl::ScopedGlslProg mGlsl(mNormalGlsl);
gl::ScopedTextureBind tex0(_tex);
mNormalGlsl->uniform("uSampler", 0);
mNormalGlsl->uniform("u_textureSize", vec2(_tex->getWidth(), _tex->getHeight()));
mNormalGlsl->uniform("bias", bias);
mNormalGlsl->uniform("invertR", float(invertR ? -1.0 : 1.0) );
mNormalGlsl->uniform("invertG", float(invertG ? -1.0 : 1.0));
gl::drawSolidRect(Rectf(vec2(0), _tex->getSize()));
}
if( pushFramesToBuffer){
mPreprocessedImages->pushFront(std::make_pair(mOutputFbo->getColorTexture()->createSource(), currentFrame));
if(currentFrame == mMovie->getNumFrames()){
pushFramesToBuffer = false;
mMovie->setLoop(true);
mMovie->seekToStart();
}
currentFrame++;
}
}
示例2: maskedBlur
void Clone::maskedBlur(gl::TextureRef tex, gl::TextureRef mask, gl::FboRef result)
{
gl::ScopedTextureBind t2(mask, 2);
gl::ScopedGlslProg glsl(mMaskBlurShader);
{
gl::ScopedFramebuffer fbo(mBufferFbo);
gl::clear(ColorA::black(), false);
gl::ScopedTextureBind t1(tex, 1);
mMaskBlurShader->uniform("direction", vec2(1, 0));
gl::drawSolidRect(tex->getBounds());
}
{
gl::ScopedFramebuffer fbo(result);
gl::clear(ColorA::black(), false);
gl::ScopedTextureBind t1(mBufferFbo->getColorTexture(), 1);
mMaskBlurShader->uniform("direction", vec2(0, 1));
gl::drawSolidRect(tex->getBounds());
}
}
示例3: loadMovieFile
void QuickTimeSampleApp::loadMovieFile( const fs::path &moviePath )
{
try {
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieGl::create( moviePath );
mMovie->setLoop();
mMovie->play();
// create a texture for showing some info about the movie
TextLayout infoText;
infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
infoText.setColor( Color::white() );
infoText.addCenteredLine( moviePath.filename().string() );
infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
infoText.setBorder( 4, 2 );
mInfoTexture = gl::Texture::create( infoText.render( true ) );
}
catch( ci::Exception &exc ) {
console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
mMovie.reset();
mInfoTexture.reset();
}
mFrameTexture.reset();
}
示例4: update
void TextParticlesApp::update()
{
if( !mActive )
return;
// Update particles on the GPU
gl::ScopedGlslProg prog( mUpdateProg );
gl::ScopedState rasterizer( GL_RASTERIZER_DISCARD, true ); // turn off fragment stage
mPerlin3dTex->bind(0);
mUpdateProg->uniform( "uPerlinTex", 0 );
mUpdateProg->uniform( "uStep", mStep.value() );
mUpdateProg->uniform( "uDampingSpeed", mDampingSpeed );
mUpdateProg->uniform( "uNoiseOffset", mNoiseOffset );
mUpdateProg->uniform( "uEndColor", mEndColor );
// Bind the source data (Attributes refer to specific buffers).
gl::ScopedVao source( mAttributes[mSourceIndex] );
// Bind destination as buffer base.
gl::bindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, 0, mParticleBuffer[mDestinationIndex] );
gl::beginTransformFeedback( GL_POINTS );
// Draw source into destination, performing our vertex transformations.
gl::drawArrays( GL_POINTS, 0, mTextParticleCount );
gl::endTransformFeedback();
mPerlin3dTex->unbind();
// Swap source and destination for next loop
std::swap( mSourceIndex, mDestinationIndex );
}
示例5: update
void FaceOff::update()
{
#ifdef QUICKTIME_ENABLED
if (MOVIE_MODE)
{
if (!mMovie)
{
fs::path moviePath = getAssetPath(MOVIE_PATH);
try
{
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieSurface::create(moviePath);
mMovie->setLoop();
mMovie->play();
mOfflineFaceTex.reset();
}
catch (ci::Exception &exc)
{
console() << "Exception caught trying to load the movie from path: " << MOVIE_PATH << ", what: " << exc.what() << std::endl;
mMovie.reset();
}
}
else
{
if (mMovie->checkNewFrame())
{
auto surface = mMovie->getSurface();
if (!mOfflineFaceTex)
{
mOfflineFaceTex = gl::Texture2d::create(*surface, gl::Texture::Format().loadTopDown());
}
else
{
mOfflineFaceTex->update(*surface);
}
}
}
}
else
{
mMovie.reset();
mOfflineFaceTex = mPhotoTex;
}
#endif
if (mDeviceId != DEVICE_ID)
{
mDeviceId = DEVICE_ID;
mCapture.setup(CAM_W, CAM_H, mDevices[DEVICE_ID]);
mDoesCaptureNeedsInit = true;
}
if (mCapture.isBackCamera)
mCapture.flip = false;
else
mCapture.flip = CAM_FLIP;
}
示例6: setup
void ciApp::setup()
{
setWindowSize(1280, 720);
setFrameRate(60.f);
int maxVertUniformsVect;
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &maxVertUniformsVect);
mSize = 0;
mSizePrev = -1;
mSizeMax = 17;
mAmplifier = 1.f;
mExposure = 1.f;
mGamma = 2.2f;
printf("max uniform: %i, %i\n", maxVertUniformsVect, mSizeMax);
mParams = params::InterfaceGl::create(getWindow(), "App parameters", ivec2(250, 300));
mParams->setPosition(ivec2(20, 250));
mTexture = gl::Texture::create(loadImage(loadFile(data_path + "demo.png")));
mFbo = gl::Fbo::create(mTexture->getWidth(), mTexture->getHeight(), gl::Fbo::Format().colorTexture());
//mShader.setup("filterGaussianBlur");
filter = hb::GlslFilter::create(mTexture->getSize());
filter->setParams(mParams);
vector_blur.setup(getWindowSize());
vector_blur.setParams(mParams);
spout_receiver = hb::Receiver::create("Spout DX11 Sender");
//spout_receiver = hbSpoutReceiver::create("KidsLandSea");
spout_sender = hb::Sender::create("cinder_spout", mFbo->getWidth(), mFbo->getHeight());
#if 0
auto ctx = audio::Context::master();
// The InputDeviceNode is platform-specific, so you create it using a special method on the Context:
mInputDeviceNode = ctx->createInputDeviceNode();
// By providing an FFT size double that of the window size, we 'zero-pad' the analysis data, which gives
// an increase in resolution of the resulting spectrum data.
auto monitorFormat = audio::MonitorSpectralNode::Format().fftSize(2048).windowSize(1024);
mMonitorSpectralNode = ctx->makeNode(new audio::MonitorSpectralNode(monitorFormat));
mInputDeviceNode >> mMonitorSpectralNode;
// InputDeviceNode (and all InputNode subclasses) need to be enabled()'s to process audio. So does the Context:
mInputDeviceNode->enable();
ctx->enable();
#endif
}
示例7: draw
void QuickTimeSampleApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::enableAlphaBlending();
if( mFrameTexture ) {
Rectf centeredRect = Rectf( mFrameTexture->getBounds() ).getCenteredFit( getWindowBounds(), true );
gl::draw( mFrameTexture, centeredRect );
}
if( mInfoTexture ) {
gl::draw( mInfoTexture, vec2( 20, getWindowHeight() - 20 - mInfoTexture->getHeight() ) );
}
}
示例8: bindShader
void ShaderToyApp::bindShader(gl::GlslProgRef shader)
{
// Nothing to bind if we don't have a shader.
if(!shader) return;
// Bind the shader.
shader->bind();
// Make sure it was successfull by checking for errors.
GLenum err = glGetError();
if(err != GL_NO_ERROR)
fatal("Failed to bind the shader!\n\nYour driver may not properly support shared contexts. Make sure you use the latest driver version and a proper GPU.");
// Calculate shader parameters.
Vec3f iResolution( Vec2f( getWindowSize() ), 1.f );
float iGlobalTime = (float) getElapsedSeconds();
float iChannelTime0 = (float) getElapsedSeconds();
float iChannelTime1 = (float) getElapsedSeconds();
float iChannelTime2 = (float) getElapsedSeconds();
float iChannelTime3 = (float) getElapsedSeconds();
Vec3f iChannelResolution0 = mChannel0 ? Vec3f( mChannel0->getSize(), 1.f ) : Vec3f::one();
Vec3f iChannelResolution1 = mChannel1 ? Vec3f( mChannel1->getSize(), 1.f ) : Vec3f::one();
Vec3f iChannelResolution2 = mChannel2 ? Vec3f( mChannel2->getSize(), 1.f ) : Vec3f::one();
Vec3f iChannelResolution3 = mChannel3 ? Vec3f( mChannel3->getSize(), 1.f ) : Vec3f::one();
time_t now = time(0);
tm* t = gmtime(&now);
Vec4f iDate( float(t->tm_year + 1900),
float(t->tm_mon + 1),
float(t->tm_mday),
float(t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec) );
// Set shader uniforms.
shader->uniform("iResolution", iResolution);
shader->uniform("iGlobalTime", iGlobalTime);
shader->uniform("iChannelTime[0]", iChannelTime0);
shader->uniform("iChannelTime[1]", iChannelTime1);
shader->uniform("iChannelTime[2]", iChannelTime2);
shader->uniform("iChannelTime[3]", iChannelTime3);
shader->uniform("iChannelResolution[0]", iChannelResolution0);
shader->uniform("iChannelResolution[1]", iChannelResolution1);
shader->uniform("iChannelResolution[2]", iChannelResolution2);
shader->uniform("iChannelResolution[3]", iChannelResolution3);
shader->uniform("iMouse", mMouse);
shader->uniform("iChannel0", 0);
shader->uniform("iChannel1", 1);
shader->uniform("iChannel2", 2);
shader->uniform("iChannel3", 3);
shader->uniform("iDate", iDate);
}
示例9: draw
void FlickrTestMTApp::draw()
{
gl::clear( Color( 0.1f, 0.1f, 0.2f ) );
if( mLastTexture ) {
gl::color( 1, 1, 1, 1.0f - mFade );
Rectf textureBounds = mLastTexture->getBounds();
Rectf drawBounds = textureBounds.getCenteredFit( getWindowBounds(), true );
gl::draw( mLastTexture, drawBounds );
}
if( mTexture ) {
gl::color( 1, 1, 1, mFade );
Rectf textureBounds = mTexture->getBounds();
Rectf drawBounds = textureBounds.getCenteredFit( getWindowBounds(), true );
gl::draw( mTexture, drawBounds );
}
}
示例10: draw
void camerasApp::draw()
{
gl::clear( Color( 0, 0.1f, 0.2f ) );
// draw the cube
gl::pushMatrices();
gl::translate( getWindowCenter() );
gl::rotate( mArcball.getQuat() );
if(mTexture) {
mTexture->enableAndBind();
gl::drawCube(Vec3f::zero(), Vec3f(320,320,320));
mTexture->unbind();
}
gl::popMatrices();
}
示例11: draw
void HighDynamicRangeApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::ScopedGlslProg shaderScp( mShader );
gl::ScopedTextureBind texBindScp( mHdrTexture );
mShader->uniform( "uExposure", mExposure );
gl::drawSolidRect( mHdrTexture->getBounds() );
}
示例12: setUniforms
void ShaderToyApp::setUniforms()
{
auto shader = gl::context()->getGlslProg();
if( !shader )
return;
// Calculate shader parameters.
vec3 iResolution( vec2( getWindowSize() ), 1 );
float iGlobalTime = (float)getElapsedSeconds();
float iChannelTime0 = (float)getElapsedSeconds();
float iChannelTime1 = (float)getElapsedSeconds();
float iChannelTime2 = (float)getElapsedSeconds();
float iChannelTime3 = (float)getElapsedSeconds();
vec3 iChannelResolution0 = mChannel0 ? vec3( mChannel0->getSize(), 1 ) : vec3( 1 );
vec3 iChannelResolution1 = mChannel1 ? vec3( mChannel1->getSize(), 1 ) : vec3( 1 );
vec3 iChannelResolution2 = mChannel2 ? vec3( mChannel2->getSize(), 1 ) : vec3( 1 );
vec3 iChannelResolution3 = mChannel3 ? vec3( mChannel3->getSize(), 1 ) : vec3( 1 );
time_t now = time( 0 );
tm* t = gmtime( &now );
vec4 iDate( float( t->tm_year + 1900 ),
float( t->tm_mon + 1 ),
float( t->tm_mday ),
float( t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec ) );
// Set shader uniforms.
shader->uniform( "iResolution", iResolution );
shader->uniform( "iGlobalTime", iGlobalTime );
shader->uniform( "iChannelTime[0]", iChannelTime0 );
shader->uniform( "iChannelTime[1]", iChannelTime1 );
shader->uniform( "iChannelTime[2]", iChannelTime2 );
shader->uniform( "iChannelTime[3]", iChannelTime3 );
shader->uniform( "iChannelResolution[0]", iChannelResolution0 );
shader->uniform( "iChannelResolution[1]", iChannelResolution1 );
shader->uniform( "iChannelResolution[2]", iChannelResolution2 );
shader->uniform( "iChannelResolution[3]", iChannelResolution3 );
shader->uniform( "iMouse", mMouse );
shader->uniform( "iChannel0", 0 );
shader->uniform( "iChannel1", 1 );
shader->uniform( "iChannel2", 2 );
shader->uniform( "iChannel3", 3 );
shader->uniform( "iDate", iDate );
}
示例13: updateMirrors
void InstascopeApp::updateMirrors( vector<TrianglePiece> *vec )
{
if( ! mMirrorTexture )
return;
vec2 mSamplePt1( -0.5, -(sin(M_PI/3)/3) );
vec2 mSamplePt2( mSamplePt1.x + 1, mSamplePt1.y);
vec2 mSamplePt3( mSamplePt1.x + (cos(M_PI/3)), mSamplePt1.y + (sin(M_PI/3)));
mat3 mtrx( 1.0f );
mtrx = glm::translate( mtrx, mSamplePt.value() );
mtrx = glm::scale( mtrx, vec2( mSampleSize ) );
mtrx = glm::rotate( mtrx, float((getElapsedFrames()*4)/2*M_PI) );
mSamplePt1 = vec2( mtrx * vec3( mSamplePt1, 1.0 ) );
mSamplePt2 = vec2( mtrx * vec3( mSamplePt2, 1.0 ) );
mSamplePt3 = vec2( mtrx * vec3( mSamplePt3, 1.0 ) );
mSamplePt1 /= mMirrorTexture->getSize();
mSamplePt2 /= mMirrorTexture->getSize();
mSamplePt3 /= mMirrorTexture->getSize();
// loop through all the pieces and pass along the current texture and it's coordinates
int outCount = 0;
int inCount = 0;
for( int i = 0; i < vec->size(); i++ ) {
(*vec)[i].update( mMirrorTexture, mSamplePt1, mSamplePt2, mSamplePt3 );
if( (*vec)[i].isOut() ) outCount++;
if( (*vec)[i].isIn() ) inCount++;
}
// if all are out, then make a new mirror grid
if( outCount > 0 && outCount == mTriPieces.size() ) {
mirrorOut();
}
// if all the pieces are in
if( inCount > 0 && inCount == mTriPieces.size() && ! mPiecesIn ) {
mPiecesIn = true;
mirrorIn();
}
}
示例14: setup
void AsyncTextureLoadingApp::setup()
{
// Enable alpha blending in case our image supports it.
gl::enableAlphaBlending();
// Load the image in a separated thread and returns the ImageSourceRef
auto asyncLoad = [](DataSourceRef dataSource){
ImageSourceRef imageSource = loadImage( dataSource );
return imageSource;
};
// The second callback is executed in the main thread so any OpenGL resources can be created here.
auto textureCreation = [this](ImageSourceRef imageSource){
mTexture = gl::Texture::create( imageSource );
// It's ok to do that in the main thread:
setWindowSize( mTexture->getWidth(), mTexture->getHeight() );
};
// Use the templated version if you want to pass an object from the loading thread to the main thread. Because we are providing the load function with two callbacks there's no need to specify Options().asynchronous() like we would do with only one callback.
AssetManager::load<ImageSourceRef>( "cinder_logo_alpha.png", asyncLoad, textureCreation );
// The following does exactly the same but is shorter.
/*
AssetManager::load<ImageSourceRef>( "cinder_logo_alpha.png",
// Load the image in a separated thread and returns the ImageSourceRef
[this](DataSourceRef dataSource){
ImageSourceRef imageSource = loadImage( dataSource );
return imageSource;
},
// The second callback is executed in the main thread so any OpenGL resources can be created here.
[this](ImageSourceRef imageSource){
mTexture = gl::Texture::create( imageSource );
} );
*/
}
示例15: draw
void ImageFileBasicApp::draw()
{
gl::clear( Color( 0.5f, 0.5f, 0.5f ) );
gl::enableAlphaBlending();
if( mTexture ) {
Rectf destRect = Rectf( mTexture->getBounds() ).getCenteredFit( getWindowBounds(), true ).scaledCentered( 0.85f );
gl::draw(mTexture, getWindowBounds());
}
m_params->draw();
}