So, after reading through your LD entry and the opengl red book, I almost have this working
I use poly2tri to carry out the Delaunay triangulation, and I have the following
Code: Select all
// three points and an associated box2d body
struct myTriangle {
b2Body* m_body;
b2Vec2 m_points[3];
};
... lots of vertex/chain shape/poly2tri code cut out here ...
while(window.isOpen())
{
m_world->Step(1/60.0f, 8, 3);
window.clear();
glColor3f(1,1,1);
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
sf::Texture::bind(&earthImage);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
for (size_t i = 0; i < earthTriangles.size(); i++) {
myTriangle& tri = earthTriangles[i];
glVertexPointer(2, GL_FLOAT, 0, tri.m_points);
glDrawArrays(GL_TRIANGLES, 0, 3);
}
sf::Texture::bind(NULL);
window.display();
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_TEXTURE_2D);
}
The problem I have here is that the polygon is filled, but only with the pixel at 0,0 of my texture, so instead of seeing my silly smiling face, I have a solid color.
I think it's something to do with setting texture coordinates, but I haven't quite understood that yet.
I know this is very far off topic, but I really do appreciate your help. (and put some higher amounts in your donate paypal form!)