Переглянути джерело

- videos with NPOT frame size now will be without lines on borders in some cases

git-svn-id: http://zengl.googlecode.com/svn/branches/0.3.x@1943 6573c10b-8653-0410-9706-d32479e959fb
dr.andru 12 роки тому
батько
коміт
8b5baa9823
2 змінених файлів з 25 додано та 5 видалено
  1. 1 1
      src/zgl_main.pas
  2. 24 4
      src/zgl_video.pas

+ 1 - 1
src/zgl_main.pas

@@ -49,7 +49,7 @@ uses
 
 const
   cs_ZenGL    = 'ZenGL 0.3.6';
-  cs_Date     = '2012.11.13';
+  cs_Date     = '2012.12.10';
   cv_major    = 0;
   cv_minor    = 3;
   cv_revision = 6;

+ 24 - 4
src/zgl_video.pas

@@ -78,7 +78,7 @@ type
     Count    : record
       Items    : Integer;
       Decoders : Integer;
-              end;
+               end;
     First    : zglTVideoStream;
     Decoders : array of zglPVideoDecoder;
   end;
@@ -169,7 +169,7 @@ begin
 
   if Result._private.Decoder.Open( Result^, FileName ) Then
     begin
-      Result.Texture := tex_CreateZero( Result.Info.Width, Result.Info.Height, $FF000000 );
+      Result.Texture := tex_CreateZero( Result.Info.Width, Result.Info.Height );
       GetMem( Result.Data, Result.Info.Width * Result.Info.Height * 4 );
       FillChar( Result.Data[ 0 ], Result.Info.Width * Result.Info.Height * 4, 255 );
       video_Update( Result, 0 );
@@ -207,7 +207,10 @@ end;
 
 procedure video_Update( var Stream : zglPVideoStream; Milliseconds : Double; Loop : Boolean = FALSE );
   var
-    frame : Integer;
+    frame  : Integer;
+    data   : PLongWordArray;
+    i      : Integer;
+    sw, sh : Integer;
 begin
   if not Assigned( Stream ) Then exit;
 
@@ -233,7 +236,24 @@ begin
   Stream._private.Decoder.Update( Stream^, Milliseconds, Stream.Data );
 
   if Stream.Frame <> frame Then
-    tex_SetData( Stream.Texture, Stream.Data, 0, 0, Stream.Info.Width, Stream.Info.Height );
+    begin
+      tex_SetData( Stream.Texture, Stream.Data, 0, 0, Stream.Info.Width, Stream.Info.Height );
+
+      // TODO: Remove it and implement via Stride in decoder
+      sw := Stream.Info.Width;
+      sh := Stream.Info.Height;
+      if sw <> u_GetPOT( sw ) Then
+        begin
+          GetMem( data, ( sh + 1 ) * 4 );
+          for i := 0 to sh - 1 do
+            data[ i ] := PLongWordArray( Stream.Data )[ ( sw - 1 ) + sw * i ];
+          data[ sh ] := data[ sh - 1 ];
+          tex_SetData( Stream.Texture, PByteArray( data ), sw, 0, 1, sh + 1 );
+          FreeMem( data );
+        end;
+      if sh <> u_GetPOT( sh ) Then
+        tex_SetData( Stream.Texture, Stream.Data, 0, sh, sw, 1 );
+    end;
 end;
 
 procedure video_Seek( var Stream : zglPVideoStream; Milliseconds : Double );