Skip to content

Commit

Permalink
Added typename keyword to sizeof for template value types, cause gcc
Browse files Browse the repository at this point in the history
complained
  • Loading branch information
invor committed Jul 27, 2019
1 parent 22ac358 commit dea2f72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions include/glowl/BufferObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ class BufferObject

template<typename Container>
inline BufferObject::BufferObject(GLenum target, Container const& datastorage, GLenum usage)
: m_target(target), m_handle(0), m_byte_size(static_cast<GLsizeiptr>(datastorage.size() * sizeof(Container::value_type))), m_usage(usage)
: m_target(target),
m_handle(0),
m_byte_size(static_cast<GLsizeiptr>(datastorage.size() * sizeof(typename Container::value_type))),
m_usage(usage)
{
glGenBuffers(1, &m_handle);
glBindBuffer(m_target, m_handle);
Expand Down Expand Up @@ -118,15 +121,15 @@ template<typename Container>
inline void BufferObject::bufferSubData(Container const& datastorage, GLsizeiptr byte_offset) const
{
// check if feasible
if ((byte_offset + static_cast<GLsizeiptr>(datastorage.size() * sizeof(Container::value_type))) > m_byte_size)
if ((byte_offset + static_cast<GLsizeiptr>(datastorage.size() * sizeof(typename Container::value_type))) > m_byte_size)
{
// error message
std::cerr << "Error - BufferObject - bufferSubData: given data too large for buffer." << std::endl;
return;
}

glBindBuffer(m_target, m_handle);
glBufferSubData(m_target, byte_offset, datastorage.size() * sizeof(Container::value_type), datastorage.data());
glBufferSubData(m_target, byte_offset, datastorage.size() * sizeof(typename Container::value_type), datastorage.data());
glBindBuffer(m_target, 0);
}

Expand All @@ -147,7 +150,7 @@ inline void BufferObject::bufferSubData(GLvoid const* data, GLsizeiptr byte_size

template<typename Container>
inline void BufferObject::rebuffer(Container const& datastorage) {
m_byte_size = static_cast<GLsizeiptr>(datastorage.size() * sizeof(Container::value_type));
m_byte_size = static_cast<GLsizeiptr>(datastorage.size() * sizeof(typename Container::value_type));
glBindBuffer(m_target, m_handle);
glBufferData(m_target, m_byte_size, datastorage.data(), m_usage);
glBindBuffer(m_target, 0);
Expand Down
16 changes: 8 additions & 8 deletions include/glowl/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ class Mesh
*/
void draw(GLsizei instance_cnt = 1) {
glBindVertexArray(m_va_handle);
glDrawElementsInstanced(m_primitive_type, m_indices_cnt, m_indices_type, nullptr, instance_cnt);
glDrawElementsInstanced(m_primitive_type, m_indices_cnt, m_index_type, nullptr, instance_cnt);
glBindVertexArray(0);
}

VertexLayout getVertexLayout() const { return m_vertex_descriptor; }

GLuint getIndicesCount() const { return m_indices_cnt; }

GLenum getIndexType() const { return m_indices_type; }
GLenum getIndexType() const { return m_index_type; }

GLenum getPrimitiveType() const { return m_primitive_type; }

Expand All @@ -141,7 +141,7 @@ class Mesh
VertexLayout m_vertex_descriptor;

GLuint m_indices_cnt;
GLenum m_indices_type;
GLenum m_index_type;
GLenum m_usage;
GLenum m_primitive_type;
};
Expand All @@ -159,7 +159,7 @@ inline Mesh::Mesh(
GLenum const primitive_type)
: m_ibo(GL_ELEMENT_ARRAY_BUFFER, index_data, index_data_byte_size, usage),
m_vertex_descriptor(vertex_descriptor),
m_va_handle(0), m_indices_cnt(0), m_indices_type(indices_type), m_usage(usage), m_primitive_type(primitive_type)
m_va_handle(0), m_indices_cnt(0), m_index_type(indices_type), m_usage(usage), m_primitive_type(primitive_type)
{
for (unsigned int i = 0; i < vertex_data.size(); ++i)
m_vbos.emplace_back(std::make_unique<BufferObject>(GL_ARRAY_BUFFER, vertex_data[i], vertex_data_byte_sizes[i], usage));
Expand All @@ -186,7 +186,7 @@ inline Mesh::Mesh(
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

switch (m_indices_type)
switch (m_index_type)
{
case GL_UNSIGNED_INT:
m_indices_cnt = static_cast<GLuint>(index_data_byte_size / 4);
Expand All @@ -210,7 +210,7 @@ inline Mesh::Mesh(
GLenum primitive_type)
: m_ibo(GL_ELEMENT_ARRAY_BUFFER, index_data, usage), //TODO ibo generation in constructor might fail? needs a bound vao?
m_vertex_descriptor(vertex_descriptor),
m_va_handle(0), m_indices_cnt(0), m_indices_type(indices_type), m_usage(usage), m_primitive_type(primitive_type)
m_va_handle(0), m_indices_cnt(0), m_index_type(indices_type), m_usage(usage), m_primitive_type(primitive_type)
{
for (unsigned int i = 0; i < vertex_data.size(); ++i)
m_vbos.emplace_back(std::make_unique<BufferObject>(GL_ARRAY_BUFFER, vertex_data[i], m_usage));
Expand All @@ -232,9 +232,9 @@ inline Mesh::Mesh(
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

GLuint vi_size = static_cast<GLuint>(index_data.size() * sizeof(IndexContainer::value_type));
GLuint vi_size = static_cast<GLuint>(index_data.size() * sizeof(typename IndexContainer::value_type));

switch (m_indices_type)
switch (m_index_type)
{
case GL_UNSIGNED_INT:
m_indices_cnt = static_cast<GLuint>(vi_size / 4);
Expand Down

0 comments on commit dea2f72

Please sign in to comment.