acdemiralp / gl

Header-only C++17 wrapper for OpenGL 4.6 Core Profile.
Boost Software License 1.0
158 stars 11 forks source link

Const correctness issue and misused attribute #13

Closed BaconOFBurger closed 2 years ago

BaconOFBurger commented 2 years ago

In program.hpp at line 188

glGetProgramBinary(id_, static_cast<GLsizei>(result.size()), nullptr, &format, static_cast<void*>(result.data()));

We are passing a pointer to format which is of type const GLenum * and according to https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetProgramBinary.xhtml it should be GLenum *

I suggest that we either change the function signature to

std::vector<type> program_binary (GLenum format) const {

Or change line 188, so it includes a const cast

glGetProgramBinary(id_, static_cast<GLsizei>(result.size()), nullptr, const_cast<GLenum *>(&format), static_cast<void*>(result.data()));

I also noticed in renderbuffer.hpp at line 146

[[nodiscard]]
  void copy_image_sub_data(const renderbuffer& source,
    const GLint source_level, const GLint source_x, const GLint source_y, const GLint source_z,
    const GLint level       , const GLint x       , const GLint y       , const GLint z       , const GLint width, const GLint height, const GLint depth) const
  {
    glCopyImageSubData(source.id(), GL_RENDERBUFFER, source_level, source_x, source_y, source_z, id_, GL_RENDERBUFFER, level, x, y, z, width, height, depth);
  }

That the [[nodiscard]] attribute seems useless as we return no value, so it should be removed.

acdemiralp commented 2 years ago

Dear @BaconOFBurger , I have pushed the said changes to both develop and master, and released hotfix 2.1.2. Keep them coming. You can close the issue if there is no more.