From b80583cf08654bb5673d834d2feee5384bba99ea Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 2 Sep 2018 15:11:24 +0200 Subject: [PATCH] hyperweb: loadTextureGL() now works correctly --- textures.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/textures.cpp b/textures.cpp index 34b99793..a943571e 100644 --- a/textures.cpp +++ b/textures.cpp @@ -76,9 +76,15 @@ bool texture_data::loadTextureGL() { glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + // BGRA may be not supported in the web version + if(ISWEB) for(auto& p: texture_pixels) swap(part(p, 0), part(p, 2)); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, twidth, twidth, 0, + ISWEB ? GL_RGBA : GL_BGRA, GL_UNSIGNED_BYTE, GL_BGRA, GL_UNSIGNED_BYTE, &texture_pixels[0] ); + + if(ISWEB) for(auto& p: texture_pixels) swap(part(p, 0), part(p, 2)); return true; }