Hello Guest

glNamedBufferStorage issue

  • 3 Replies
glNamedBufferStorage issue
« on: August 03, 2018, 20:06:45 »

I recently bought the OpenGL Programming Guide and i'm currently trying to replace my old :
Code: [Select]
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBindBuffer(GL_ARRAY_BUFFER, 0);

by :
Code: [Select]
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 :

Code: [Select]
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;

public int getVao() {
return vaoID;

public int getVertexCount() {
return verticesCount;

public float[] getData() {
return data;

public int getBufferVertexSize() {
return bufferVertexSize;

public void cleanUp() {

for(int vbo : vbos) {


public void createVertexArray() {
vaoID = glCreateVertexArrays();

public void bindVertexArray(int target) {

public void setUpBuffer(float[] data, int bufferVertexSize, int bufferIndexBinding) {
int vboID = glCreateBuffers();

// 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);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexBuffer(bufferIndexBinding, vboID, 0, bufferVertexSize * 4);

public void setUpVertexAttrib(int attribIndex, int bufferIndexBinding, int vertexAttribsize, int offset) {
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).
« Last Edit: August 03, 2018, 20:09:24 by xenoliss »

Re: glNamedBufferStorage issue
« Reply #1 on: August 03, 2018, 20:22:10 »
Ups, my bad. I juste realized I was not using the good flag in glNamedBufferStorage() function...  ::)
By the way, I'm a bit confuse about the different flags we could use here. Wich one should I use to replace a "STATIC_DRAW" flag ?


Offline KaiHH

  • ***
  • 118
Re: glNamedBufferStorage issue
« Reply #2 on: August 03, 2018, 22:21:48 »
- https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferStorage.xhtml
- http://developer.download.nvidia.com/opengl/specs/GL_ARB_buffer_storage.txt
- https://computergraphics.stackexchange.com/questions/5550/how-to-set-flags-and-usage-glnamedbufferstorage-in-new-opengl-4-4-gl-static-dr

If you only ever initialize the buffer data once with the call to glBufferStorage/glNamedBufferStorage then you can use flags = 0. There is no real equivalent for glBufferData's usage flag, since you could do anything with the buffer afterwards anyway, such as mapping into client memory, reading from it and writing to it. This is not possible anymore with glBufferStorage, since there you have to explicitly state what you are going to do with the buffer. With flags = 0 you say: "I will never ever again touch the buffer data and only let the OpenGL server (i.e. the graphics card) read from it."

Re: glNamedBufferStorage issue
« Reply #3 on: August 04, 2018, 12:22:13 »

Tanks for your answer, I'm gonna have a look at the links.  :D