本文整理汇总了C++中ofTexture类的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture类的具体用法?C++ ofTexture怎么用?C++ ofTexture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofTexture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: updateOpticalFlow
void FluidKinect::updateOpticalFlow(ofTexture & maskedKinect)
{
maskedKinect.readToPixels(maskPixels);
blurImage.setFromPixels(maskPixels);
blurImage.resize(opFlow.sizeSml.width, opFlow.sizeSml.height);
blurImage.flagImageChanged();
opFlow.update(blurImage);
}
开发者ID:Mystfit,项目名称:Sonoromancer,代码行数:8,代码来源:FluidKinect.cpp
示例17: draw
void BulgeEffect::draw(ofTexture& tex, int x, int y) {
applyBulgeShader.begin();
applyBulgeShader.setUniformTexture("bulge", blendBulge.getTextureReference(), 1);
applyBulgeShader.setUniformTexture("tex", tex, 2);
tex.draw(x, y);
applyBulgeShader.end();
needToClear = true;
}
开发者ID:jeonghopark,项目名称:openFrameworksDemos,代码行数:8,代码来源:BulgeEffect.cpp
示例18: debugShader
void Clone::debugShader(ofTexture &tex, ofTexture &mask){
debugFbo.allocate(buffer.getWidth(), buffer.getHeight());
debugResultFbo.allocate(buffer.getWidth(), buffer.getHeight());
ofShader debugShader;
debugShader.load("shader/maskBlurShader");
setStrength(16);
debugFbo.begin();
// debugShader.begin();
//
// //maskBlurShader.setUniformTexture("tex", tex, 1);
// debugShader.setUniformTexture("tex0", tex, 1);
// debugShader.setUniformTexture("mask", mask, 2);
// debugShader.setUniform2f("direction", 0, 1);
// debugShader.setUniform1i("k", strength);
// mask.draw(0, 0);
//
// debugShader.end();
maskBlurShader.begin();
maskBlurShader.setUniformTexture("tex0", tex, 1);
maskBlurShader.setUniformTexture("mask", mask, 2);
//maskBlurShader.setUniform2f("direction", 0., 1./tex.getHeight());
maskBlurShader.setUniform2f("direction", 1./tex.getWidth(), 0.);
maskBlurShader.setUniform1i("k", strength);
tex.draw(0, 0);
maskBlurShader.end();
debugFbo.end();
// debugResultFbo.begin();
//
// maskBlurShader.setUniformTexture("tex0", debugFbo, 1);
// maskBlurShader.setUniformTexture("mask", mask, 2);
// maskBlurShader.setUniform2f("direction", 0., 1./tex.getHeight());
// maskBlurShader.setUniform1i("k", strength);
// debugFbo.draw(0, 0);
//
// debugResultFbo.end();
}
开发者ID:RyotaKatoh,项目名称:ofxiOSFaceSubstitution,代码行数:46,代码来源:Clone.cpp
示例19: 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
示例20: ofGetWidth
void tricks::gl::effects::OutputFilter::draw(ofTexture &tex) {
shader.begin();
shader.setUniformTexture("tex", tex, 0);
shader.setUniform1f("brightness", brightness);
shader.setUniform1f("contrast", contrast);
shader.setUniform1f("saturation", saturation);
tex.draw(0, 0, ofGetWidth(), ofGetHeight());
shader.end();
}
开发者ID:mazbox,项目名称:tricks,代码行数:9,代码来源:OutputFilter.cpp
注:本文中的ofTexture类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论