Hi,
I recently bought the OpenGL Programming Guide and i'm currently trying to replace my old :
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
by : glNamedBufferStorage(vboID, data, GL_STATIC_DRAW);
as shown in this book.
But whenever I try i get this error message :
[LWJGL] OpenGL debug message
ID: 0x501
Source: API
Type: ERROR
Severity: HIGH
Message: GL_INVALID_VALUE error generated. <flags> has unknown bits set
Strangely enough it works with glBufferData().
I paste the code below so you can have a look :
package globalComponents;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.opengl.GL43.*;
import static org.lwjgl.opengl.GL45.*;
import java.util.ArrayList;
import java.util.List;
public abstract class VaoLoadingComponent implements IVaoLoadingComponent {
protected int vaoID;
protected int verticesCount;
protected int primitiveDraw;
protected int bufferVertexSize;
protected float[] data;
private List<Integer> vbos;
public VaoLoadingComponent(int primitiveDraw, float[] data, int dataVertexSize) {
vbos = new ArrayList<Integer>();
this.primitiveDraw = primitiveDraw;
this.data = data;
this.bufferVertexSize = dataVertexSize;
}
@Override
public int getVao() {
return vaoID;
}
@Override
public int getVertexCount() {
return verticesCount;
}
@Override
public float[] getData() {
return data;
}
@Override
public int getBufferVertexSize() {
return bufferVertexSize;
}
@Override
public void cleanUp() {
for(int vbo : vbos) {
glDeleteBuffers(vbo);
}
glDeleteVertexArrays(vaoID);
}
public void createVertexArray() {
vaoID = glCreateVertexArrays();
}
public void bindVertexArray(int target) {
glBindVertexArray(target);
}
public void setUpBuffer(float[] data, int bufferVertexSize, int bufferIndexBinding) {
int vboID = glCreateBuffers();
vbos.add(vboID);
// HERE IT DOESNT WORK BUT glNamedBufferData(vboID, data, GL_STATIC_DRAW) works...
// glNamedBufferStorage(vboID, data, GL_STATIC_DRAW);
// Old code to replace
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexBuffer(bufferIndexBinding, vboID, 0, bufferVertexSize * 4);
}
public void setUpVertexAttrib(int attribIndex, int bufferIndexBinding, int vertexAttribsize, int offset) {
glEnableVertexAttribArray(attribIndex);
glVertexAttribFormat(attribIndex, vertexAttribsize, GL_FLOAT, false, offset * 4);
glVertexAttribBinding(attribIndex, bufferIndexBinding);
}
protected void setVertexCount() {
this.verticesCount = getVertexCount();
}
}
Thank you very much for your help and feel free to redirect me if my post isn't in the good category (and sorry for my bad english).