index 062f76bdcebe373f1ecc231c88ba127b7724d476..0114880088cc352459cfd7911021c99978f2d85f 100644 (file)
TGLMultiTexture = class
private
mTexture: array of TGLTexture;
- mBackanim: Boolean;
public
destructor Destroy; override;
property width: Integer read GetWidth;
property height: Integer read GetHeight;
property count: Integer read GetCount;
- property backAnim: Boolean read mBackanim; (* this property must be located at TAnimState? *)
end;
TGLTextureArray = array of TGLTexture;
function r_Textures_LoadFromFile (const filename: AnsiString; log: Boolean = True): TGLTexture;
function r_Textures_LoadMultiFromFile (const filename: AnsiString; log: Boolean = True): TGLMultiTexture;
- function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; backanim: Boolean; log: Boolean = True): TGLMultiTexture;
+ function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
function r_Textures_LoadMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; log: Boolean = True): TGLMultiTexture;
function r_Textures_LoadStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; log: Boolean = True): Boolean;
uses
SysUtils, Classes,
e_log, e_res, WADReader, Config,
+ g_console, // cvar declaration
Imaging, ImagingTypes, ImagingUtility
;
var
+ r_GL_MaxTexSize: WORD;
maxTileSize: Integer;
atl: array of TGLAtlas;
(* --------- Init / Fin --------- *)
+ function IsPOT (v: LongWord): Boolean;
+ begin
+ result := (v <> 0) and ((v and (v - 1)) = 0)
+ end;
+
+ function NextPOT (v: LongWord): LongWord;
+ begin
+ DEC(v);
+ v := v or (v >> 1);
+ v := v or (v >> 2);
+ v := v or (v >> 4);
+ v := v or (v >> 8);
+ v := v or (v >> 16);
+ INC(v);
+ result := v;
+ end;
+
function r_Textures_GetMaxHardwareSize (): Integer;
var size: GLint = 0;
begin
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, @size);
- if size < 64 then size := 64;
- //if size > 512 then size := 512;
- //size := 64; // !!!
+ if r_GL_MaxTexSize <= 0 then
+ begin
+ // auto, max possible reccomended by driver
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, @size);
+ if size < 1 then size := 64;
+ end
+ else
+ begin
+ // selected by user
+ if IsPOT(r_GL_MaxTexSize) then
+ size := r_GL_MaxTexSize
+ else
+ size := NextPOT(r_GL_MaxTexSize);
+ end;
result := size;
end;
procedure r_Textures_Initialize;
begin
maxTileSize := r_Textures_GetMaxHardwareSize();
+ e_LogWritefln('TEXTURE SIZE: %s', [maxTileSize]);
end;
procedure r_Textures_Finalize;
end
end;
- function r_Textures_LoadMultiFromImageAndInfo (var img: TImageData; w, h, c: Integer; b: Boolean): TGLMultiTexture;
+ function r_Textures_LoadMultiFromImageAndInfo (var img: TImageData; w, h, c: Integer): TGLMultiTexture;
var t: TImageData; a: array of TGLTexture; i: Integer; m: TGLMultiTexture;
begin
ASSERT(w >= 0);
end;
m := TGLMultiTexture.Create();
m.mTexture := a;
- m.mBackanim := b;
ASSERT(m.mTexture <> nil);
result := m;
end;
- function r_Textures_LoadMultiFromDataAndInfo (data: Pointer; size: LongInt; w, h, c: Integer; b: Boolean): TGLMultiTexture;
+ function r_Textures_LoadMultiFromDataAndInfo (data: Pointer; size: LongInt; w, h, c: Integer): TGLMultiTexture;
var img: TImageData;
begin
ASSERT(w > 0);
try
if LoadImageFromMemory(data, size, img) then
if r_Textures_FixImageData(img) then
- result := r_Textures_LoadMultiFromImageAndInfo(img, w, h, c, b)
+ result := r_Textures_LoadMultiFromImageAndInfo(img, w, h, c)
except
end;
FreeImage(img);
try
if LoadImageFromMemory(data, size, img) then
if r_Textures_FixImageData(img) then
- result := r_Textures_LoadMultiFromImageAndInfo(img, txt.w, txt.h, txt.anim.frames, txt.anim.back);
+ result := r_Textures_LoadMultiFromImageAndInfo(img, txt.w, txt.h, txt.anim.frames);
finally
FreeMem(data);
end;
m := TGLMultiTexture.Create();
SetLength(m.mTexture, 1);
m.mTexture[0] := t;
- m.mBackanim := false;
txt.name := '';
txt.w := m.width;
txt.h := m.height;
result := r_Textures_LoadMultiTextFromFile(filename, txt, log);
end;
- function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; backanim: Boolean; log: Boolean = True): TGLMultiTexture;
+ function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
var wad: TWADFile; wadName, resName: AnsiString; data: Pointer; size: Integer;
begin
ASSERT(w > 0);
resName := g_ExtractFilePathName(filename);
if wad.GetResource(resName, data, size, log) then
begin
- result := r_Textures_LoadMultiFromDataAndInfo(data, size, w, h, count, backanim);
+ result := r_Textures_LoadMultiFromDataAndInfo(data, size, w, h, count);
FreeMem(data);
end;
wad.Free
result := self.info.kern;
end;
+initialization
+ conRegVar('r_gl_maxtexsize', @r_GL_MaxTexSize, '', '');
+ r_GL_MaxTexSize := 0; // default is automatic value
end.