summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b5f0859)
raw | patch | inline | side by side (parent: b5f0859)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 9 Jun 2021 12:52:24 +0000 (15:52 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 29 Jun 2021 09:51:11 +0000 (12:51 +0300) |
index 3e578c8088d25b39612a400bded3946147606d2c..58ae4cdb44369d4bc7a7af4f7c14501aa7e1d977 100644 (file)
--- a/src/engine/e_texture.pas
+++ b/src/engine/e_texture.pas
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
-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!
-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
// 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;
+ TEXTUREFILTER: Integer;
begin
tex.width := Width;
tex.height := Height;
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
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;
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);
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;
exit;
end;
try
- result := LoadTextureImg(img, Texture, pWidth, pHeight, Fmt);
+ result := LoadTextureImg(img, Texture, pWidth, pHeight, Fmt, filter);
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;
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);
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;
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;
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;
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;
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index b18fae8ec3661e02bf699ed1b8074b2a443f92aa..4a8a26b78fa9ba58c6e91c6b9719e00680393a67 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
geom in '../shared/geom.pas',
math,
-{$INCLUDE ../nogl/noGLuses.inc}
-
{$IFDEF USE_MINIUPNPC}
miniupnpc in '../lib/miniupnpc/miniupnpc.pas',
{$ENDIF}
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 5d4093084e15df09133e9c4c70ad9146f140ba56..058726b985185b32c201368d88c38e5013bdcb01 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
implementation
uses
-{$INCLUDE ../nogl/noGLuses.inc}
{$IFDEF ENABLE_HOLMES}
g_holmes,
{$ENDIF}
MegaWAD.endpic := cfg.ReadStr('megawad', 'endpic', '');
if MegaWAD.endpic <> '' then
begin
- TEXTUREFILTER := GL_LINEAR;
s := e_GetResourcePath(WadDirs, MegaWAD.endpic, WAD);
- g_Texture_CreateWADEx('TEXTURE_endpic', s);
- TEXTUREFILTER := GL_NEAREST;
+ g_Texture_CreateWADEx('TEXTURE_endpic', s, gTextureFilter);
end;
MegaWAD.endmus := cfg.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\КОНЕЦ');
if MegaWAD.endmus <> '' then
sfsGCDisable(); // temporary disable removing of temporary volumes
try
- TEXTUREFILTER := GL_LINEAR;
- g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD+':TEXTURES\TITLE');
- g_Texture_CreateWADEx('INTER', GameWAD+':TEXTURES\INTER');
- g_Texture_CreateWADEx('ENDGAME_EN', GameWAD+':TEXTURES\ENDGAME_EN');
- g_Texture_CreateWADEx('ENDGAME_RU', GameWAD+':TEXTURES\ENDGAME_RU');
- TEXTUREFILTER := GL_NEAREST;
+ g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD+':TEXTURES\TITLE', gTextureFilter);
+ g_Texture_CreateWADEx('INTER', GameWAD+':TEXTURES\INTER', gTextureFilter);
+ g_Texture_CreateWADEx('ENDGAME_EN', GameWAD+':TEXTURES\ENDGAME_EN', gTextureFilter);
+ g_Texture_CreateWADEx('ENDGAME_RU', GameWAD+':TEXTURES\ENDGAME_RU', gTextureFilter);
LoadStdFont('STDTXT', 'STDFONT', gStdFont);
LoadFont('MENUTXT', 'MENUFONT', gMenuFont);
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index a9c986e32885092b38454fa39251b12f85931b66..3da02c2a7969c7b3dcba276fafe2e44dcce79b0e 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
implementation
uses
-{$INCLUDE ../nogl/noGLuses.inc}
{$IFDEF ENABLE_HOLMES}
g_holmes, sdlcarcass, fui_ctls, fui_wadread, fui_style, fui_gfx_gl,
{$ENDIF}
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index a6e1dabcd1e197b05ed9b19e2a1f867dae033410..5044657c85e159103a97441257852579b97c840b 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
implementation
uses
- {$INCLUDE ../nogl/noGLuses.inc}
e_input, g_main, e_log, e_texture, e_res, g_items, g_gfx, g_console,
g_weapons, g_game, g_sound, e_sound, CONFIG,
g_options, g_triggers, g_player,
begin
e_WriteLog(' Loading sky: ' + gMapInfo.SkyName, TMsgType.Notify);
g_Game_SetLoadingText(_lc[I_LOAD_SKY], 0, False);
- if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
- try
- s := e_GetResourcePath(WadDirs, gMapInfo.SkyName, g_ExtractWadName(Res));
- if g_Texture_CreateWAD(BackID, s) then
- g_Game_SetupScreenSize
- else
- g_FatalError(Format(_lc[I_GAME_ERROR_SKY], [s]))
- finally
- TEXTUREFILTER := GL_NEAREST;
- end;
+ s := e_GetResourcePath(WadDirs, gMapInfo.SkyName, g_ExtractWadName(Res));
+ if g_Texture_CreateWAD(BackID, s, gTextureFilter) then
+ g_Game_SetupScreenSize
+ else
+ g_FatalError(Format(_lc[I_GAME_ERROR_SKY], [s]))
end;
// Çàãðóçêà ìóçûêè
index 6417fa9363e9c9de5458dd57564c0017090fe997..773260fb19102e687447ceac187ff7a9f25595e5 100644 (file)
--- a/src/game/g_textures.pas
+++ b/src/game/g_textures.pas
end;
-function g_Texture_CreateWAD (var ID: LongWord; const Resource: AnsiString): Boolean;
+function g_Texture_CreateWAD (var ID: LongWord; const Resource: AnsiString; filterHint: Boolean = False): Boolean;
function g_Texture_CreateFile (var ID: LongWord; const FileName: AnsiString): Boolean;
-function g_Texture_CreateWADEx (const textureName, Resource: AnsiString): Boolean;
+function g_Texture_CreateWADEx (const textureName, Resource: AnsiString; filterHint: Boolean = False): Boolean;
function g_Texture_CreateFileEx (const textureName, FileName: AnsiString): Boolean;
function g_Texture_Get (const textureName: AnsiString; var ID: LongWord): Boolean;
function g_Texture_GetSize (const textureName: AnsiString; var w, h: Integer): Boolean; overload;
procedure DumpTextureNames ();
-function g_Texture_Light (): Integer;
-
implementation
uses
- {$INCLUDE ../nogl/noGLuses.inc}
g_game, e_log, g_basic, g_console, wadreader,
g_language, utils, xstreams;
// ////////////////////////////////////////////////////////////////////////// //
-function g_Texture_CreateWAD (var ID: LongWord; const Resource: AnsiString): Boolean;
+function g_Texture_CreateWAD (var ID: LongWord; const Resource: AnsiString; filterHint: Boolean = False): Boolean;
var
WAD: TWADFile;
FileName: AnsiString;
if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
- if e_CreateTextureMem(TextureData, ResourceLength, ID) then
+ if e_CreateTextureMem(TextureData, ResourceLength, ID, filterHint) then
result := true;
FreeMem(TextureData)
end
end;
-function g_Texture_CreateWADEx (const textureName, Resource: AnsiString): Boolean;
+function g_Texture_CreateWADEx (const textureName, Resource: AnsiString; filterHint: Boolean = False): Boolean;
var
WAD: TWADFile;
FileName: AnsiString;
if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
- result := e_CreateTextureMem(TextureData, ResourceLength, texturesArray[find_id].ID);
+ result := e_CreateTextureMem(TextureData, ResourceLength, texturesArray[find_id].ID, filterHint);
if result then
begin
e_GetTextureSize(texturesArray[find_id].ID, @texturesArray[find_id].width, @texturesArray[find_id].height);
mRevert := utils.readBool(st);
end;
-
-// ////////////////////////////////////////////////////////////////////////// //
-var
- ltexid: GLuint = 0;
-
-function g_Texture_Light (): Integer;
-const
- Radius: Integer = 128;
-var
- tex, tpp: PByte;
- x, y, a: Integer;
- dist: Double;
-begin
- if ltexid = 0 then
- begin
- GetMem(tex, (Radius*2)*(Radius*2)*4);
- tpp := tex;
- for y := 0 to Radius*2-1 do
- begin
- for x := 0 to Radius*2-1 do
- begin
- dist := 1.0-sqrt((x-Radius)*(x-Radius)+(y-Radius)*(y-Radius))/Radius;
- if (dist < 0) then
- begin
- tpp^ := 0; Inc(tpp);
- tpp^ := 0; Inc(tpp);
- tpp^ := 0; Inc(tpp);
- tpp^ := 0; Inc(tpp);
- end
- else
- begin
- //tc.setPixel(x, y, Color(cast(int)(dist*255), cast(int)(dist*255), cast(int)(dist*255)));
- if (dist > 0.5) then dist := 0.5;
- a := round(dist*255);
- if (a < 0) then a := 0 else if (a > 255) then a := 255;
- tpp^ := 255; Inc(tpp);
- tpp^ := 255; Inc(tpp);
- tpp^ := 255; Inc(tpp);
- tpp^ := Byte(a); Inc(tpp);
- end;
- end;
- end;
-
- glGenTextures(1, @ltexid);
- //if (tid == 0) assert(0, "VGL: can't create screen texture");
-
- glBindTexture(GL_TEXTURE_2D, ltexid);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- //GLfloat[4] bclr = 0.0;
- //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Radius*2, Radius*2, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
- end;
-
- result := ltexid;
-end;
-
-
end.
index 6260d48e18b0b114a422597a6ab0c21c50023d7e..8acd51b104fcd4cc973f9d1b79f23ae7fd4996f6 100644 (file)
e_AmbientQuad(sX, sY, sWidth, sHeight, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
end;
+// ////////////////////////////////////////////////////////////////////////// //
+var
+ ltexid: GLuint = 0;
+
+function g_Texture_Light (): Integer;
+const
+ Radius: Integer = 128;
+var
+ tex, tpp: PByte;
+ x, y, a: Integer;
+ dist: Double;
+begin
+ if ltexid = 0 then
+ begin
+ GetMem(tex, (Radius*2)*(Radius*2)*4);
+ tpp := tex;
+ for y := 0 to Radius*2-1 do
+ begin
+ for x := 0 to Radius*2-1 do
+ begin
+ dist := 1.0-sqrt((x-Radius)*(x-Radius)+(y-Radius)*(y-Radius))/Radius;
+ if (dist < 0) then
+ begin
+ tpp^ := 0; Inc(tpp);
+ tpp^ := 0; Inc(tpp);
+ tpp^ := 0; Inc(tpp);
+ tpp^ := 0; Inc(tpp);
+ end
+ else
+ begin
+ //tc.setPixel(x, y, Color(cast(int)(dist*255), cast(int)(dist*255), cast(int)(dist*255)));
+ if (dist > 0.5) then dist := 0.5;
+ a := round(dist*255);
+ if (a < 0) then a := 0 else if (a > 255) then a := 255;
+ tpp^ := 255; Inc(tpp);
+ tpp^ := 255; Inc(tpp);
+ tpp^ := 255; Inc(tpp);
+ tpp^ := Byte(a); Inc(tpp);
+ end;
+ end;
+ end;
+
+ glGenTextures(1, @ltexid);
+ //if (tid == 0) assert(0, "VGL: can't create screen texture");
+
+ glBindTexture(GL_TEXTURE_2D, ltexid);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ //GLfloat[4] bclr = 0.0;
+ //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Radius*2, Radius*2, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
+ end;
+
+ result := ltexid;
+end;
// setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
//FIXME: broken for splitscreen mode
index f7b7fd3e299e25af9357defbb18fe5e13da57abd..cb568b418977456013691eff26848e0c7fa01265 100644 (file)
function e_CreateTextureImg (var img: TImageData; var ID: DWORD): Boolean;
function e_CreateTexture(FileName: string; var ID: DWORD): Boolean;
function e_CreateTextureEx(FileName: string; var ID: DWORD; fX, fY, fWidth, fHeight: Word): Boolean;
-function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD): Boolean;
-function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word): Boolean;
+function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD; filter: Boolean = False): Boolean;
+function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word; filter: Boolean = False): Boolean;
procedure e_GetTextureSize(ID: DWORD; Width, Height: PWord);
procedure e_DeleteTexture(ID: DWORD);
procedure e_RemoveAllTextures();
Result := True;
end;
-function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD): Boolean;
+function e_CreateTextureMem(pData: Pointer; dataSize: LongInt; var ID: DWORD; filter: Boolean = False): Boolean;
var
find_id: DWORD;
fmt: Word;
find_id := FindTexture;
- if not LoadTextureMem(pData, dataSize, e_Textures[find_id].tx, e_Textures[find_id].tx.Width, e_Textures[find_id].tx.Height, @fmt) then exit;
+ if not LoadTextureMem(pData, dataSize, e_Textures[find_id].tx, e_Textures[find_id].tx.Width, e_Textures[find_id].tx.Height, @fmt, filter) then exit;
id := find_id;
Result := True;
end;
-function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word): Boolean;
+function e_CreateTextureMemEx(pData: Pointer; dataSize: LongInt; var ID: DWORD; fX, fY, fWidth, fHeight: Word; filter: Boolean = False): Boolean;
var
find_id: DWORD;
fmt: Word;
find_id := FindTexture();
- if not LoadTextureMemEx(pData, dataSize, e_Textures[find_id].tx, fX, fY, fWidth, fHeight, @fmt) then exit;
+ if not LoadTextureMemEx(pData, dataSize, e_Textures[find_id].tx, fX, fY, fWidth, fHeight, @fmt, filter) then exit;
ID := find_id;