2d
This commit is contained in:
parent
112a8f568b
commit
2a4c8de8d7
2 changed files with 39 additions and 0 deletions
|
|
@ -77,6 +77,16 @@ namespace fishbone {
|
|||
this->triangle(v, t, n);
|
||||
}
|
||||
void triangle(std::vector<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals);
|
||||
void quad(std::vector<struct fishbone::Vector2> vertices, std::vector<struct fishbone::Vector2> texcoords) {
|
||||
std::vector<struct fishbone::Vector2> v;
|
||||
std::vector<struct fishbone::Vector2> t;
|
||||
|
||||
v = fishbone::quadToTriangle<struct fishbone::Vector2>(vertices);
|
||||
t = fishbone::quadToTriangle<struct fishbone::Vector2>(texcoords);
|
||||
|
||||
this->triangle(v, t);
|
||||
}
|
||||
void triangle(std::vector<struct fishbone::Vector2> vertices, std::vector<struct fishbone::Vector2> texcoords);
|
||||
};
|
||||
|
||||
static float maxDistance = 64;
|
||||
|
|
|
|||
|
|
@ -276,4 +276,33 @@ void fishbone::Renderer::triangle(std::vector<struct fishbone::Vector3> vertices
|
|||
delete[] t;
|
||||
delete[] v;
|
||||
}
|
||||
|
||||
void fishbone::Renderer::triangle(std::vector<struct fishbone::Vector2> vertices, std::vector<struct fishbone::Vector2> texcoords) {
|
||||
GLfloat* v = new GLfloat[vertices.size() * 2];
|
||||
GLfloat* t = new GLfloat[texcoords.size() * 2];
|
||||
|
||||
for(int i = 0; i < vertices.size(); i++) {
|
||||
v[i * 2 + 0] = vertices[i].x;
|
||||
v[i * 2 + 1] = vertices[i].y;
|
||||
}
|
||||
|
||||
for(int i = 0; i < texcoords.size(); i++) {
|
||||
t[i * 2 + 0] = texcoords[i].x;
|
||||
t[i * 2 + 1] = texcoords[i].y;
|
||||
}
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, v);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, t);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size());
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] t;
|
||||
delete[] v;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue