index 34b5b9e7027c8863ad32a0777d22297047fb5dc2..1025abad5f29d73540ecd541e33b28903fe52efe 100644 (file)
function r_Textures_LoadFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
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
implementation
uses
r_GL_RepeatOpt: Boolean;
maxTileSize: Integer;
atl, ratl: array of TGLAtlas;
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 --------- *)
(* --------- TGLAtlasNode --------- *)
ASSERT(n.l + x + w - 1 <= n.r);
ASSERT(n.t + y + h - 1 <= n.b);
ASSERT(n.id > 0);
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);
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 --------- *)
end;
(* --------- TGLAtlas --------- *)
glGenTextures(1, @id);
if id <> 0 then
begin
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);
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;
end;
result := id
end;
procedure r_Textures_Initialize;
begin
procedure r_Textures_Initialize;
begin
+ currentTexture2D := 0;
maxTileSize := r_Textures_GetMaxHardwareSize();
e_LogWritefln('TEXTURE SIZE: %s', [maxTileSize]);
end;
maxTileSize := r_Textures_GetMaxHardwareSize();
e_LogWritefln('TEXTURE SIZE: %s', [maxTileSize]);
end;