diff --git a/engine/Engine.cpp b/engine/Engine.cpp index 8883275..13e9a2f 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -63,11 +63,11 @@ void Engine::create(int screenWidth, int screenHeight, const std::string &name, GLfloat *model = it.second->glModel(); GLfloat *geometry = Screen::glMeshToGLfloatArray(it.second, camera->position()); screen->glDrawMesh(geometry, view, model, 3 * it.second->triangles().size()); - free(geometry); - free(model); + delete[] geometry; + delete[] model; } } - free(view); + delete[] view; } else { // clear triangles from previous frame camera->clear(); diff --git a/engine/Object.cpp b/engine/Object.cpp index 3594170..0e86a6c 100644 --- a/engine/Object.cpp +++ b/engine/Object.cpp @@ -140,7 +140,7 @@ void Object::unattach(const ObjectNameTag &tag) { // OpenGL function GLfloat *Object::glView() const { - auto *v = (GLfloat *) malloc(4 * 4 * sizeof(GLfloat)); + auto *v = new GLfloat[4 * 4]; v[0] = -static_cast(left().x()); v[4] = -static_cast(left().y()); @@ -166,7 +166,7 @@ GLfloat *Object::glView() const { } GLfloat *Object::glModel() const { - auto *m = (GLfloat *) malloc(4 * 4 * sizeof(GLfloat)); + auto *m = new GLfloat[4 * 4]; m[0] = static_cast(left().x()); m[4] = static_cast(up().x()); diff --git a/engine/Screen.cpp b/engine/Screen.cpp index 5390d09..c865de5 100644 --- a/engine/Screen.cpp +++ b/engine/Screen.cpp @@ -173,7 +173,7 @@ void Screen::glDrawMesh(GLfloat *geometry, GLfloat *view, GLfloat *model, size_t GLfloat *Screen::glMeshToGLfloatArray(std::shared_ptr mesh, const Vec3D &cameraPosition) { std::vector const &triangles = mesh->triangles(); - auto *geometry = (GLfloat *) malloc(7 * 3 * triangles.size() * sizeof(GLfloat)); + auto *geometry = new GLfloat[7 * 3 * triangles.size()]; auto model = mesh->model();