代码如下:
#include <vector>
#include <GL/glew.h>
struct VertexBufferElement
{
unsigned int type;
unsigned int count;
bool normalized;
};
class VertexBufferLayout
{
private:
std::vector<VertexBufferElement> m_Elements;
unsigned int m_Stride;
public:
VertexBufferLayout()
:m_Stride(0) {}
template<typename T>
void Push(int count)
{
static_assert(false);
}
template<>
void Push<float>(int count)
{
m_Elements.push_back({GL_FLOAT, count, false});
m_Stride += sizeof(GLfloat);
}
template<>
void Push<unsigned int>(int count)
{
m_Elements.push_back({GL_UNSIGNED_INT, count, false });
m_Stride += sizeof(GLuint);
}
template<>
void Push<unsigned char>(int count)
{
m_Elements.push_back({GL_UNSIGNED_BYTE, count, true });
m_Stride += sizeof(GLbyte);
}
inline const std::vector<VertexBufferElement>GetElements() const { return m_Elements; }
inline unsigned int GetStride() const { return m_Stride; }
};
报错
严重性 代码 说明 项目 文件 行 禁止显示状态
错误(活动) E0304 没有与参数列表匹配的 重载函数 "std::vector<_Ty, _Alloc>::push_back [其中 _Ty=VertexBufferElement, _Alloc=std::allocator]" 实例 OpenGL E:\opengl\1\Opengl\src\VertexBufferLayout.h 30