本文整理汇总了C++中ofTexture::unbind方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture::unbind方法的具体用法?C++ ofTexture::unbind怎么用?C++ ofTexture::unbind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofTexture
的用法示例。
在下文中一共展示了ofTexture::unbind方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMask
void ofxSimpleMask::drawMask ( ofTexture contentTex , ofTexture maskTex ,
float xOffset , float yOffset , float contentAlpha , float width , float height )
{
if ( width == 0 ) width = maskArea.width ;
if ( height == 0 ) height = maskArea.height ;
//BEGIN MASK
ofEnableAlphaBlending( ) ;
glActiveTexture(GL_TEXTURE0_ARB);
contentTex.bind();
glActiveTexture(GL_TEXTURE1_ARB);
maskTex.bind();
//prevents weird texture wrapping , otherwise the last or first pixel is repeated to infinity
contentTex.setTextureWrap( GL_CLAMP_TO_BORDER_ARB , GL_CLAMP_TO_BORDER_ARB ) ;
//contentTex.setTextureWrap( GL_CLAMP , GL_CLAMP ) ;
maskShader->begin();
maskShader->setUniformTexture("Tex0", contentTex , 0);
maskShader->setUniformTexture("Tex1", maskTex , 1);
maskShader->setUniform1f( "alpha" , contentAlpha ) ;
glBegin(GL_QUADS);
ofFill() ;
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset , yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, 0 );
glVertex2f( maskArea.x , maskArea.y );
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset + contentTex.getWidth(), yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, maskTex.getWidth(), 0 );
glVertex2f( maskArea.x + width , maskArea.y );
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset + contentTex.getWidth() , contentTex.getHeight() + yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, maskTex.getWidth() , maskTex.getHeight() );
glVertex2f( maskArea.x + width , height + maskArea.y );
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset , contentTex.getHeight() + yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, maskTex.getHeight() );
glVertex2f( maskArea.x , height + maskArea.y ) ;
glEnd();
maskShader->end() ;
//deactive and clean up
glActiveTexture(GL_TEXTURE1_ARB);
maskTex.unbind();
glActiveTexture(GL_TEXTURE0_ARB);
contentTex.unbind();
//maskArea = originalMaskArea ;
}
示例2: ofDrawBitmapCharacterEnd
//---------------------------------------------------------------------
void ofDrawBitmapCharacterEnd(){
if( vC > 0 ){
charMesh.getVertices().resize(vC);
charMesh.getTexCoords().resize(vC);
bitmappedFontTexture.bind();
ofPtr<ofGLProgrammableRenderer> programmableRenderer = ofGetGLProgrammableRenderer();
if (!programmableRenderer){
#ifndef TARGET_OPENGLES
// this temporarily enables alpha testing,
// which discards pixels unless their alpha is 1.0f
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
#endif
}else{
// glPush/PopAttrib is deprecated + we are doing the alpha test through a shader
programmableRenderer->setAlphaBitmapText(true);
}
charMesh.draw();
if (!programmableRenderer){
#ifndef TARGET_OPENGLES
glPopAttrib();
#endif
}else{
programmableRenderer->setAlphaBitmapText(false);
}
bitmappedFontTexture.unbind();
}
}
示例3: roi
// draw texture in fbo using a normalized Region Of Interest
void ftUtil::roi(ofFbo& _dst, ofTexture& _tex, ofRectangle _roi) {
ofMesh quad;
quad.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
quad.addVertex(glm::vec3(0,0,0));
quad.addVertex(glm::vec3(_dst.getWidth(),0,0));
quad.addVertex(glm::vec3(_dst.getWidth(),_dst.getHeight(),0));
quad.addVertex(glm::vec3(0,_dst.getHeight(),0));
float t0x = _roi.x * _tex.getWidth();
float t0y = _roi.y * _tex.getHeight();
float t1x = (_roi.x + _roi.width) * _tex.getWidth();
float t1y = (_roi.y + _roi.height) * _tex.getHeight();
quad.addTexCoord(glm::vec2(t0x, t0y));
quad.addTexCoord(glm::vec2(t1x, t0y));
quad.addTexCoord(glm::vec2(t1x, t1y));
quad.addTexCoord(glm::vec2(t0x, t1y));
_dst.begin();
ofClear(0,0);
_tex.bind();
quad.draw();
_tex.unbind();
_dst.end();
}
示例4: drawScrollingMask
void ofxSimpleMask::drawScrollingMask( ofTexture content , ofTexture mask , float scrolling , float contentAlpha )
{
content.setTextureWrap( GL_CLAMP_TO_BORDER_ARB , GL_CLAMP_TO_BORDER_ARB ) ;
glActiveTexture(GL_TEXTURE0_ARB);
content.bind() ;
glActiveTexture(GL_TEXTURE1_ARB);
mask.bind() ;
//ofTranslate ( 0 , offset.y + 100 , 0 ) ;
//draw a quad the size of the frame
glBegin(GL_QUADS);
ofFill() ;
ofSetColor ( 255 , 255 , 255 , 255 ) ;
int fadeMaskOffset = 0 ;
//move the mask around with the mouse by modifying the texture coordinates
glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, scrolling );
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, 0);
glVertex2f( 0 , fadeMaskOffset );
glMultiTexCoord2d(GL_TEXTURE0_ARB, content.getWidth(), scrolling );
glMultiTexCoord2d(GL_TEXTURE1_ARB, mask.getWidth(), 0 );
glVertex2f( maskArea.width , fadeMaskOffset );
glMultiTexCoord2d(GL_TEXTURE0_ARB, content.getWidth() , mask.getHeight() + scrolling );
glMultiTexCoord2d(GL_TEXTURE1_ARB, mask.getWidth() , mask.getHeight() );
glVertex2f( maskArea.width , maskArea.height + fadeMaskOffset );
glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, mask.getHeight() + scrolling );
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, mask.getHeight() );
glVertex2f( 0 , maskArea.height + fadeMaskOffset ) ;
glEnd();
//deactive and clean up
glActiveTexture(GL_TEXTURE1_ARB);
mask.unbind() ;
glActiveTexture(GL_TEXTURE0_ARB);
content.unbind() ;
}
示例5: drawBasicRibbon
void dpMarionette::drawBasicRibbon(ofTexture &tex,
const ramNode &nodeA,const ramNode &nodeB,
float width, int resolution,
int A_Axis, int B_Axis,
bool wired,int beginOffset, int endOffset,
ofVec3f beginOffset3v,ofVec3f endOffset3v){
ofNode parent[2];
parent[0] = nodeA;
parent[1] = nodeB;
ofNode child[4];
child[0].setParent(parent[0]);
child[1].setParent(parent[0]);
child[2].setParent(parent[1]);
child[3].setParent(parent[1]);
ofVec3f aPos,bPos;
if (A_Axis == DPM_AXIS_X) aPos.set(width/2.0, beginOffset, 0.0);
if (A_Axis == DPM_AXIS_Y) aPos.set(0.0, width/2.0, 0.0);
if (A_Axis == DPM_AXIS_Z) aPos.set(0.0, beginOffset, width/2.0);
if (B_Axis == DPM_AXIS_X) bPos.set(width/2.0, endOffset, 0.0);
if (B_Axis == DPM_AXIS_Y) bPos.set(0.0, width/2.0, 0.0);
if (B_Axis == DPM_AXIS_Z) bPos.set(0.0, endOffset, width/2.0);
child[0].setPosition(aPos.x * -1, aPos.y, aPos.z * -1);
child[1].setPosition(aPos);
child[2].setPosition(bPos.x * -1, bPos.y, bPos.z * -1);
child[3].setPosition(bPos);
child[0].setPosition(child[0].getPosition() + beginOffset3v);
child[1].setPosition(child[1].getPosition() + beginOffset3v);
child[2].setPosition(child[2].getPosition() + endOffset3v);
child[3].setPosition(child[3].getPosition() + endOffset3v);
ofVec2f texSize = ofVec2f(tex.getWidth(),tex.getHeight());
ofVec3f targA,targB;
float sliceP;
tex.bind();
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0;i < resolution + 1;i++){
sliceP = i/float(resolution);
targA = child[0].getGlobalPosition().interpolated(child[2].getGlobalPosition(),
sliceP);
targB = child[1].getGlobalPosition().interpolated(child[3].getGlobalPosition(),
sliceP);
glTexCoord2d(0.0, texSize.y * sliceP);
glVertex3d(targA.x, targA.y, targA.z);
glTexCoord2d(texSize.x, texSize.y * sliceP);
glVertex3d(targB.x, targB.y, targB.z);
}
glEnd();
tex.unbind();
}
示例6: ofDrawBitmapCharacterEnd
//---------------------------------------------------------------------
void ofDrawBitmapCharacterEnd() {
if( vC > 0 ) {
glTexCoordPointer(2, GL_FLOAT, 0, &coords[0] );
glVertexPointer(2, GL_FLOAT, 0, &verts[0] );
glDrawArrays(GL_TRIANGLES, 0, vC/2 );
}
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
#ifndef TARGET_OPENGLES
glPopAttrib();
#endif
glesBitmappedFontTexture.unbind();
}
示例7: loadTexture
bool loadTexture(ofTexture & tex, const std::string & path, bool mipmap, float bias, int anisotropy){
bool ok = ofLoadImage(tex, path);
if (ok){
tex.generateMipmap();
tex.enableMipmap();
tex.setTextureMinMagFilter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
tex.bind();
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, bias);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); //TODO check for hw support!
tex.unbind();
ofLogError("ofxApp") << "Failed to load texture at \"" << path << "\"";
}else{
ofLogError("ofxApp") << "Failed to load texture at \"" << path << "\"";
}
return ok;
}
示例8: pbDrawRects
//--------------------------------------------------------------
void pbDrawRects( vector<ofPoint> &points, vector<ofVec2f> &texs, ofTexture &texture )
{
if ( points.empty() ) { return; }
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer( 3, GL_FLOAT, sizeof( ofPoint ), &points[0].x);
glTexCoordPointer( 2, GL_FLOAT, sizeof( ofVec2f ), &texs[0].x );
texture.bind();
glDrawArrays(GL_QUADS, 0, points.size());
texture.unbind();
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
示例9: drawShoulderPoint
void dpMarionette::drawShoulderPoint(ofTexture &tex,
const ramNode &nodeA,
const ramNode &nodeB,
const ramNode &nodeC,int width, int resolution){
//A is NECK!
ofNode parent[3];
parent[0] = nodeA;
parent[1] = nodeB;
parent[2] = nodeC;
ofNode child[4];
child[0].setParent(parent[0]);
child[1].setParent(parent[0]);
child[2].setParent(parent[1]);
child[3].setParent(parent[2]);
child[0].setPosition( width/2.0, 0.0, 0.0);
child[1].setPosition(-width/2.0, 0.0, 0.0);
child[2].setPosition( 12.0, 0.0, 0.0);
child[3].setPosition(-12.0, 0.0, 0.0);
ofVec2f texSize = ofVec2f(tex.getWidth(),tex.getHeight());
ofVec3f targA,targB;
float sliceP;
tex.bind();
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0;i < resolution + 1;i++){
sliceP = i/float(resolution);
targA = child[0].getGlobalPosition().interpolated(child[2].getGlobalPosition(),
sliceP);
targB = child[1].getGlobalPosition().interpolated(child[3].getGlobalPosition(),
sliceP);
glTexCoord2d(0.0, texSize.y * sliceP);
glVertex3d(targA.x, targA.y, targA.z);
glTexCoord2d(texSize.x, texSize.y * sliceP);
glVertex3d(targB.x, targB.y, targB.z);
}
glEnd();
tex.unbind();
}
示例10: fit
// draw texture in fbo using aspectratio of texture, showing the complete texture, but not filling the fbo
void ftUtil::fit(ofFbo& _dst, ofTexture& _tex) {
float meRatio = float(_dst.getWidth()) / float(_dst.getHeight()); // 0.5625
float texRatio = float(_tex.getWidth()) / float(_tex.getHeight()); // 1.3333
float width, height;
float x0, y0, x1, y1;
if (meRatio > texRatio) {
height = _dst.getHeight();
width = height * texRatio;
}
else {
width = _dst.getWidth();
height = width / texRatio;
}
x0 = (_dst.getWidth() - width) / 2;
x1 = x0 + width;
y0 = (_dst.getHeight() - height) / 2;
y1 = y0 + height;
ofMesh quad;
quad.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
quad.addVertex(glm::vec3(x0,y0,0));
quad.addVertex(glm::vec3(x1,y0,0));
quad.addVertex(glm::vec3(x1,y1,0));
quad.addVertex(glm::vec3(x0,y1,0));
quad.addTexCoord(glm::vec2(0,0));
quad.addTexCoord(glm::vec2(_tex.getWidth(),0));
quad.addTexCoord(glm::vec2(_tex.getWidth(),_tex.getHeight()));
quad.addTexCoord(glm::vec2(0,_tex.getHeight()));
_dst.begin();
ofClear(0,0);
_tex.bind();
quad.draw();
_tex.unbind();
_dst.end();
}
示例11: ofDrawTriangles
void ofDrawTriangles(const ArrayBridge<ofShapeTriangle2>& Triangles,ofTexture& Texture,const ArrayBridge<ofShapeTriangle2>& TexCoords)
{
Texture.bind();
for ( int t=0; t<Triangles.GetSize(); t++ )
{
auto& Triangle = Triangles[t];
auto& TexCoord = TexCoords[t];
auto& v0 = Triangle.mTriangle[0];
auto& v1 = Triangle.mTriangle[1];
auto& v2 = Triangle.mTriangle[2];
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer( 2, GL_FLOAT, sizeof(ofVec2f), &TexCoord );
ofTriangle( v0.x, v0.y, v1.x, v1.y, v2.x, v2.y );
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
Texture.unbind();
}
示例12: updateTexture
void updateTexture(ofTexture & videoFrame){
if(!fbo.isAllocated()){
fbo.allocate(videoFrame.getWidth(),videoFrame.getHeight(),videoFrame.texData.glInternalFormat);
}
fbo.begin();
videoFrame.bind();
ofMesh mesh;
mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
mesh.addTexCoord(ofVec2f(0,0));
mesh.addTexCoord(ofVec2f(videoFrame.getWidth(),0));
mesh.addTexCoord(ofVec2f(videoFrame.getWidth(),videoFrame.getHeight()));
mesh.addTexCoord(ofVec2f(0,videoFrame.getHeight()));
mesh.addVertex(ofVec3f(0,0));
mesh.addVertex(ofVec3f(videoFrame.getWidth(),0));
mesh.addVertex(ofVec3f(videoFrame.getWidth(),videoFrame.getHeight()));
mesh.addVertex(ofVec3f(0,videoFrame.getHeight()));
mesh.draw();
videoFrame.unbind();
fbo.end();
}
示例13: drawElbowPoint
void dpMarionette::drawElbowPoint(ofTexture &tex, const ramNode &nodeA, const ramNode &nodeB, const ramNode &nodeC, int width, int resolution, bool isLEFT){
ofNode parent[3];
parent[0] = nodeA;
parent[1] = nodeB;
parent[2] = nodeC;
ofNode subParent[2];
subParent[0].setParent(parent[1]);
subParent[1].setParent(parent[2]);
if (isLEFT){
subParent[0].setPosition(-12.0, 0.0, 0.0);
subParent[1].setPosition( 12.0, 0.0, 0.0);
}else{
subParent[0].setPosition( 12.0, 0.0, 0.0);
subParent[1].setPosition(-12.0, 0.0, 0.0);
}
ofNode child[4];
child[0].setParent(parent[0]);
child[1].setParent(parent[0]);
if (isLEFT){
child[2].setGlobalPosition(subParent[1].getGlobalPosition().
interpolate(subParent[0].getGlobalPosition(), 0.0));
child[3].setGlobalPosition(subParent[1].getGlobalPosition().
interpolate(subParent[0].getGlobalPosition(), 0.2));
}else{
child[2].setGlobalPosition(subParent[1].getGlobalPosition().
interpolate(subParent[0].getGlobalPosition(), 0.2));
child[3].setGlobalPosition(subParent[1].getGlobalPosition().
interpolate(subParent[0].getGlobalPosition(), 0.0));
}
child[0].setPosition( width/2.0, 0.0, 0.0);
child[1].setPosition(-width/2.0, 0.0, 0.0);
ofVec2f texSize = ofVec2f(tex.getWidth(),tex.getHeight());
ofVec3f targA,targB;
float sliceP;
tex.bind();
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0;i < resolution + 1;i++){
sliceP = i/float(resolution);
targA = child[0].getGlobalPosition().interpolated(child[2].getGlobalPosition(),
sliceP);
targB = child[1].getGlobalPosition().interpolated(child[3].getGlobalPosition(),
sliceP);
glTexCoord2d(0.0, texSize.y * (1.0 - sliceP));
glVertex3d(targA.x, targA.y, targA.z);
glTexCoord2d(texSize.x, texSize.y * (1.0 - sliceP));
glVertex3d(targB.x, targB.y, targB.z);
}
glEnd();
tex.unbind();
ofVec3f guideA = subParent[0].getGlobalPosition().interpolate(subParent[1].getGlobalPosition(),
5.0);
ofVec3f guideB = subParent[1].getGlobalPosition().interpolate(subParent[0].getGlobalPosition(),
5.0);
}
示例14: drawMask
void EasyMask::drawMask ( ofTexture contentTex , ofTexture maskTex , float xOffset , float yOffset , float contentAlpha )
{
/*
if ( contentTex.getWidth() < maskArea.width )
maskArea.width = contentTex.getWidth() ;
if ( contentTex.getHeight() < maskArea.height )
maskArea.height = contentTex.getHeight() ;
*/
//TEX0 = CONTENT
//TEX1 = M
//BEGIN MASK
ofEnableAlphaBlending( ) ;
//ofSetColor ( 255 , 255 , 255 ) ;
// contentTex.setTextureWrap( GL_CLAMP, GL_CLAMP ) ;
glActiveTexture(GL_TEXTURE0_ARB);
contentTex.bind();
glActiveTexture(GL_TEXTURE1_ARB);
maskTex.bind();
//prevents weird texture wrapping
// contentTex.setTextureWrap( GL_CLAMP_TO_BORDER_ARB, GL_CLAMP_TO_BORDER_ARB ) ;
contentTex.setTextureWrap( GL_CLAMP_TO_BORDER_ARB , GL_CLAMP_TO_BORDER_ARB ) ;
// texture1.setTextureWrap( GL_CLAMP , GL_CLAMP ) ;
//xOffset = sin ( ofGetElapsedTimef() ) * 500.0f ;
maskShader.begin();
maskShader.setUniformTexture("Tex0", contentTex , 0);
maskShader.setUniformTexture("Tex1", maskTex , 1);
maskShader.setUniform1f( "alpha" , contentAlpha ) ;
glBegin(GL_QUADS);
ofFill() ;
// ofSetColor ( 255 , 255 , 255 , 255 ) ;
// maskOffset = 0 ; //sin ( ofGetElapsedTimef() ) * 200.0f ;
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset , yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, contentAlpha );
glVertex2f( maskArea.x , maskArea.y );
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset + contentTex.getWidth(), yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, maskTex.getWidth(), 0 );
glVertex2f( maskArea.x + maskArea.width , maskArea.y );
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset + contentTex.getWidth() , contentTex.getHeight() + yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, maskTex.getWidth() , maskTex.getHeight() );
glVertex2f( maskArea.x + maskArea.width , maskArea.height + maskArea.y );
glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset , contentTex.getHeight() + yOffset );
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, maskTex.getHeight() );
glVertex2f( maskArea.x , maskArea.height + maskArea.y ) ;
glEnd();
maskShader.end() ;
//deactive and clean up
glActiveTexture(GL_TEXTURE1_ARB);
maskTex.unbind();
glActiveTexture(GL_TEXTURE0_ARB);
contentTex.unbind();
//maskArea = originalMaskArea ;
}