c - OpenGL 3.0 glVertexAttribPointer: legacy works, forward compatible (core) doesn’t -


this code works fine in legacy opengl 3.0, fails in forward compatible mode (4.1 , 3.3 on setup). i’ve tested on hardware , sofware implementations. use sdl opengl context, , glew find functions. adding line below code make problem.

sdl_gl_setattribute(sdl_gl_context_flags, sdl_gl_context_forward_compatible_flag); 

the problematic part of code call glvertexattribpointer

glbindbuffer(gl_array_buffer, glb.vbo); glbufferdata(     gl_array_buffer,     size * sizeof(glfloat),     input,     gl_dynamic_draw ); test_gl_errors(); /* gl_no_error */  gluseprogram(glb.program); glenablevertexattribarray(glb.vert_array); glenablevertexattribarray(glb.colour_array); /* use later. */  test_gl_errors(); /* gl_no_error */ glvertexattribpointer(     glb.vert_array,     2,     gl_float,     gl_false,     5 * sizeof(glfloat),     0 ); test_gl_errors(); /* gl_invalid_operation */ 

i add more code, there lot of stuff. reading information link below didn’t me. suggestions?
https://www.opengl.org/sdk/docs/man/html/glvertexattribpointer.xhtml

my opengl setup:

  • gallium 0.4 on amd cape verde (drm 2.45.0 / 4.7.2-1-ck, llvm 3.8.1)
  • gallium 0.4 on llvmpipe (llvm 3.8, 128 bits)
  • mesa3d: 12.0.1

the working code, based on comments reto koradi.

glbindvertexarray(gl_array_buffer, glb.vao); /* <-- new !!! */ glbindbuffer(gl_array_buffer, glb.vbo); glbufferdata(     gl_array_buffer,     size * sizeof(glfloat),     input,     gl_dynamic_draw );  gluseprogram(glb.program); glenablevertexattribarray(glb.vert_array);  glvertexattribpointer(     glb.vert_array,     2,     gl_float,     gl_false,     5 * sizeof(glfloat),     0 ); test_gl_errors(); /* gl_no_error */ 

Comments