Skip to content

Commit

Permalink
The Github Actions agent doesn't support openGL 3+, so re-instantiate…
Browse files Browse the repository at this point in the history
… the workaround of calling gluBuild2DMipmaps for these old clients.
  • Loading branch information
codereader committed Aug 9, 2021
1 parent 294811b commit 565776e
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions libs/RGBAImage.h
Expand Up @@ -69,10 +69,26 @@ class RGBAImage :
if (role == Role::NORMAL_MAP) {
format = GL_RG8;
}
glTexImage2D(GL_TEXTURE_2D, 0, format, static_cast<GLint>(getWidth()),
static_cast<GLint>(getHeight()), 0, GL_RGBA,
GL_UNSIGNED_BYTE, getPixels());
glGenerateMipmap(GL_TEXTURE_2D);

if (GLEW_VERSION_3_0)
{
glTexImage2D(GL_TEXTURE_2D, 0, format, static_cast<GLint>(getWidth()),
static_cast<GLint>(getHeight()), 0, GL_RGBA,
GL_UNSIGNED_BYTE, getPixels());

glGenerateMipmap(GL_TEXTURE_2D);
}
else // no openGL 3+ context, run the old-fashioned code
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

// Download the image to OpenGL
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA,
static_cast<GLint>(getWidth()), static_cast<GLint>(getHeight()),
GL_RGBA, GL_UNSIGNED_BYTE,
getPixels()
);
}

// Un-bind the texture
glBindTexture(GL_TEXTURE_2D, 0);
Expand Down

0 comments on commit 565776e

Please sign in to comment.