本文整理汇总了C++中ci::gl::Texture类的典型用法代码示例。如果您正苦于以下问题:C++ Texture类的具体用法?C++ Texture怎么用?C++ Texture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Texture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Color
void Fluid2DTextureApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
// Update the positions and tex coords
Rectf drawRect = getWindowBounds();
int limX = mFluid2D.resX() - 1;
int limY = mFluid2D.resY() - 1;
float dx = drawRect.getWidth()/(float)limX;
float dy = drawRect.getHeight()/(float)limY;
for( int j = 0; j < mFluid2D.resY(); ++j ) {
for( int i = 0; i < mFluid2D.resX(); ++i ) {
Vec2f P = Vec2f( i*dx, j*dy );
Vec2f uv = mFluid2D.texCoordAt( i, j );
int idx = j*mFluid2D.resX() + i;
mTriMesh.getVertices()[idx] = P;
mTriMesh.getTexCoords()[idx] = uv;
}
}
mTex.bind();
gl::draw( mTriMesh );
mTex.unbind();
mParams.draw();
}
示例2: drawPumpkin
void Pumpkin::drawPumpkin(const ci::gl::Texture & PumpkinTexture)
{
PumpkinTexture.bind();
ci::gl::translate(mPos);
ci::gl::rotate(ci::Vec3f(180.f, 0.f, 0.f));
ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
PumpkinTexture.unbind();
}
示例3: drawTownwindow
void TownwindowHit::drawTownwindow(const ci::gl::Texture& mTownwindowTexture)
{
mTownwindowTexture.bind();
ci::gl::translate(mPos);
ci::gl::rotate(ci::Vec3f(180.f, 0.f, 0.f));
ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
mTownwindowTexture.unbind();
}
示例4:
void King2::drawKing2(const ci::gl::Texture& texture)
{
texture.bind();
ci::gl::translate(mPos);
ci::gl::rotate(mRotate);
ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
texture.unbind();
}
示例5: onColorData
// Receives Color data
void MeshApp::onColorData( Surface8u surface, const DeviceOptions& deviceOptions )
{
if ( mTextureColor ) {
mTextureColor.update( surface, surface.getBounds() );
} else {
mTextureColor = gl::Texture( surface );
mTextureColor.setWrap( GL_REPEAT, GL_REPEAT );
}
}
示例6: uniformTexture
void Shader::uniformTexture( const std::string &name, ci::gl::Texture tex, int slot )
{
glActiveTexture( GL_TEXTURE0 + slot );
glEnable( tex.getTarget() );
glBindTexture( tex.getTarget(), tex.getId() );
glDisable( tex.getTarget() );
GLint loc = getUniformLocation( name );
glUniform1i( loc, slot );
glActiveTexture( GL_TEXTURE0 );
}
示例7: drawCinderella
void Cinderella::drawCinderella(const ci::gl::Texture & texture, const ci::Vec3f& offset)
{
ci::gl::pushModelView();
texture.bind();
ci::gl::translate(mPos);
ci::gl::rotate(mRotate);
ci::gl::translate(offset);
ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
texture.unbind();
ci::gl::popModelView();
}
示例8: draw
// Render
void MeshApp::draw()
{
// Set up window
gl::clear( ColorAf::black(), true );
gl::setMatrices( mCamera );
gl::color( ColorAf::white() );
// Check texture and VBO
if ( mTextureDepth && mTextureColor && mVboMesh ) {
// Position world
gl::pushMatrices();
gl::scale( -1.0f, -1.0f, -1.0f );
gl::rotate( mRotation );
// Bind textures
mTextureDepth.bind( 0 );
mTextureColor.bind( 1 );
// Bind and configure shader
mShader.bind();
mShader.uniform( "brightTolerance", mBrightTolerance );
mShader.uniform( "eyePoint", mEyePoint );
mShader.uniform( "lightAmbient", mLightAmbient );
mShader.uniform( "lightDiffuse", mLightDiffuse );
mShader.uniform( "lightPosition", mLightPosition );
mShader.uniform( "lightSpecular", mLightSpecular );
mShader.uniform( "positions", 0 );
mShader.uniform( "scale", mScale );
mShader.uniform( "showColor", mShowColor );
mShader.uniform( "shininess", mLightShininess );
mShader.uniform( "Color", 1 );
mShader.uniform( "ColorOffset", Vec2f( mColorOffsetX, mColorOffsetY ) );
mShader.uniform( "uvmix", mMeshUvMix );
// Draw VBO
gl::draw( mVboMesh );
// Stop drawing
mShader.unbind();
mTextureDepth.unbind();
mTextureColor.unbind();
gl::popMatrices();
}
// Draw params
params::InterfaceGl::draw();
}
示例9: init
void SpriteSheet::init(ci::gl::Texture spriteImage, std::string xmlPath, int DataFormat){
__spriteData = SpriteDataParser::parseSpriteData(xmlPath, DataFormat);
__spriteImage = spriteImage;
__currentFrame = 0;
__totalFrames = __spriteData.size();
__textureWidth = spriteImage.getWidth();
__textureHeight = spriteImage.getHeight();
x = 0;
y = 0;
scale = 1.0f;
rotation = 0.0f;
alpha = 1.0f;
}
示例10: unbindTexture
void BulletTestApp::unbindTexture( uint32_t index )
{
if ( mTest > 4 ) {
if ( index == 0 ) {
mTexTerrain.unbind();
} else {
if ( mTest < 7 ) {
mTexSphere.unbind();
}
}
} else {
if ( ( ( mTest == 0 || mTest == 3 ) && index > 0 ) || mTest == 1 ) {
mTexSquare.unbind();
}
}
}
示例11: update
void ClientApp::update()
{
mClient.poll();
mFrameRate = getFrameRate();
if ( mFullScreen != isFullScreen() ) {
setFullScreen( mFullScreen );
}
double e = getElapsedSeconds();
if ( mPing && e - mPingTime > 3.0 ) {
mClient.ping();
mPingTime = e;
}
if ( mTextPrev != mText ) {
mTextPrev = mText;
if ( mText.empty() ) {
mTexture.reset();
} else {
TextBox tbox = TextBox().alignment( TextBox::CENTER ).font( mFont ).size( Vec2i( mSize.x, TextBox::GROW ) ).text( mText );
tbox.setColor( ColorAf( 1.0f, 0.8f, 0.75f, 1.0f ) );
tbox.setBackgroundColor( ColorAf::black() );
tbox.setPremultiplied( false );
mSize.y = tbox.measure().y;
mTexture = gl::Texture( tbox.render() );
}
}
}
示例12: onVideoData
// Receives video data
void SkeletonBitmapApp::onVideoData( Surface8u surface, const DeviceOptions &deviceOptions )
{
if ( mTexture ) {
mTexture.update( surface );
} else {
mTexture = gl::Texture( surface );
}
}
示例13: setup
void BulletTestApp::setup()
{
mDragging = false;
mFrameRate = 0.0f;
mTest = 9;
mTestPrev = mTest;
// Set up lighting
mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() );
mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) );
mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) );
mLight->enable();
// Load meshes
loadModels();
// Create a Bullet dynamics world
mWorld = bullet::createWorld();
// Load texture
mTexSquare = gl::Texture( loadImage( loadResource( RES_TEX_SQUARE ) ) );
mTexSphere = gl::Texture( loadImage( loadResource( RES_TEX_SPHERE ) ) );
mTexTerrain = gl::Texture( loadImage( loadResource( RES_TEX_TERRAIN ) ) );
mTexTerrain.setWrap( GL_REPEAT, GL_REPEAT );
mTexTerrain.unbind();
// Init terrain pointer
mTerrain = 0;
// Parameters
mParams = params::InterfaceGl( "Params", Vec2i( 200, 120 ) );
mParams.addParam( "Frame Rate", &mFrameRate, "", true );
mParams.addParam( "Test", &mTest, "min=0 max=9 step=1 keyDecr=t keyIncr=T" );
mParams.addButton( "Drop", bind( &BulletTestApp::drop, this ), "key=space" );
mParams.addButton( "Screen shot", bind( &BulletTestApp::screenShot, this ), "key=s" );
mParams.addButton( "Quit", bind( &BulletTestApp::quit, this ), "key=q" );
// Initialize
initTest();
// Run first resize to initialize view
resize( ResizeEvent( getWindowSize() ) );
}
示例14: draw
void FloorView::draw()
{
const ci::gl::Texture fbotex = fbo.getTexture();
gl::enableAdditiveBlending();
fbotex.enableAndBind();
//draw fbo with shader
shader->bind();
shader->uniform( "alpha", alpha->value() );
drawQuad();
shader->unbind();
fbotex.unbind();
gl::enableAlphaBlending();
}
示例15: setup
void BulletTestApp::setup()
{
// Set test mode
mTest = 0;
mTestPrev = mTest;
// Set up lighting
mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() );
mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) );
mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) );
mLight->enable();
// Load meshes
loadModels();
// Create a Bullet dynamics world
mWorld = bullet::createWorld();
// Load texture
mTexSquare = gl::Texture( loadImage( loadResource( RES_TEX_SQUARE ) ) );
mTexSphere = gl::Texture( loadImage( loadResource( RES_TEX_SPHERE ) ) );
mTexTerrain = gl::Texture( loadImage( loadResource( RES_TEX_TERRAIN ) ) );
mTexTerrain.setWrap( GL_REPEAT, GL_REPEAT );
mTexTerrain.unbind();
// Init terrain pointer
mTerrain = 0;
// Parameters
mFrameRate = 0.0f;
mParams = params::InterfaceGl( "Params", Vec2i( 150, 100) );
mParams.addParam( "Frame Rate", &mFrameRate, "", true );
mParams.addParam( "Test", &mTest, "min=0 max=7 step=1 keyDecr=d keyIncr=D" );
// Initialize
initTest();
// Run first resize to initialize view
resize( ResizeEvent( getWindowSize() ) );
}