Hi
Can someone show me the easiest way to bind an ofTexture to my ofMesh?
I tried
`myTex.bind();
mesh.draw();
myTex.unbind();
`
but the texture is not displayed to my mesh
Thanks for your help
Hi
Can someone show me the easiest way to bind an ofTexture to my ofMesh?
I tried
`myTex.bind();
mesh.draw();
myTex.unbind();
`
but the texture is not displayed to my mesh
Thanks for your help
You can find a usage example here examples/gl/textureExample/
.
Thanks for your quick reply , I already used this example to understand how to use and allocate textures but how allocate them to a mesh ? Thanks for your help
Hmm thanks for your help guys. The answer was just I forgot to setTexCoord to mesh and to set the right meshType mode
`mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
mesh.addVertex(ofPoint(offset, offset, 0));
mesh.addVertex(ofPoint(ofGetWindowWidth() - offset, offset, 0));
mesh.addVertex(ofPoint(ofGetWindowWidth() - offset, ofGetWindowHeight() - offset, 0));
mesh.addVertex(ofPoint(offset, ofGetWindowHeight() - offset, 0));
mesh.addIndex(0);
mesh.addIndex(1);
mesh.addIndex(2);
mesh.addIndex(3);
mesh.addTexCoord(ofVec2f(0,0));
mesh.addTexCoord(ofVec2f(0, 100));
mesh.addTexCoord(ofVec2f(100, 100));
mesh.addTexCoord(ofVec2f(100, 0));
img.load(â2.jpgâ);
ofPixels pixels = img.getPixels();
tex.loadData(pixels);
//
`
And this code in draw()
tex.bind(); mesh.draw(); tex.unbind();