summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b6da48a)
raw | patch | inline | side by side (parent: b6da48a)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 22 Feb 2023 16:28:25 +0000 (19:28 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 09:20:38 +0000 (12:20 +0300) |
index 42102bb75ad4dd8ca1f3e7e04c66b88d0e387e29..774b352d78cc6dba9605802d877a442c63eb9d52 100644 (file)
end;
procedure r_Common_DrawBackgroundImage (img: TGLTexture);
- var fw, w, h: LongInt;
+ var fw, w, h: LongInt; OldFilter: Boolean;
begin
if img <> nil then
begin
img := BackgroundTexture.id;
+ OldFilter := img.filter;
+ r_Draw_SetFilter(img, gTextureFilter);
if img.width = img.height then fw := img.width * 4 div 3 else fw := img.width; // fix aspect 4:3
r_Common_CalcAspect(fw, img.height, gScreenWidth, gScreenHeight, false, w, h);
r_Draw_Texture(img, gScreenWidth div 2 - w div 2, 0, w, h, false, 255, 255, 255, 255, false);
+ r_Draw_SetFilter(img, OldFilter);
end
end;
index f77b3471ce6f043f444d216304a14f782a2f703b..4f28d505c7da6d1f8e01db2c2fe4dbe2fe2c7cd6 100644 (file)
r_textures
;
+ procedure r_Draw_SetFilter (img: TGLTexture; enable: Boolean);
+
procedure r_Draw_Texture (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
procedure r_Draw_TextureRepeatRotate (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
r_Draw_Rect(x, y, x + w, y + h, 0, 255, 0, 255);
end;
- procedure DrawTile (tile: TGLAtlasNode; x, y, w, h: Integer; flip: Boolean; rr, gg, bb, aa: Byte; blend: Boolean);
+ procedure r_Draw_SetFilter (img: TGLTexture; enable: Boolean);
+ begin
+ ASSERT(img <> nil);
+ img.filter := enable;
+ end;
+
+ procedure DrawTile (tile: TGLAtlasNode; x, y, w, h: Integer; flip: Boolean; rr, gg, bb, aa: Byte; blend, filter: Boolean);
var nw, nh, ax, bx, ay, by: GLfloat; l, t, r, b: Integer;
begin
if tile = nil then
by := (tile.b + 1) / nh;
l := x; t := y; r := x + w; b := y + h;
r_Textures_GL_Bind(tile.id);
+ if filter <> tile.base.filter then
+ begin
+ if filter then
+ begin
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ end
+ else
+ begin
+ 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);
+ end;
+ tile.base.filter := filter;
+ end;
r_Draw_SetColor(rr, gg, bb, aa);
r_Draw_EnableTexture2D(true);
if blend then glBlendFunc(GL_SRC_ALPHA, GL_ONE) else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
repeat
n := img.GetTile(i, j);
ASSERT(n <> nil);
- DrawTile(n, 0, 0, n.width, n.height, flip, r, g, b, a, blend);
+ DrawTile(n, 0, 0, n.width, n.height, flip, r, g, b, a, blend, img.filter);
glTranslatef(n.width, 0, 0);
i := i + step;
until i = last;
index ee1c8b32a48aca7dddeb5404a3f26bb512ba0b2c..eba81403044209ce9ace6903bc3d83c22bb5850e 100644 (file)
if gDrawBackGround and (SkyTexture <> nil) then
begin
r_Map_CalcSkyParallax(cx, cy, w, h, SkyTexture.width, SkyTexture.height, gMapInfo.Width, gMapInfo.Height, sx, sy, sw, sh);
+ r_Draw_SetFilter(SkyTexture, gTextureFilter);
r_Draw_Texture(SkyTexture, sx, sy, sw, sh, false, 255, 255, 255, 255, false);
end;
index 56d2656c8c17e0e556e70e8525fc06e7e718537e..ae9d02afa6596d878453ffb7d1dc87e6f8e43485 100644 (file)
TGLAtlas = class (TAtlas)
private
mID: GLuint;
+ mFilter: Boolean;
public
constructor Create (ww, hh: Integer; id: GLuint);
function Alloc (ww, hh: Integer): TGLAtlasNode; overload;
property id: GLuint read mID write mID default 0;
+ property filter: Boolean read mFilter write mFilter;
end;
TGLTexture = class
mCols: Integer;
mTile: array of TGLAtlasNode;
mHints: TGLHintsSet;
+ mFilter: Boolean;
public
destructor Destroy; override;
property cols: Integer read mCols;
property lines: Integer read GetLines;
property hints: TGLHintsSet read mHints;
+ property filter: Boolean read mFilter write mFilter;
end;
TGLMultiTexture = class
ASSERT(hh > 0);
inherited Create(ww, hh);
self.mID := id;
+ self.mFilter := false;
end;
destructor TGLAtlas.Destroy;
t.mCols := cols;
// t.mLines := lines;
t.mHints := hints;
+ t.mFilter := false;
SetLength(t.mTile, cols * lines);
for y := 0 to lines - 1 do
begin
diff --git a/src/nogl/noGL.pas b/src/nogl/noGL.pas
index fe9601c2331645ec04916c60f03edd3ce1c1f784..5ee98a274668784093d042ab1d10ce2fccd01efa 100644 (file)
--- a/src/nogl/noGL.pas
+++ b/src/nogl/noGL.pas
GL_TEXTURE_WRAP_S = $2802;
GL_TEXTURE_WRAP_T = $2803;
GL_REPEAT = $2901;
+ GL_CLAMP_TO_EDGE = $812F;
GL_TEXTURE_MIN_FILTER = $2801;
GL_TEXTURE_MAG_FILTER = $2800;
GL_RGBA = $1908;