Given the following OpenGL call stack.

According to my knowlegde, the calls to glDrawElements/Arrays are ok.(?)

But, they do not draw anything. (There is no triangle)
The calls to glBegin() and glVertex() works fine.

Full source: here

  • \$\begingroup\$ I don't see you setting the uniform "scale" in the gDraw* versions. \$\endgroup\$ – ratchet freak Feb 28 '17 at 11:39
  • \$\begingroup\$ The scale is set in the update() method. I removed it from the call stack paste, but I'll add it back in. The shaders affect the glBegin call aswell, so they should look the same. \$\endgroup\$ – stelar7 Feb 28 '17 at 11:45
  • \$\begingroup\$ I recommend using RenderDoc to capture a frame and to find out what's really being sent to the GPU. There are way too many variables at play here. \$\endgroup\$ – Dan Feb 28 '17 at 16:02
  • \$\begingroup\$ @Dan the values i read from RenderDoc seem to be totaly wrong.. The IBO is all 3722304989, and the VBO is all -1.9984e+18.. Tho i might be using it wrong? link to .rdc file \$\endgroup\$ – stelar7 Feb 28 '17 at 17:01

Turns out LWJGL does not allow the use of .wrap() to create a FloatBuffer?
Use BufferUtils.createFloatBuffer(), then put() and flip().

Ive created an issue on their github to see the answer


At https://github.com/stelar7/engine/blob/master/src/main/java/no/stelar7/engine/rendering/buffers/VertexBufferObject.java#L54 you have:

glBufferData(type, data, draw);

And likewise at your other glBufferData call.

These are not legal glBufferData calls; please see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml

void glBufferData( GLenum target,
                   GLsizeiptr size,
                   const GLvoid * data,
                   GLenum usage);

As you'll see, glBufferData actually has 4 parameters, with the second one - GLsizeiptr size - being the one that is missing from your calls. It's also important that this is the size of the data parameter in bytes, and not the number of items in an array.


You should bind the element array before you draw something with it. It's not a problem now, because you only have a single element buffer, but if you want to draw multiple meshes, it's necessary.

You don't actually need to disable anything, it only introduces unnecessary function calls.

  • \$\begingroup\$ 1. Deleting/detaching shaders after linking is fine. (The shader works fine on glBegin() calls) 2. The element buffer is linked to the vbo when its set. 3. I enable attrib 0, and put the buffer into it. \$\endgroup\$ – stelar7 Feb 28 '17 at 17:26
  • \$\begingroup\$ @stelar but then you enable attrib 1 when you render \$\endgroup\$ – Bálint Feb 28 '17 at 17:31
  • \$\begingroup\$ Where do you see that? I cant find that in the source, nor the gl call stack i linked? \$\endgroup\$ – stelar7 Feb 28 '17 at 17:33
  • \$\begingroup\$ @stelar also, are you sure you have OpenGL 3.0+? \$\endgroup\$ – Bálint Feb 28 '17 at 17:34
  • \$\begingroup\$ @stelar Sorry, I misread that part \$\endgroup\$ – Bálint Feb 28 '17 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.