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