index 3e578c8088d25b39612a400bded3946147606d2c..58ae4cdb44369d4bc7a7af4f7c14501aa7e1d977 100644 (file)
--- a/src/engine/e_texture.pas
+++ b/src/engine/e_texture.pas
var
e_DummyTextures: Boolean = False;
var
e_DummyTextures: Boolean = False;
- TEXTUREFILTER: Integer = GL_NEAREST;
-function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer): Boolean;
+function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer; filter: Boolean = False): Boolean;
// Standard set of images loading functions
// Standard set of images loading functions
-function LoadTexture (Filename: String; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil): Boolean;
-function LoadTextureEx (Filename: String; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil): Boolean;
-function LoadTextureMem (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil): Boolean;
-function LoadTextureMemEx (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTexture (Filename: String; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
+function LoadTextureEx (Filename: String; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
+function LoadTextureMem (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
+function LoadTextureMemEx (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
// `img` must be valid!
// `img` must be valid!
-function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
implementation
implementation
// This is auxiliary function that creates OpenGL texture from raw image data
// This is auxiliary function that creates OpenGL texture from raw image data
-function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer): Boolean;
+function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer; filter: Boolean = False): Boolean;
var
Texture: GLuint;
fmt: GLenum;
//buf: PByte;
//f, c: Integer;
var
Texture: GLuint;
fmt: GLenum;
//buf: PByte;
//f, c: Integer;
+ TEXTUREFILTER: Integer;
begin
tex.width := Width;
tex.height := Height;
begin
tex.width := Width;
tex.height := Height;
GL_LINEAR_MIPMAP_LINEAR - BiLinear Mipmapped texture
}
GL_LINEAR_MIPMAP_LINEAR - BiLinear Mipmapped texture
}
+ if filter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
+
// for GL_TEXTURE_MAG_FILTER only first two can be used
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TEXTUREFILTER);
// for GL_TEXTURE_MIN_FILTER all of the above can be used
// for GL_TEXTURE_MAG_FILTER only first two can be used
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TEXTUREFILTER);
// for GL_TEXTURE_MIN_FILTER all of the above can be used
end;
// `img` must be valid!
end;
// `img` must be valid!
-function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
var
image, ii: PByte;
width, height: Integer;
var
image, ii: PByte;
width, height: Integer;
ii^ := clr.a; Inc(ii);
end;
end;
ii^ := clr.a; Inc(ii);
end;
end;
- CreateTexture(Texture, width, height, GL_RGBA, image);
+ CreateTexture(Texture, width, height, GL_RGBA, image, filter);
result := true;
finally
FreeMem(image);
result := true;
finally
FreeMem(image);
end;
end;
-function LoadTextureMem (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTextureMem (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
var
//image, ii: PByte;
//width, height: Integer;
var
//image, ii: PByte;
//width, height: Integer;
exit;
end;
try
exit;
end;
try
- result := LoadTextureImg(img, Texture, pWidth, pHeight, Fmt);
+ result := LoadTextureImg(img, Texture, pWidth, pHeight, Fmt, filter);
finally
FreeImage(img);
end;
end;
finally
FreeImage(img);
end;
end;
-function LoadTextureMemEx (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTextureMemEx (pData: Pointer; dataSize: LongInt; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
var
image, ii: PByte;
//width, height: Integer;
var
image, ii: PByte;
//width, height: Integer;
ii^ := clr.a; Inc(ii);
end;
end;
ii^ := clr.a; Inc(ii);
end;
end;
- CreateTexture(Texture, fWidth, fHeight, GL_RGBA, image);
+ CreateTexture(Texture, fWidth, fHeight, GL_RGBA, image, filter);
result := true;
finally
FreeMem(image);
result := true;
finally
FreeMem(image);
end;
end;
-function LoadTexture (filename: AnsiString; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTexture (filename: AnsiString; var Texture: GLTexture; var pWidth, pHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
var
fs: TStream;
img: Pointer;
var
fs: TStream;
img: Pointer;
GetMem(img, imageSize);
try
fs.readBuffer(img^, imageSize);
GetMem(img, imageSize);
try
fs.readBuffer(img^, imageSize);
- result := LoadTextureMem(img, imageSize, Texture, pWidth, pHeight, Fmt);
+ result := LoadTextureMem(img, imageSize, Texture, pWidth, pHeight, Fmt, filter);
finally
FreeMem(img);
end;
finally
FreeMem(img);
end;
end;
end;
-function LoadTextureEx (filename: AnsiString; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil): Boolean;
+function LoadTextureEx (filename: AnsiString; var Texture: GLTexture; fX, fY, fWidth, fHeight: Word; Fmt: PWord=nil; filter: Boolean = False): Boolean;
var
fs: TStream;
img: Pointer;
var
fs: TStream;
img: Pointer;
GetMem(img, imageSize);
try
fs.readBuffer(img^, imageSize);
GetMem(img, imageSize);
try
fs.readBuffer(img^, imageSize);
- result := LoadTextureMemEx(img, imageSize, Texture, fX, fY, fWidth, fHeight, Fmt);
+ result := LoadTextureMemEx(img, imageSize, Texture, fX, fY, fWidth, fHeight, Fmt, filter);
finally
FreeMem(img);
end;
finally
FreeMem(img);
end;