diff options
| author | Ray <[email protected]> | 2017-04-20 00:21:38 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-04-20 00:21:38 +0200 |
| commit | bc1bfe54d6df0b872b604870d3e55a9f9f4e19dd (patch) | |
| tree | fa1fb6c1b03008d98c342970fa095d7cc84c2252 /src/textures.c | |
| parent | 407746193d991190fa4dead94649abb2ed27d462 (diff) | |
| parent | 35172430c6b5929e8f6781e0d92b4bc1f9fcc2a2 (diff) | |
| download | raylib-bc1bfe54d6df0b872b604870d3e55a9f9f4e19dd.tar.gz raylib-bc1bfe54d6df0b872b604870d3e55a9f9f4e19dd.zip | |
Merge pull request #262 from raysan5/develop
Integrate develop branch
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/textures.c b/src/textures.c index fff0e4e9..9fd5944e 100644 --- a/src/textures.c +++ b/src/textures.c @@ -195,9 +195,13 @@ Image LoadImage(const char *fileName) int imgWidth = 0; int imgHeight = 0; int imgBpp = 0; + + FILE *imFile = fopen(fileName, "rb"); // NOTE: Using stb_image to load images (Supports: BMP, TGA, PNG, JPG, ...) - image.data = stbi_load(fileName, &imgWidth, &imgHeight, &imgBpp, 0); + image.data = stbi_load_from_file(imFile, &imgWidth, &imgHeight, &imgBpp, 0); + + fclose(imFile); image.width = imgWidth; image.height = imgHeight; @@ -516,12 +520,14 @@ Image GetTextureData(Texture2D texture) image.width = texture.width; image.height = texture.height; image.mipmaps = 1; -#if defined(GRAPHICS_API_OPENGL_ES2) - // NOTE: Data retrieved on OpenGL ES 2.0 comes as RGB (from framebuffer) - image.format = UNCOMPRESSED_R8G8B8A8; -#else - image.format = texture.format; -#endif + + if (rlGetVersion() == OPENGL_ES_20) + { + // NOTE: Data retrieved on OpenGL ES 2.0 comes as RGBA (from framebuffer) + image.format = UNCOMPRESSED_R8G8B8A8; + } + else image.format = texture.format; + TraceLog(INFO, "Texture pixel data obtained successfully"); } else TraceLog(WARNING, "Texture pixel data could not be obtained"); |
