Answer the question
In order to leave comments, you need to log in
Can OpenGL cause a memory leak?
Can this method cause a memory leak (increase in the amount of RAM consumed) in the application? When I call this method again.
public void updateVBO() {
/** Creating VBO **/
FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(79600 * 18);
for (int height = 0; height < map.getHeight() - 1; height++) {
for (int counter = 0; counter < map.getWidth(); counter++) {
// Creating vertex buffer
vertexBuffer.put((float)(vertex * Math.cos(point) * Math.cos(hpoint))).put((float) Math.sin(hpoint)).put((float)(vertex * Math.sin(point) * Math.cos(hpoint))); // a
vertexBuffer.put((float)(vertex2 * Math.cos(point2) * Math.cos(hpoint))).put((float)Math.sin(hpoint)).put((float)(vertex2 * Math.sin(point2) * Math.cos(hpoint))); // b
vertexBuffer.put((float)(vertex4 * Math.cos(point) * Math.cos(hpoint2))).put((float)Math.sin(hpoint2)).put((float)(vertex4 * Math.sin(point) * Math.cos(hpoint2))); // d
vertexBuffer.put((float)(vertex2 * Math.cos(point2) * Math.cos(hpoint))).put((float)Math.sin(hpoint)).put((float)(vertex2 * Math.sin(point2) * Math.cos(hpoint))); // b
vertexBuffer.put((float)(vertex3 * Math.cos(point2) * Math.cos(hpoint2))).put((float)Math.sin(hpoint2)).put((float)(vertex3 *Math.sin(point2) * Math.cos(hpoint2))); // c
vertexBuffer.put((float)(vertex4 * Math.cos(point) * Math.cos(hpoint2))).put((float)Math.sin(hpoint2)).put((float)(vertex4 * Math.sin(point) * Math.cos(hpoint2))); // d
}
}
vertexBuffer.flip();
/** Creating normal buffer **/
FloatBuffer normalBuffer = BufferUtils.createFloatBuffer(79600 * 18);
for (int height = 0; height < map.getHeight() - 2; height++) {
for (int counter = 0; counter < map.getWidth(); counter++) {
normalBuffer.put(-normal1.getX()).put(-normal1.getY()).put(-normal1.getZ()); // a
normalBuffer.put(-normal1.getX()).put(-normal1.getY()).put(-normal1.getZ()); // b
normalBuffer.put(-normal1.getX()).put(-normal1.getY()).put(-normal1.getZ()); // d
normalBuffer.put(-normal1.getX()).put(-normal1.getY()).put(-normal1.getZ()); // b
normalBuffer.put(-normal1.getX()).put(-normal1.getY()).put(-normal1.getZ()); // c
normalBuffer.put(-normal1.getX()).put(-normal1.getY()).put(-normal1.getZ()); // d
}
}
normalBuffer.flip();
vboVertexBuffer = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, vertexBuffer, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
vboNormalBuffer = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboNormalBuffer);
glBufferData(GL_ARRAY_BUFFER, normalBuffer, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
normalBuffer = null;
vertexBuffer = null;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question