Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofMesh texturing

$
0
0

@aldero wrote:

Hi,
I’m trying to create a rectangle with a texture. I get the texture to be loaded and rendered but only within the single triangles of the mesh. How can I texture the whole surface of the mesh? I don’t know what I’m missing:

ofDisableArbTex();

ofImage    *    texturePtr;
ofMesh          mesh;

mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);

// variables cx, cy, r are function parameters

mesh.addVertex(ofPoint(cx,cy));
mesh.addVertex(ofPoint(cx+r,cy));
mesh.addVertex(ofPoint(cx+r,cy+r));
mesh.addVertex(ofPoint(cx,cy+r));

mesh.addIndex(0);
mesh.addIndex(1);
mesh.addIndex(2);
mesh.addIndex(1);
mesh.addIndex(2);
mesh.addIndex(3);

mesh.addTexCoord( texturePtr->getTextureReference().getCoordFromPercent(0,0) );
mesh.addTexCoord( texturePtr->getTextureReference().getCoordFromPercent(1,0) );
mesh.addTexCoord( texturePtr->getTextureReference().getCoordFromPercent(0,1) );
mesh.addTexCoord( texturePtr->getTextureReference().getCoordFromPercent(1,1) );

texturePtr->bind();
mesh.draw();
texturePtr->unbind();

ubuntu 16.04
OF 098

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles