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


C++ ofTexture类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: Obj

	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

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

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

示例6: ofLoadImage

//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, const std::string& path, const ofImageLoadSettings &settings){
	ofPixels pixels;
	bool loaded = ofLoadImage(pixels, path, settings);
	if(loaded){
		tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
		tex.loadData(pixels);
	}
	return loaded;
}
开发者ID:BaptisteTheoriz,项目名称:openFrameworks,代码行数:10,代码来源:ofImage.cpp

示例7: ofLoadImage

//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, string path){
	ofPixels pixels;
	bool loaded = ofLoadImage(pixels,path);
	if(loaded){
		tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
		tex.loadData(pixels);
	}
	return loaded;
}
开发者ID:prettyextreme,项目名称:openFrameworks-0.7,代码行数:10,代码来源:ofImage.cpp

示例8: 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

示例9: initFromOFTexture

void GLTexture::initFromOFTexture(ofTexture &texture)
{
	tex[0] = texture.getTextureData().textureID;
	type = texture.texData.glType;
	texTarget = texture.texData.textureTarget;			//texTarget  GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, 
	texInternalFormat = texture.texData.glTypeInternal;  //GL_RGBA, GL_RGBA16F_ARB, GL_RGBA32F_ARB;
	minFilter = GL_LINEAR;		//GL_NEAREST, GL_LINEAR
	magFilter = GL_LINEAR;		//GL_NEAREST, GL_LINEAR
	width = texture.getWidth();
	height = texture.getHeight();

}
开发者ID:davidhoe,项目名称:devart-template,代码行数:12,代码来源:GLTexture.cpp

示例10: ofxCreateGaussianMapTexture

//--------------------------------------------------------------
void ofxCreateGaussianMapTexture(ofTexture& texture, int resolution, int textureTarget)
{
    ofTextureData textureData;
    textureData.width = resolution;
    textureData.height = resolution;
    textureData.glInternalFormat = GL_RGBA;
    textureData.textureTarget = textureTarget;

    unsigned char *data = createGaussianMap(resolution);

    texture.allocate(textureData);
    texture.loadData(data, resolution, resolution, GL_RGBA);
}
开发者ID:arturoc,项目名称:Entropy,代码行数:14,代码来源:ofxGaussianMapTexture.cpp

示例11: setup

void Puppet::setup(string paintingID, ofTexture tex, vector<ofPolyline> lines, ofPoint pos)
{
    this->tex = tex;
    this->pos = pos;
    this->lines = lines;
    scale = 1.0;
    rot = 0.0;
    
    if (!lines.empty())
    {
        ofPolyline line = lines.at(0);
        
        line = line.getResampledBySpacing(20);
        line.getVertices().erase(line.getVertices().begin());
        
        if (line.size() > 5)
        {
            ofPolyline lineForTri = line;
            ofVec2f tweakForDeformer(tex.getWidth()/2, tex.getHeight()/2);
            ofVec2f centroid = lineForTri.getCentroid2D();
            for (auto& p : lineForTri.getVertices())
            {
                // enlarge from centroid
//                ofVec2f dir = (p - centroid).getNormalized();
//                p += dir * 15;
                p -= tweakForDeformer;
            }
            
            mesh.triangulate(lineForTri, 28, -1);
            
            for (auto& v: mesh.triangulatedMesh.getVertices())
            {
                mesh.triangulatedMesh.addTexCoord(tex.getCoordFromPoint(v.x + tweakForDeformer.x,
                                                                        v.y + tweakForDeformer.y));
            }
            
            instance.setup(mesh.triangulatedMesh, lineForTri);
            
            vector<ofPoint> pts = line.getVertices();

            b2dObj = ofPtr<ofxBox2dPolygon>(new ofxBox2dPolygon);
            b2dObj->addVertices(pts);
            b2dObj->setPhysics(1.0, 0.3, 0.3);
            b2dObj->triangulatePoly();
            b2dObj->create(Globals::box2d->getWorld());
            b2dObj->setPosition(pos);
        }
    }
}
开发者ID:Akira-Hayasaka,项目名称:Katarube_Entrance,代码行数:49,代码来源:Puppet.cpp

示例12: mapTexCoords

//----------------------------------------------------------
void of3dPrimitive::mapTexCoordsFromTexture( ofTexture& inTexture ) {
    bool bNormalized = true;
#ifndef TARGET_OPENGLES
    bNormalized = (inTexture.getTextureData().textureTarget!=GL_TEXTURE_RECTANGLE_ARB);
#endif
    
    ofTextureData& tdata = inTexture.getTextureData();
    if(bNormalized)
        mapTexCoords( 0, 0, tdata.tex_t, tdata.tex_u );
    else
        mapTexCoords(0, 0, inTexture.getWidth(), inTexture.getHeight());
    
    ofVec4f tcoords = getTexCoords();
    mapTexCoords(tcoords.x, tcoords.y, tcoords.z, tcoords.w);
}
开发者ID:6uclz1,项目名称:openFrameworks,代码行数:16,代码来源:of3dPrimitives.cpp

示例13: 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;
	}
开发者ID:local-projects,项目名称:ofxApp,代码行数:16,代码来源:ofxAppUtils.cpp

示例14: preprocess

//--------------------------------------------------------------
void testApp::preprocess(ofTexture &_text){
    grayscale.setTexture( _text );
    grayscale.update();
    blur << grayscale;
    blur.update();
    normals << blur;
    normals.update();
    
    ofPixels normPixels;
    normPixels.allocate(normals.getWidth(), normals.getHeight(), 4);
    normals.getTextureReference().readToPixels(normPixels);
    _text.readToPixels(pixels);
    
    int scaledWidth = width/scale;
    int scaledHeight = height/scale;
    for(int x = 0; x <= scaledWidth; x++){
        for(int y = 0; y <= scaledHeight; y++){
            
            int scaledX = ofClamp(x*scale,0,width-1);
            int scaledY = ofClamp(y*scale,0,height-1);
            
            ofFloatColor normalColor = normPixels.getColor(scaledX, scaledY);
            
            int index = x + y * scaledWidth;
            ofPoint norm = ofPoint((normalColor.r - 0.5) * 2.0,
                                   (normalColor.g - 0.5) * 2.0, 0.0);
            
            float pct = 0.5;
            VF[index] = VF[index]*(1.0-pct) + norm * pct;
        }
    }
}
开发者ID:Joelone,项目名称:patriciogv_algo2012,代码行数:33,代码来源:testApp.cpp

示例15: applyDisplaceMap

void dfDisplacementMap::applyDisplaceMap(ofxCvColorImage& sourceImage,ofTexture& destTexture,float hscale=0.3, float vscale=0.3){
    //apply displacement
    unsigned char * displacePixels  = this->getPixels();
    unsigned char * pixels          = sourceImage.getPixels();
    int displace,hdisplace,vdisplace;
    int totalPixels=height*width*3;
    unsigned char * videoDisplaced     = new unsigned char[totalPixels];
    for (int i = 0; i < totalPixels;i+=3){
        hdisplace = (int)((displacePixels[i] - 127)*hscale); //x coord
        vdisplace = (int)((displacePixels[i+2] - 127) *vscale); //y coord
        if( i%(320*3)+hdisplace*3 >0 && i%(320*3)+hdisplace*3<320*3){
            displace=hdisplace+vdisplace*320;
        }else{
            displace = 0;
        }
        displace*= 3;
        if(i+displace>0 && i+displace<totalPixels){
            videoDisplaced[i]   = pixels[i+displace];
            videoDisplaced[i+1] = pixels[i+displace+1];
            videoDisplaced[i+2] = pixels[i+displace+2];
        }
    }
    destTexture.loadData(videoDisplaced,width,height, GL_RGB);
    delete videoDisplaced;
}
开发者ID:typecode,项目名称:digitallyfit,代码行数:25,代码来源:dfDisplacementMap.cpp


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