Fixed useless copying of vectors during model.draw(), now references.

Fixed copy constructor of Vec3 (Copy-pasting is bad)
Now exits on escape
This commit is contained in:
trotFunky 2019-10-19 04:24:08 +02:00
parent 8cdcc9750b
commit 18bad8389a
3 changed files with 8 additions and 3 deletions

View file

@ -53,7 +53,7 @@ void Model3D::draw_model()
for (uint32_t i = 0;i<face_count;i++)
{
Vec3i face = faces[i];
Vec3i& face = faces[i];
Vec3i* face_texture;
if (is_textured)
@ -68,7 +68,7 @@ void Model3D::draw_model()
if (is_textured)
{
Vec2f vertex_texture = texture_coordinates[face_texture->coordinates[j]];
Vec2f& vertex_texture = texture_coordinates[face_texture->coordinates[j]];
glTexCoord2f(vertex_texture.x,vertex_texture.y);
}
glVertex3f(vertex.x,vertex.y,vertex.z);

View file

@ -150,7 +150,7 @@ struct Vec3 : CoordinatesVector<T,3>
{
if (this != &original)
{
std::copy(std::begin(original.coordinates), std::end(original.coordinates), std::begin(CoordinatesVector<T,2>::coordinates));
std::copy(std::begin(original.coordinates), std::end(original.coordinates), std::begin(CoordinatesVector<T,3>::coordinates));
}
}

View file

@ -21,6 +21,11 @@ void manage_inputs()
{
glClearColor(0.5,0,0,1);
}
else if (KeyStateManager::is_key_pressed(0x1B))
{
glutDestroyWindow(glutGetWindow());
exit(EXIT_SUCCESS);
}
else
{
glClearColor(0,0,0,1);