0

I'm building my own game engine in C++14 with a core OpenGL 4.3 back-end.

I'm following the following tutorials:

I also follow these books:

  • OpenGL SuperBible (Sixth Edition)
  • OpenGL 4 Shading Language Cookbook (Second Edition)

Both of these books work with OpenGL 4.3, but learnopengl.com teaches OpenGL 3.3. This isn't a problem, as I follow OpenGL 3.3, and modify whenever my other resources introduce a new way.

I'm currently having a bit of trouble porting vertex arrays from the old OpenGL 3.3 way to the new OpenGL 4.3 way, as seen in Wolff's book on page 31.

The old way:

gl::EnableVertexAttribArray(0);
gl::BindBuffer(gl::ARRAY_BUFFER, vbo);
gl::VertexAttribPointer(0, 3, gl::FLOAT, false, 0, nullptr);

The new way:

gl::EnableVertexAttribArray(0);
gl::BindVertexBuffer(0, vbo, 0, sizeof(GLfloat) * 3);
gl::VertexAttribFormat(0, 3, gl::FLOAT, false, 0);
gl::VertexAttribBinding(0, 0);

Hopefully, that's brought you up to speed on what I'm talking about. My real issue is concerning element arrays, which Wolff doesn't go into much detail about. Furthermore, I can't seem to find element arrays in the SuperBible, and the index is misleading (note that I'm treating the SuperBible as more of a reference than as a book to read).

Following the online documentation, my best guess is that I should apply the following code:

gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo);
gl::BufferData(gl::ELEMENT_ARRAY_BUFFER, size, ptr, gl::STATIC_DRAW);

However, I can't seem to see my mesh. Just wondering if there's a newer way to handle element arrays that I might have overlooked?

Cheers!

cjdb
  • 54
  • 3
  • 9
  • No, I can't see anything you've missed. – Nicol Bolas Jan 31 '16 at 14:23
  • 1
    Why do you assume the error has anything to do with "newer" vs. "older" ways for some things? The "new" APIs are just alternative ways, and the "old" ones are not deprecated. You can mix and match those stuff in most cases. Do you have a working version with the "old" APIs? And if so, what exactly did you change? – derhass Jan 31 '16 at 17:48

0 Answers0