Buffer Layout Abstraction in OpenGL
Why Stack Overflow recommends it
Stack Overflow users link it when they are following the series and get stuck on the template push function, template specialization, or a compile error in their own VertexBufferLayout code.
Recommended by 0 people across 0 different months, 2018 to 2023.
What it is
An episode of The Cherno's OpenGL series in which he builds a vertex buffer layout abstraction in C++, using templates and a VertexBufferElement struct to describe attribute counts, types and stride. It is a roughly 30 minute live-coding walkthrough aimed at people following the full series.
What people said
Cites BinaryAura · 2018-05 · Stack Overflow · on “How to give different values based on a generic type parameter?”
I'm trying to implement a VertexBufferLayout struct by following TheChernoProject Series on openGL [this video] . I've been adapting the C++ series over to Rust easily enough, but I've gotten stuck. VertexBufferElement has a count, the glEnum for the data_type it uses and a boolean, normalized. There is a generic method called push which takes a u32 count that pushes a VertexBufferElement to elements Vec and updates the stride. I can't seem to get the function to accept code for matching the type. I've attempted to use TypeId , Any , and PhantomData when I got an error. pub fn push<T: 'a>(&mut self, count: u32) { let dt = TypeId::of::<T>(); let (data_type, normalized) = if dt == TypeId::of::<i8>(
Cites KcFnMi · 2022-11 · Stack Overflow · on “In C++ what does template<> mean?”
Does it make sense to have just the specializations but do do specify the general case? Like in [this video] Why not just get rid of the template then?
Cites Hunter Martenson · 2023-09 · Stack Overflow · on “C++ no instance of overloaded function matches the argument list E0304”
[this video] I'm following this YouTube series on OpenGL, and at around the 13:00 mark, my code throws this error on the push_back function. No matter what I try, I can't figure out what is different between my code and his. Error (active) E0304 no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=VertexBufferElement, _Alloc=std::allocator<VertexBufferElement>]" matches the argument list TheChernoOpenGl C:\Users\Hunter Martenson\source\repos\TheChernoOpenGl\TheChernoOpenGl\src\VertexBufferLayout.h 31 #pragma once #include <vector> #include <GL/glew.h> struct VertexBufferElement { unsigned int type; unsigned int count; bool normalized; }; class VertexBufferLayout { pri