This problem does not occur with lwjgl 2.8.2, but does happen with lwjgl 2.8.3. I do think this is a bug since the exception message talks about needing space in the Buffer for a 'faux' return value for a function(
http://www.opengl.org/sdk/docs/man/xhtml/glBufferSubData.xml ) that does not, as far as I understand it, only accepts in-data and doesn't produce any kind of return value, 'faux' or otherwise.
The exception is very easy to reproduce, so here's..
The exception:
Exception in thread "main" java.lang.IllegalArgumentException: Number of remaining buffer elements is 0, must be at least 1. Because at most 1 elements can be returned, a buffer with at least 1 elements is required, regardless of actual returned element count
at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:258)
at org.lwjgl.opengl.GL15.glBufferSubData(GL15.java:192)
at proceduralterraingenerator.test.LWJGL283Bug.main(LWJGL283Bug.java:33)
The code that produces it:
package proceduralterraingenerator.test;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL30;
public class LWJGL283Bug {
public static void main(String[] args) throws LWJGLException {
System.out.println("Creating display.");
Display.create();
System.out.println("Creating VAO.");
int vaoValue = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vaoValue);
System.out.println("Creating VBO.");
int vbo = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
System.out.println("Allocating some space in the VBO.");
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, 100, GL15.GL_STATIC_DRAW);
System.out.println("Loading up 0 bytes of data into the VBO.");
FloatBuffer buffer = BufferUtils.createFloatBuffer(0);
GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, buffer);
//Resulting output:
/*
Creating display.
Creating VAO.
Creating VBO.
Allocating some space in the VBO.
Loading up 0 bytes of data into the VBO.
Exception in thread "main" java.lang.IllegalArgumentException: Number of remaining buffer elements is 0, must be at least 1. Because at most 1 elements can be returned, a buffer with at least 1 elements is required, regardless of actual returned element count
at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:258)
at org.lwjgl.opengl.GL15.glBufferSubData(GL15.java:192)
at proceduralterraingenerator.test.LWJGL283Bug.main(LWJGL283Bug.java:33)
*/
}
}