Skip to content

Commit

Permalink
lib support for loading ALPHA channel into textures
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriousSamV committed Mar 1, 2017
1 parent 24bc92f commit 0c57b59
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/mylib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,31 @@ namespace mylib
return texID;
}

static GLuint loadTextureRGB(GLchar* path) {
return loadTexture(path);
}

static GLuint loadTextureRGBA(GLchar* path)
{
GLuint texID{ 0 };
glGenTextures(1, &texID);
int width{ 0 }, height{ 0 };
unsigned char* image = SOIL_load_image(path, &width, &height,
0, SOIL_LOAD_RGBA);
glBindTexture(GL_TEXTURE_2D, texID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, image);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
SOIL_free_image_data(image);

return texID;
}

};

#endif

0 comments on commit 0c57b59

Please sign in to comment.