当前位置: 首页>>代码示例>>C++>>正文


C++ ofTexture::getWidth方法代码示例

本文整理汇总了C++中ofTexture::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture::getWidth方法的具体用法?C++ ofTexture::getWidth怎么用?C++ ofTexture::getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofTexture的用法示例。


在下文中一共展示了ofTexture::getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: publishTexture

	void Output::publishTexture(ofTexture &tex)
	{
		assert(mutex);

		if (tex.getWidth() == uiFrameWidth
			&& tex.getHeight() == uiFrameHeight)
		{
			ofPixels pix2;
			tex.readToPixels(pix2);

			mutex->lock();
			if (!back_buffer->isAllocated() ||
				back_buffer->getWidth() != tex.getWidth() ||
				back_buffer->getHeight() != tex.getHeight()) {
				back_buffer->allocate(tex.getWidth(), tex.getHeight(), pix2.getNumChannels());
			}
			memcpy(&back_buffer->getData()[1], pix2.getData(), pix2.size() - 1);

			if (back_buffer->getNumChannels() != 4)
				back_buffer->setNumChannels(4);

			has_new_frame = true;

			mutex->unlock();
		}
		else
			ofLogError("ofxDeckLinkAPI::Output") << "invalid texture size";
	}
开发者ID:elliotwoods,项目名称:ofxBlackmagic2,代码行数:28,代码来源:Output.cpp

示例2: 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();
	}
开发者ID:bossacorp,项目名称:ofxFlowTools,代码行数:28,代码来源:ftUtil.cpp

示例3: send

	//----------
	bool Sender::send(const ofTexture & texture, bool flipY) {
		try {
			if (!this->isInitialized()) {
				throw("Not initialised");
			}

			//check if the sender matches the settings of the texture
			if (this->width != texture.getWidth() || this->height != texture.getHeight()) {
				this->width = texture.getWidth();
				this->height = texture.getHeight();

				//update the sender to match local settings
				char mutableName[256];
				strcpy_s(mutableName, channelName.size() + 1, channelName.c_str());
				if (!this->spoutSender->UpdateSender(mutableName, this->width, this->height)) {
					throw("Can't update sender");
				}
				this->channelName = string(mutableName);
			}

			//send texture and retain any fbo bound for drawing
			GLint drawFboId = 0;
			glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
			this->spoutSender->SendTexture(texture.getTextureData().textureID, texture.getTextureData().textureTarget, this->width, this->height, flipY, drawFboId);
			return true;
		}
		catch (const char * e) {
			ofLogError("ofxSpout::Sender::send") << e;
			return false;
		}
	}
开发者ID:Harvey3141,项目名称:ofxSpout,代码行数:32,代码来源:Sender.cpp

示例4: 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 ;
}
开发者ID:HeliosInteractive,项目名称:ofxSimpleMask,代码行数:58,代码来源:ofxSimpleMask.cpp

示例5: center

//--------------------------------------------------------------
void center(const ofTexture& texture, ofFbo& container,  int angle) {
  if (angle % 2 == 0) {
    ofTranslate(container.getWidth() * 0.5f - texture.getWidth()  * 0.5f,
                container.getHeight() * 0.5f - texture.getHeight() * 0.5f);
  }
  else {
    ofTranslate(container.getWidth() * 0.5f - texture.getHeight() * 0.5f,
                container.getHeight() * 0.5f - texture.getWidth()  * 0.5f);
  }
}
开发者ID:ragnaringi,项目名称:Periscope,代码行数:11,代码来源:Input.cpp

示例6: copy

    void copy(S& src, ofTexture& tex) {
        imitate(tex, src);
        int w = tex.getWidth(), h = tex.getHeight();
        int glType = tex.getTextureData().glTypeInternal;
        Mat mat = toCv(src);
		tex.loadData(mat.ptr(), w, h, glType);
    }
开发者ID:brannondorsey,项目名称:LEDWallInteractive,代码行数:7,代码来源:Helpers.cpp

示例7: render

void LayoutVerticalStripes::render(ofTexture texture, ColorChannel *colorChannel, Layer layer) {
    float complexity = layer.complexity;
    int nrows = (complexity * 128) + 1;
    int ncols = 1;
    int xSize = ofGetWidth() / nrows;
    int ySize = ofGetHeight() / ncols;
    for (int row=0; row<nrows; row++) {
        for (int col=0; col<ncols; col++) {
            ofColor selectedColor = colorChannel->selectColor(nrows * col + row + layoutFrame);
            shader.begin(texture.getWidth(),
                         texture.getHeight(),
                         layer.masterScreenAlpha,
                         layer.alpha,
                         layer.contrast,
                         layer.luminance,
                         selectedColor.r,
                         selectedColor.g,
                         selectedColor.b);
            int xOffset = row * xSize;
            int yOffset = col * ySize;
            texture.draw(xOffset, yOffset, xSize, ySize);
            shader.end();
        }
    }
}
开发者ID:jhpoelen,项目名称:ofPooks,代码行数:25,代码来源:layoutVerticalStripes.cpp

示例8: initFromTexture

	void OpenCLImage::initFromTexture(ofTexture &tex,
									  cl_mem_flags memFlags,
									  int mipLevel)
	{
		
		ofLog(OF_LOG_VERBOSE, "OpenCLImage::initFromTexture");
		
		init(tex.getWidth(), tex.getHeight(), 1);
		
		cl_int err;
		if(clMemObject) clReleaseMemObject(clMemObject);
		
		clMemObject = clCreateFromGLTexture2D(pOpenCL->getContext(), memFlags, tex.getTextureData().textureTarget, mipLevel, tex.getTextureData().textureID, &err);
		assert(err != CL_INVALID_CONTEXT);
		assert(err != CL_INVALID_VALUE);
		//	assert(err != CL_INVALID_MIPLEVEL);
		assert(err != CL_INVALID_GL_OBJECT);
		assert(err != CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
		assert(err != CL_OUT_OF_HOST_MEMORY);
		assert(err == CL_SUCCESS);
		assert(clMemObject);
		
		texture = &tex;
		hasCorrespondingGLObject = true;
	}
开发者ID:mikeswoods,项目名称:position-based-fluids,代码行数:25,代码来源:MSAOpenCLImage.cpp

示例9: 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() ;
}
开发者ID:HeliosInteractive,项目名称:ofxSimpleMask,代码行数:47,代码来源:ofxSimpleMask.cpp

示例10:

	Obj(ofTexture & videoFrame)
	:pixelsChanged(false)
	,createdTexPixels(false)
	{
		pixels.allocate(videoFrame.getWidth(),videoFrame.getHeight(),ofGetImageTypeFromGLType(videoFrame.texData.glInternalFormat));
		updateTexture(videoFrame);
		total_num_frames++;
	}
开发者ID:jurcello,项目名称:ofxPlaymodes,代码行数:8,代码来源:VideoFrame.cpp

示例11: 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();

}
开发者ID:YCAMInterlab,项目名称:RAMDanceToolkit,代码行数:57,代码来源:dpMarionette.cpp

示例12: 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();
	}
开发者ID:bossacorp,项目名称:ofxFlowTools,代码行数:44,代码来源:ftUtil.cpp

示例13: 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();
	}
开发者ID:jurcello,项目名称:ofxPlaymodes,代码行数:20,代码来源:VideoFrame.cpp

示例14: applyRotation

//--------------------------------------------------------------
void applyRotation(const ofTexture &texture, int angle) {
  ofRotate(angle * 90);
  
  switch (angle) {
      
    case Rotate90:
      ofTranslate( 0, -texture.getHeight() );
      break;
      
    case Rotate180:
      ofTranslate( -texture.getWidth(), -texture.getHeight() );
      break;
      
    case Rotate270:
      ofTranslate( -texture.getWidth(), 0 );
      break;
      
    default: break;
  }
}
开发者ID:ragnaringi,项目名称:Periscope,代码行数:21,代码来源:Input.cpp

示例15: pickColorFrom

void Brush::pickColorFrom(ofTexture &_tex, float _lerpAmount, float _randAmount){
    
    ofRectangle palleteArea(0,0,_tex.getWidth(),_tex.getHeight());
    
    ofFloatPixels pixels;
    pixels.allocate(_tex.getWidth(), _tex.getHeight(), OF_IMAGE_COLOR_ALPHA);
    _tex.readToPixels(pixels);
    
    for(int i = 0; i < Bs.size(); i++){
        
        if ( palleteArea.inside( *Bs[i] ) ){
        
            ofFloatColor color = pixels.getColor(Bs[i]->x, Bs[i]->y);
            Bs[i]->color.lerp(color, _lerpAmount * color.a);
            Bs[i]->color.setHue( Bs[i]->color.getHue() + ofRandom(-_randAmount,_randAmount) );
            colors[i].set(Bs[i]->color);
            colors[i].a = 1.0;
        }
    }
}
开发者ID:jeonghopark,项目名称:MuseoPicasso,代码行数:20,代码来源:Brush.cpp


注:本文中的ofTexture::getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。