Browse Source

[OpenGL]fixed problem with Ctrl+Alt+Delete and message "Cannot set fullscreen mode"\
fixed crash when cannot load some resources using res_* functions

git-svn-id: http://zengl.googlecode.com/svn/branches/0.3.x@1890 6573c10b-8653-0410-9706-d32479e959fb

dr.andru 13 years ago
parent
commit
8c7a3f8a28
7 changed files with 34 additions and 31 deletions
  1. 1 1
      headers/zglHeader.h
  2. 4 4
      headers/zglHeader.pas
  3. 6 3
      src/zgl_application.pas
  4. 1 1
      src/zgl_main.pas
  5. 18 18
      src/zgl_resources.pas
  6. 1 1
      src/zgl_sound.pas
  7. 3 3
      src/zgl_types.pas

+ 1 - 1
headers/zglHeader.h

@@ -3,7 +3,7 @@
 /*--------------------------------*/
 /*                                */
 /* version:  0.3.1                */
-/* date:     2012.08.12           */
+/* date:     2012.08.26           */
 /* license:  GNU LGPL version 3   */
 /* homepage: http://zengl.org     */
 /*                                */

+ 4 - 4
headers/zglHeader.pas

@@ -3,7 +3,7 @@
 {--------------------------------}
 {                                }
 { version:  0.3.1                }
-{ date:     2012.08.12           }
+{ date:     2012.08.26           }
 { license:  GNU LGPL version 3   }
 { homepage: http://zengl.org     }
 {                                }
@@ -64,11 +64,11 @@ type
   {$ENDIF}
 
   PByteArray     = ^TByteArray;
-  TByteArray     = array[ 0..65535 ] of Byte;
+  TByteArray     = array[ 0..High(LongWord) shr 1 - 1 ] of Byte;
   PWordArray     = ^TWordArray;
-  TWordArray     = array[ 0..32767 ] of Word;
+  TWordArray     = array[ 0..High(LongWord) shr 2 - 1 ] of Word;
   PLongWordArray = ^TLongWordArray;
-  TLongWordArray = array[ 0..16383 ] of LongWord;
+  TLongWordArray = array[ 0..High(LongWord) shr 3 - 1 ] of LongWord;
 
 type
   zglTStringList = record

+ 6 - 3
src/zgl_application.pas

@@ -273,7 +273,7 @@ begin
 
       t := timer_GetTicks();
       {$IFDEF WINDESKTOP}
-      // Workaround for bug with unstable time between frames...
+      // Workaround for a bug with unstable time between frames(happens when videocard trying to reclock GPU frequency/etc.)...
       if Assigned( app_PUpdate ) and ( scrVSync ) and ( appFPS > 0 ) and ( appFPS = scrRefresh ) and ( appFlags and APP_USE_DT_CORRECTION > 0 ) Then
         app_PUpdate( 1000 / appFPS )
       else
@@ -639,6 +639,11 @@ begin
         if not wndFullScreen Then
           wnd_Update();
       end;
+    WM_SETFOCUS:
+      begin
+        if ( wndFullScreen ) and ( not wndFirst ) Then
+          scr_SetOptions( scrWidth, scrHeight, scrRefresh, wndFullScreen, scrVSync );
+      end;
     WM_ACTIVATEAPP:
       begin
         if appMinimized Then exit;
@@ -652,8 +657,6 @@ begin
             key_ClearState();
             FillChar( mouseDown[ 0 ], 3, 0 );
             mouse_ClearState();
-            if ( wndFullScreen ) and ( not wndFirst ) Then
-              scr_SetOptions( scrWidth, scrHeight, scrRefresh, wndFullScreen, scrVSync );
           end else
             if ( wParam = 0 ) and ( appFocus ) Then
               begin

+ 1 - 1
src/zgl_main.pas

@@ -46,7 +46,7 @@ uses
 
 const
   cs_ZenGL    = 'ZenGL 0.3.1';
-  cs_Date     = '2012.08.12';
+  cs_Date     = '2012.08.26';
   cv_major    = 0;
   cv_minor    = 3;
   cv_revision = 1;

+ 18 - 18
src/zgl_resources.pas

@@ -501,15 +501,9 @@ begin
                     if IsFromFile Then
                       begin
                         if not file_Exists( FileName ) Then
-                          begin
-                            log_Add( 'Cannot read "' + FileName + '"' );
-
-                            FileName := '';
-                            FreeMem( Resource );
-                            Resource := nil;
-                            DEC( resQueueSize[ id ] );
-                          end else
-                            FileLoader( FileName, pData, Width, Height, Format )
+                          log_Add( 'Cannot read "' + FileName + '"' )
+                        else
+                          FileLoader( FileName, pData, Width, Height, Format )
                       end else
                         begin
                           FileName := 'From Memory';
@@ -520,6 +514,18 @@ begin
                       begin
                         log_Add( 'Unable to load texture: "' + FileName + '"' );
 
+                        // FIXME: Temporary solution, change in future
+                        Texture.ID     := managerZeroTexture.ID;
+                        Texture.Width  := managerZeroTexture.Width;
+                        Texture.Height := managerZeroTexture.Height;
+                        Texture.Format := managerZeroTexture.Format;
+                        Texture.U      := managerZeroTexture.U;
+                        Texture.V      := managerZeroTexture.V;
+                        SetLength( Texture.FramesCoord, Length( managerZeroTexture.FramesCoord ) );
+                        for i := 0 to High( managerZeroTexture.FramesCoord ) do
+                          Texture.FramesCoord[ i ] := managerZeroTexture.FramesCoord[ i ];
+                        Texture.Flags  := managerZeroTexture.Flags;
+
                         FileName := '';
                         FreeMem( Resource );
                         Resource := nil;
@@ -655,15 +661,9 @@ begin
                     if IsFromFile Then
                       begin
                         if not file_Exists( FileName ) Then
-                          begin
-                            log_Add( 'Cannot read "' + FileName + '"' );
-
-                            FileName := '';
-                            FreeMem( Resource );
-                            Resource := nil;
-                            DEC( resQueueSize[ id ] );
-                          end else
-                            FileLoader( FileName, Sound.Data, Sound.Size, Format, Sound.Frequency )
+                          log_Add( 'Cannot read "' + FileName + '"' )
+                        else
+                          FileLoader( FileName, Sound.Data, Sound.Size, Format, Sound.Frequency )
                       end else
                         begin
                           FileName := 'From Memory';

+ 1 - 1
src/zgl_sound.pas

@@ -214,7 +214,7 @@ const
 
 var
   sndAutoPaused : Boolean;
-  sndVolume     : Single  = 1;
+  sndVolume     : Single = 1;
   sfVolume      : Single = 1;
 
   sfStream    : array[ 1..SND_MAX ] of zglTSoundStream;

+ 3 - 3
src/zgl_types.pas

@@ -33,11 +33,11 @@ type
   Ptr = {$IFDEF CPU64} QWORD {$ELSE} LongWord {$ENDIF};
 
   PByteArray     = ^TByteArray;
-  TByteArray     = array[ 0..65535 ] of Byte;
+  TByteArray     = array[ 0..High(LongWord) shr 1 - 1 ] of Byte;
   PWordArray     = ^TWordArray;
-  TWordArray     = array[ 0..32767 ] of Word;
+  TWordArray     = array[ 0..High(LongWord) shr 2 - 1 ] of Word;
   PLongWordArray = ^TLongWordArray;
-  TLongWordArray = array[ 0..16383 ] of LongWord;
+  TLongWordArray = array[ 0..High(LongWord) shr 3 - 1 ] of LongWord;
 
 type
   zglPTexCoordIndex = ^zglTTexCoordIndex;