Created
March 16, 2017 17:45
-
-
Save feuery/8bb229c3ff5d023fa87195e163badf73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void immutable_obj::setup_texture(QOpenGLFunctions_4_3_Core *f, const char* filename) | |
{ | |
if(strcmp(filename, "") == 0) { | |
qDebug() << "Not loading texture's from an empty string"; | |
return; | |
} | |
if(!shader_loaded) { qDebug()<<"Shader isn't loaded?"; return; } | |
f->glGenTextures(1, &texture); | |
f->glBindTexture(GL_TEXTURE_2D, texture); | |
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); | |
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); | |
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); | |
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
unsigned char* img = SOIL_load_image(filename, &text_w, &text_h, 0, SOIL_LOAD_RGB); | |
f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, text_w, text_h, 0, GL_RGB, GL_UNSIGNED_BYTE, img); | |
f->glGenerateMipmap(GL_TEXTURE_2D); | |
SOIL_free_image_data(img); | |
f->glBindTexture(GL_TEXTURE_2D, 0); | |
qDebug() << "Set up a texture from " << filename; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment