Closed TheoW03 closed 11 months ago
one of the solutions I have is to may be have a size param instead of just sending the Buffer in with no size
the error doesn't occur with
glBufferData(int target, Array (float[],int[]...) data, int usage);
You need to use a direct buffer, see https://github.com/LWJGL/lwjgl3-wiki/wiki/1.3.-Memory-FAQ#how-do-i-allocate-and-deallocate-buffers.
the problem still continues when i implement it, like this.
try (MemoryStack stack = stackPush()) {
IntBuffer ip = stack.callocInt(1);
glGenBuffers(ip);
buffer[0] = ip.get(0);
} // stack automatically popped, ip memory automatically reclaimed
glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glVertexAttribPointer(location, 3, GL_FLOAT, false, 0, 0);
glBufferData(GL_ARRAY_BUFFER, FloatBuffer.wrap(vertices),GL_STATIC_DRAW);
i did run the debugger, and it does crash around glBufferData.
Your code is still using FloatBuffer.wrap
, which allocates a heap, and not direct, buffer.
that worked.
Version
3.2.3
Platform
Windows x86
JDK
Java 17
Module
openGL
Bug description
glBufferData(int target, Buffer (FloatBuffer,Intbuffer...) data, int usage);
has a memory error.
here is the full usage that caused this.
vertices - being an array of 12 floats between -1,1. its the points to draw a square.
shaderProgram - compiled and linked shader program.
Stacktrace or crash log output