|
|
| |
int TEXTURE_DESC::load_image_file(const char* filename) { | int TEXTURE_DESC::load_image_file(const char* filename) { |
int retval; | int retval; |
|
int sizeX; |
|
int sizeY; |
|
int sizeZ; |
|
unsigned int *pImage; |
FILE* f; | FILE* f; |
f = boinc_fopen(filename, "r"); | f = boinc_fopen(filename, "r"); |
if (!f) goto done; | if (!f) goto done; |
|
|
retval = CreateTextureTGA(filename); | retval = CreateTextureTGA(filename); |
if (!retval) return 0; | if (!retval) return 0; |
#endif | #endif |
retval = CreateTextureRGB(filename); |
retval = -1; |
if (!retval) return 0; |
if (filename) { |
|
pImage = read_rgb_texture(filename,&sizeX,&sizeY,&sizeZ); |
|
if (pImage != NULL) { |
|
glPixelStorei(GL_UNPACK_ALIGNMENT,1); |
|
glGenTextures(1, (GLuint*)&id); |
|
glBindTexture(GL_TEXTURE_2D, id); |
|
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, sizeX, sizeY, GL_RGBA, GL_UNSIGNED_BYTE, pImage); |
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); |
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); |
|
if (pImage) |
|
free(pImage); |
|
retval = 0; |
|
} |
|
} |
|
if (!retval) return 0; |
| |
done: | done: |
present = false; | present = false; |