From 6ff85ad711a5ff263563ea3fa922a7206235cae3 Mon Sep 17 00:00:00 2001 From: basisbit Date: Fri, 4 Sep 2015 20:18:28 +0000 Subject: * if NPOT is supported by the graphics card driver, do not manually resize videos and textures to a power of 2 with and hight. This slightly improves image quality because of less resizing (OpenGL handles this better anyways) and is a minor performance improvement on systems that support OpenGL 2.x or newer. * please test this release and report bugs in the sourceforge forum or preferably our IRC channel git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3129 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/media/UVideo.pas | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/media') diff --git a/src/media/UVideo.pas b/src/media/UVideo.pas index e6019827..7a3d066b 100644 --- a/src/media/UVideo.pas +++ b/src/media/UVideo.pas @@ -67,6 +67,7 @@ uses glu, glext, textgl, + StrUtils, UMediaCore_FFmpeg, UCommon, UConfig, @@ -237,6 +238,7 @@ type var FFmpegCore: TMediaCore_FFmpeg; + SupportsNPOT: Boolean; // These are called whenever we allocate a frame buffer. @@ -310,6 +312,7 @@ end; constructor TVideo_FFmpeg.Create; begin glGenTextures(1, PGLuint(@fFrameTex)); + SupportsNPOT := AnsiContainsStr(glGetString(GL_EXTENSIONS),'texture_non_power_of_two'); Reset(); end; @@ -494,8 +497,17 @@ begin end; {$ENDIF} - fTexWidth := Round(Power(2, Ceil(Log2(fCodecContext^.width)))); - fTexHeight := Round(Power(2, Ceil(Log2(fCodecContext^.height)))); + if (SupportsNPOT = false) then + begin + fTexWidth := Round(Power(2, Ceil(Log2(fCodecContext^.width)))); + fTexHeight := Round(Power(2, Ceil(Log2(fCodecContext^.height)))); + end + else + begin + fTexWidth := fCodecContext^.width; + fTexHeight := fCodecContext^.height; + end; + if (fPboEnabled) then begin @@ -523,7 +535,7 @@ begin glBindTexture(GL_TEXTURE_2D, fFrameTex); glTexImage2D(GL_TEXTURE_2D, 0, 3, fTexWidth, fTexHeight, 0, PIXEL_FMT_OPENGL, GL_UNSIGNED_BYTE, nil); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); fOpened := true; -- cgit v1.2.3