aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorbasisbit <basisbit@b956fd51-792f-4845-bead-9b4dfca2ff2c>2015-08-24 22:09:23 +0000
committerbasisbit <basisbit@b956fd51-792f-4845-bead-9b4dfca2ff2c>2015-08-24 22:09:23 +0000
commitc6fa7a7ed50fe4fcd712d2bebed31817f77b4a80 (patch)
tree089cc5ba5917f88f7551dc494f6df8c721f34266 /src/base
parent003becc3c7b7773b08a693e23932c3cd6e3a0999 (diff)
downloadusdx-c6fa7a7ed50fe4fcd712d2bebed31817f77b4a80.tar.gz
usdx-c6fa7a7ed50fe4fcd712d2bebed31817f77b4a80.tar.xz
usdx-c6fa7a7ed50fe4fcd712d2bebed31817f77b4a80.zip
* detect if OpenGL has hardware-support for GL_ARB_texture_non_power_of_two. if yes, don't resize textures => lots faster and texture image quality is a lot better.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3126 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--src/base/UTexture.pas19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/base/UTexture.pas b/src/base/UTexture.pas
index c0f0f396..d497f9be 100644
--- a/src/base/UTexture.pas
+++ b/src/base/UTexture.pas
@@ -133,6 +133,7 @@ type
var
Texture: TTextureUnit;
TextureDatabase: TTextureDatabase;
+ SupportsNPOT: Boolean;
implementation
uses
@@ -217,6 +218,11 @@ constructor TTextureUnit.Create;
begin
inherited Create;
TextureDatabase := TTextureDatabase.Create;
+ Log.LogInfo('OpenGL vendor ' + glGetString(GL_VENDOR), 'TTextureUnit.Create');
+ Log.LogInfo('OpenGL renderer ' + glGetString(GL_RENDERER), 'TTextureUnit.Create');
+ Log.LogInfo('OpenGL version ' + glGetString(GL_VERSION), 'TTextureUnit.Create');
+ SupportsNPOT := AnsiContainsStr(glGetString(GL_EXTENSIONS),'texture_non_power_of_two');
+ Log.LogInfo('OpenGL TextureNPOT-support: ' + BoolToStr(SupportsNPOT), 'TTextureUnit.Create');
end;
destructor TTextureUnit.Destroy;
@@ -283,11 +289,14 @@ begin
oldWidth := newWidth;
oldHeight := newHeight;
- // make texture dimensions be powers of 2
- newWidth := Round(Power(2, Ceil(Log2(newWidth))));
- newHeight := Round(Power(2, Ceil(Log2(newHeight))));
- if (newHeight <> oldHeight) or (newWidth <> oldWidth) then
- FitImage(TexSurface, newWidth, newHeight);
+ if (SupportsNPOT = false) then
+ begin
+ // make texture dimensions be powers of 2
+ newWidth := Round(Power(2, Ceil(Log2(newWidth))));
+ newHeight := Round(Power(2, Ceil(Log2(newHeight))));
+ if (newHeight <> oldHeight) or (newWidth <> oldWidth) then
+ FitImage(TexSurface, newWidth, newHeight);
+ end;
// at this point we have the image in memory...
// scaled so that dimensions are powers of 2