Trouble migrating to core profile - nothing drawn

Hi there,

I am currently trying to port old code to OpenGL-4.4 core profile. The main reason is I would like to use new features such as SSBOs and some drivers don’t offer a compact profile for OpenGL 4.x (mainly Intel mesa).
The old code did (I think) pretty much what I wanted. Since the per-vertex data changes each draw, it simply streamed down that data from user managed memory each glDrawArrays call.

The code works well with compat profile, but as soon as I request a core profile context nothing is drawn.
I have to admit, I really struggle finding the issue:

/* Initialization */
// Create persistently mapped SSBO for Fragment shader
 glGenBuffers( 1, &maskBuffer );
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, maskBuffer);
  glBindBuffer( GL_SHADER_STORAGE_BUFFER, maskBuffer );
  //Create an immutable data store for the buffer
  size_t bufferSize( MASK_WIDTH * MASK_HEIGHT * 4 );  
  GLbitfield flags = GL_MAP_WRITE_BIT | 
                               GL_MAP_PERSISTENT_BIT |
  glBufferStorage( GL_SHADER_STORAGE_BUFFER, bufferSize, 0, flags);
  maskBufferData = (uint8_t*) glMapBufferRange( GL_SHADER_STORAGE_BUFFER, 0, bufferSize, flags ); 

// configure vertex attrib arrays, stream directly from user managed memory each draw() call

  vertices = (GLfloat*) malloc(sizeof(GLfloat) * 2 * 32);
  glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertices);
  attrs = (GLfloat*) malloc(sizeof(GLfloat) * 3 * 32);
  glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, attrs);

 /* Rendering */
 // Write vertices etc
 glDrawArrays(GL_QUADS, 0, 32);

Any ideas why nothing is rendered?

Thank you in advance.

While trying to find the issue, I read about core profile only working with a bound VAO.

However, it seems I am unable to draw even a simple quad using a VAO:

  GLuint VboID, VaoID;

  glGenVertexArrays(1, &VaoID);
  glGenBuffers(1, &VboID);  
  glBindBuffer(GL_ARRAY_BUFFER, VboID); 
  glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(float), NULL, GL_STREAM_DRAW);

  glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);

  GLfloat vertices[8];
  glBufferSubData(VboID, 0, 8 * sizeof(float), vertices);
  glDrawArrays(GL_QUADS, 0, 4);

Are you:

Indeed, I was not - which made it a hassle to track down errors introduced while trying out changes.
In this case the issue was with glBufferSubData expecting the binding point of the buffer (GL_ARRAY_BUFFER) instead of the buffer id.
Thanks for the pointer, the error messages are priceless.

Thanks again & best regards, Clemens

With recent versions of OpenGL, debug output may be more convenient than glGetError.

Definitely. That’s also described on the wiki page link I pointed him to, in this section: