X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Frenders%2Fopengl%2Fr_textures.pas;h=b98c0d3507d98576d6ecafa23291bfd895280ce9;hb=659ba32fea457791d0489969a7ded0485efc5a31;hp=34b5b9e7027c8863ad32a0777d22297047fb5dc2;hpb=203d8922aa34a34fb63e312691c711c419c34ae1;p=d2df-sdl.git diff --git a/src/game/renders/opengl/r_textures.pas b/src/game/renders/opengl/r_textures.pas index 34b5b9e..b98c0d3 100644 --- a/src/game/renders/opengl/r_textures.pas +++ b/src/game/renders/opengl/r_textures.pas @@ -18,11 +18,7 @@ unit r_textures; interface uses - {$IFDEF USE_GLES1} - GLES11, - {$ELSE} - GL, GLEXT, - {$ENDIF} + {$I ../../../nogl/noGLuses.inc} g_base, g_animations, // TRectHW, TAnimInfo utils, r_atlas, r_fonts @@ -139,6 +135,8 @@ interface function r_Textures_LoadFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont; + procedure r_Textures_GL_Bind (id: GLuint); + implementation uses @@ -154,6 +152,16 @@ implementation r_GL_RepeatOpt: Boolean; maxTileSize: Integer; atl, ratl: array of TGLAtlas; + currentTexture2D: GLuint; + + procedure r_Textures_GL_Bind (id: GLuint); + begin + if id <> currentTexture2D then + begin + glBindTexture(GL_TEXTURE_2D, id); + currentTexture2D := id; + end + end; (* --------- TGLAtlasNode --------- *) @@ -185,9 +193,9 @@ implementation ASSERT(n.l + x + w - 1 <= n.r); ASSERT(n.t + y + h - 1 <= n.b); ASSERT(n.id > 0); - glBindTexture(GL_TEXTURE_2D, n.id); + r_Textures_GL_Bind(n.id); glTexSubImage2D(GL_TEXTURE_2D, 0, n.l + x, n.t + y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, data); - glBindTexture(GL_TEXTURE_2D, 0); + r_Textures_GL_Bind(0); end; (* --------- TGLAtlas --------- *) @@ -221,13 +229,13 @@ implementation glGenTextures(1, @id); if id <> 0 then begin - glBindTexture(GL_TEXTURE_2D, id); + r_Textures_GL_Bind(id); 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_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); - glBindTexture(GL_TEXTURE_2D, 0); + r_Textures_GL_Bind(0); end; result := id end; @@ -472,6 +480,7 @@ implementation procedure r_Textures_Initialize; begin + currentTexture2D := 0; maxTileSize := r_Textures_GetMaxHardwareSize(); e_LogWritefln('TEXTURE SIZE: %s', [maxTileSize]); end;