summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd18843)
raw | patch | inline | side by side (parent: fd18843)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 7 Apr 2016 03:25:22 +0000 (06:25 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 7 Apr 2016 03:26:00 +0000 (06:26 +0300) |
src/engine/e_textures.pas | patch | blob | history | |
src/game/g_language.pas | patch | blob | history | |
src/game/g_menu.pas | patch | blob | history | |
src/game/g_options.pas | patch | blob | history |
index af38f3c3c2e7d7948b5f0439eef28ba94f1b97de..e7bcbcf99e89db1f8cd72da1bb77423ea1bde9fd 100644 (file)
end;
var
- fUseMipmaps: Boolean = False;
TEXTUREFILTER: Integer = GL_NEAREST;
-function CreateTexture(var tex: GLTexture; Width, Height, Format: Word; pData: Pointer ): Boolean;
+function CreateTexture(var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer ): Boolean;
// Standard set of images loading functions
function LoadTexture( Filename: String; var Texture: GLTexture;
implementation
-uses BinEditor;
+uses BinEditor, g_options;
function AlignP2 (n: Word): Word;
end;
// This is auxiliary function that creates OpenGL texture from raw image data
-function CreateTexture (var tex: GLTexture; Width, Height, Format: Word; pData: Pointer): Boolean;
+function CreateTexture (var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer): Boolean;
var
Texture: GLuint;
begin
tex.width := Width;
tex.height := Height;
- tex.glwidth := AlignP2(Width);
- tex.glheight := AlignP2(Height);
- if (tex.glwidth = tex.glwidth) and (tex.glheight = tex.height) then
+ if glLegacyNPOT then
begin
- tex.u := 1;
- tex.v := 1;
+ tex.glwidth := AlignP2(Width);
+ tex.glheight := AlignP2(Height);
end
else
begin
- tex.u := (tex.width+0.0)/(tex.glwidth+0.0);
- tex.v := (tex.height+0.0)/(tex.height+0.0);
+ tex.glwidth := Width;
+ tex.glheight := Height;
+ end;
+ tex.u := 1;
+ tex.v := 1;
+ if tex.glwidth <> tex.width then tex.u := (tex.width+0.0)/(tex.glwidth+0.0);
+ if tex.glheight <> tex.height then tex.v := (tex.height+0.0)/(tex.glheight+0.0);
+
+ if (tex.glwidth <> tex.width) or (tex.glheight <> tex.height) then
+ begin
+ e_WriteLog(Format('NPOT: orig is %ux%u; gl is %ux%u; u=%f; v=%f', [Width, Height, tex.glwidth, tex.glheight, tex.u, tex.v]), MSG_NOTIFY);
end;
glGenTextures(1, @Texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TEXTUREFILTER);
// create empty texture
- if Format = GL_RGBA then
+ if aFormat = GL_RGBA then
begin
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.glwidth, tex.glheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, tex.glheight-Height, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, pData);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, pData);
end
else
begin
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex.glwidth, tex.glheight, 0, GL_RGB, GL_UNSIGNED_BYTE, nil);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, tex.glheight-Height, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, pData);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, pData);
end;
// the following is ok too
{
if (tex.glwidth = tex.glwidth) and (tex.glheight = tex.height) then
// easy case
- if Format = GL_RGBA then
+ if aFormat = GL_RGBA then
begin
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pData);
end
index b1513f1517d1e398c2f1a6406dfbf8e91da4d921..dbeb7d0efeafd34f3ec39a6d435f87cf72224553 100644 (file)
--- a/src/game/g_language.pas
+++ b/src/game/g_language.pas
I_MENU_VIDEO_BPP,
I_MENU_VIDEO_VSYNC,
I_MENU_VIDEO_FILTER_SKY,
+ I_MENU_VIDEO_LEGACY_COMPATIBLE,
I_MENU_VIDEO_NEED_RESTART,
I_MENU_RESOLUTION_SELECT,
'Âåðò. ñèíõðîíèçàöèÿ:'),
('MENU VIDEO FILTER SKY', 'Anisotropic sky',
'Ôèëüòðàöèÿ íåáà:'),
+ ('MENU VIDEO LEGACY COMPATIBLE', 'Compatibility with NPOT textures:',
+ 'Ñîâìåñòèìîñòü ñ NPOT-òåêñòóðàìè:'),
('MENU VIDEO NEED RESTART', 'Video settings will be changed after game restart.',
'Äàííûå íàñòðîéêè âèäåî âñòóïÿò â ñèëó ïîñëå ïåðåçàïóñêà èãðû.'),
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index 5c0452e464d9a2cbacec39794ed00767a04a1f28..0ac36062c5aff28f8a8174da449069e367ee87d3 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
gBPP := 32;
gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
+ glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
with TGUISwitch(menu.GetControl('swVSync')) do
if gVSync then ItemIndex := 0 else ItemIndex := 1;
+ with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
+ if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1;
+
menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
AddItem(_lc[I_MENU_YES]);
AddItem(_lc[I_MENU_NO]);
end;
+ with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
+ begin
+ Name := 'swLegacyNPOT';
+ AddItem(_lc[I_MENU_NO]);
+ AddItem(_lc[I_MENU_YES]);
+ end;
AddSpace();
AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
ReAlign();
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index fab30284a197d776eb4908364ff89ea9e618631c..f6ffc77ee61f09caa8d911249fe063b7198389c8 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
gFullscreen: Boolean = False;
gWinMaximized: Boolean = False;
gVSync: Boolean = False;
+ glLegacyNPOT: Boolean = False;
gTextureFilter: Boolean = True;
gNoSound: Boolean = False;
gSoundLevel: Byte = 75;
gBPP := 32;
gVSync := False;
gTextureFilter := True;
- fUseMipmaps := False;
+ glLegacyNPOT := False;
Exit;
end;
gFreq := config.ReadInt('Video', 'Freq', 0);
gVSync := config.ReadBool('Video', 'VSync', True);
gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
- fUseMipmaps := config.ReadBool('Video', 'LegacyCompatible', False);
+ glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
gNoSound := config.ReadBool('Sound', 'NoSound', False);
gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
config.WriteInt('Video', 'BPP', gBPP);
config.WriteBool('Video', 'VSync', gVSync);
config.WriteBool('Video', 'TextureFilter', gTextureFilter);
- config.WriteBool('Video', 'LegacyCompatible', fUseMipmaps);
+ config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
config.WriteBool('Sound', 'NoSound', gNoSound);
config.WriteInt('Sound', 'SoundLevel', gSoundLevel);