replace malloc/free with new/delete
parent
a39fbaff47
commit
bd013c5e43
|
@ -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();
|
||||
|
|
|
@ -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<GLfloat>(left().x());
|
||||
v[4] = -static_cast<GLfloat>(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<GLfloat>(left().x());
|
||||
m[4] = static_cast<GLfloat>(up().x());
|
||||
|
|
|
@ -173,7 +173,7 @@ void Screen::glDrawMesh(GLfloat *geometry, GLfloat *view, GLfloat *model, size_t
|
|||
GLfloat *Screen::glMeshToGLfloatArray(std::shared_ptr<Mesh> mesh, const Vec3D &cameraPosition) {
|
||||
std::vector<Triangle> 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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue