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!