Jelajahi Sumber

Fixed shaders and assets

GLScene 2 tahun lalu
induk
melakukan
e75ac55fc4

+ 2 - 2
Examples/Demos/cgshaders/CloudSky/fCloudSkyD.pas

@@ -24,15 +24,15 @@ uses
   GLS.VectorGeometry,
   GLS.SkyDome,
   GLS.Texture,
-  CG.Shader,
   GLS.FileTGA,
   GLS.Keyboard,
   GLS.Material,
   GLS.Coordinates,
   GLS.BaseClasses,
   GLS.Utils,
+  GLS.SimpleNavigation,
 
-  GLS.SimpleNavigation;
+  Cg.Shader;
 
 type
 

+ 4 - 4
Source/CUDA.Compiler.pas

@@ -4,9 +4,8 @@
 unit CUDA.Compiler;
 
 (*
-  Component allows to compile the CUDA-source (*.cu) file.
-  in design- and runtime.
-  To work requires the presence of CUDA Toolkit 3.X and MS Visual Studio C++.
+  Component allows to compile the CUDA-source (*.cu) file in design- and runtime.
+  To work requires the presence of CUDA Toolkit 4.X and MS Visual Studio C++.
 *)
 
 interface
@@ -18,6 +17,7 @@ uses
   System.UITypes,
   System.SysUtils,
   System.Classes,
+
   Vcl.Forms,
   VCL.Dialogs,
 
@@ -143,7 +143,7 @@ begin
     if FileExists(path + 'nvcc.exe') then
       FNVCCPath := path;
   end;
-  path := 'C:\Program Files\Microsoft Visual Studio 2015\VC\bin\';
+  path := 'C:\Program Files\Microsoft Visual Studio 2019\VC\bin\'; // check path for current VC
   if FileExists(path + 'cl.exe') then
     FCppCompilerPath := path
   else

+ 3 - 5
Source/CUDA.Context.pas

@@ -40,7 +40,6 @@ type
       write SetMaxDimComponent;
     property ReadOnlyValue: Boolean read FReadOnly write FReadOnly;
   published
-    { Published Properties }
     property SizeX: Integer index 0 read GetDimComponent write SetDimComponent
       default 1;
     property SizeY: Integer index 1 read GetDimComponent write SetDimComponent
@@ -68,8 +67,8 @@ type
     constructor Create; reintroduce;
     destructor Destroy; override;
     procedure Assign(Source: TPersistent); override;
-    {  Returns in bytes the total amount of memory
-      available on the device dev in bytes. }
+    (*  Returns in bytes the total amount of memory
+      available on the device dev in bytes. *)
     function TotalMemory: Cardinal;
   published
     property Name: string read GetName;
@@ -298,8 +297,7 @@ begin
       cuDeviceGetAttribute(@fDeviceProperties.TextureAlignment, CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT, fHandle);
       cuDeviceGetAttribute(@fDeviceProperties.DeviceOverlap, CU_DEVICE_ATTRIBUTE_GPU_OVERLAP, fHandle);
       cuDeviceGetAttribute(@fDeviceProperties.DeviceOverlap, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, fHandle);
-      fGFlops := fDeviceProperties.MultiProcessorCount *
-        fDeviceProperties.ClockRate;
+      fGFlops := fDeviceProperties.MultiProcessorCount * fDeviceProperties.ClockRate;
       fMaxThreadsDim.FXYZ[0] := fDeviceProperties.MaxThreadsDim[0];
       fMaxThreadsDim.FXYZ[1] := fDeviceProperties.MaxThreadsDim[1];
       fMaxThreadsDim.FXYZ[2] := fDeviceProperties.MaxThreadsDim[2];

+ 2 - 0
Source/CUDA.Graphics.pas

@@ -79,6 +79,8 @@ type
   TFeedBackMeshPrimitive = (fbmpPoint, fbmpLine, fbmpTriangle);
   TFeedBackMeshLaunching = (fblCommon, fblOnePerAtttribute);
 
+  //====================================================
+
   TCUDACustomFeedBackMesh = class(TGLBaseSceneObject)
   private
     FGeometryResource: TCUDAGraphicResource;

+ 1 - 1
Source/Cg.Register.pas

@@ -19,7 +19,7 @@ uses
 
   Cg.Import,
   Cg.GL,
-  GLS.SceneRegister,  // TGLLibMaterialNameProperty
+  GLS.SceneRegister,  // using TGLLibMaterialNameProperty
   Cg.Shader,
   Cg.BombShader;
 

+ 1 - 1
Source/FMX/CGx.BombShader.pas

@@ -22,7 +22,7 @@ uses
   GLX.TextureFormat,
   GLX.State,
 
-  CGx.GL,
+  CG.GL,
   CGx.Shader;
 
 type

+ 2 - 2
Source/FMX/CGx.PostTransformationShader.pas

@@ -24,8 +24,8 @@ uses
 
   GLSLx.CustomShader,
 
-  CGx.Import,
-  CGx.GL,
+  Cg.GL,
+  Cg.Import,
   CGx.Shader;
 
 type

+ 2 - 3
Source/FMX/CGx.Shader.pas

@@ -25,10 +25,9 @@ uses
   GLX.Material,
   GLX.TextureFormat,
 
-  CGx.Import,
-  CGx.GL;
+  CG.Import,
+  CG.GL;
 
-{.$I GLXcene.inc}
 { .$DEFINE OutputCompilerWarnings }
 
 (* Define OutputCompilerWarnings to output CG compiler warnings to a file. Useful

+ 6 - 5
Source/FMX/CUDAx.API.pas

@@ -21,13 +21,14 @@ uses
   GLX.Context,
   GLX.Graphics,
 
-  CUDAx.Import,
-  CUDAx.Runtime,
-  CUDAx.Parser,
-  CUDAx.FourierTransform,
+  CUDA.Import,
+  CUDA.Runtime,
+  CUDA.Parser,
+  CUDA.FourierTransform,
+  CUDA.DataAccess,
+
   CUDAx.Compiler,
   CUDAx.Context,
-  CUDAx.DataAccess,
 
   GLX.Utils;
 

+ 1 - 1
Source/FMX/CUDAx.Compiler.pas

@@ -22,7 +22,7 @@ uses
 
   GLX.ApplicationFileIO,
   GLX.Strings,
-  CUDAx.Parser;
+  CUDA.Parser;
 
 type
   TgxSCUDACompilerOutput = (codeUndefined, codePtx, codeCubin, codeGpu);

+ 4 - 3
Source/FMX/CUDAx.Context.pas

@@ -5,18 +5,19 @@ unit CUDAx.Context;
 
 interface
 
-{$I GLX.Scene.inc}
+{.$I GLX.Scene.inc}
 
 uses
   System.Classes,
   System.SysUtils,
   FMX.Dialogs,
 
+  CUDA.Import,
+  CUDA.RunTime,
+
   GLX.Strings,
   GLX.Generics,
   GLX.BaseClasses,
-  CUDAx.Import,
-  CUDAx.RunTime,
   GLX.Context;
 
 type

+ 4 - 3
Source/FMX/CUDAx.FFTPlan.pas

@@ -5,17 +5,18 @@ unit CUDAx.FFTPlan;
 
 interface
 
-{$I GLX.Scene.inc}
+{.$I GLX.Scene.inc}
 
 uses
   System.Classes,
   System.SysUtils,
   FMX.Dialogs,
   
-  CUDAx.Import,
+  CUDA.Import,
+  CUDA.FourierTransform,
+
   CUDAx.API,
   CUDAx.Context,
-  CUDAx.FourierTransform,
   GLX.Strings;
 
 type

+ 1 - 1
Source/FMX/CUDAx.Graphics.pas

@@ -11,7 +11,7 @@ uses
   System.Classes,
   FMX.Dialogs,
 
-  CUDAx.Import,
+  CUDA.Import,
   CUDAx.API,
 
   GLX.Context,

+ 2 - 3
Source/FMX/GLX.Strings.pas

@@ -3,7 +3,7 @@
 //
 unit GLX.Strings;
 
-(* String constants that are used in many GLXcene units *)
+(* String constants as resourcestring *)
 
 interface
 
@@ -209,8 +209,7 @@ resourcestring
   strThreadBusy = 'Unable to create CUDA context - thread is busy by another context';
   strMakeFloatingFail = 'Unable to make context floating after creation';
   strUnbalansedUsage = 'Unbalansed CUDA context usage';
-  strInvalidGLContext = 'Unable to create CUDA context with OpenGL interop' +
-    ' - OpenGL context not ready';
+  strInvalidGLContext = 'Unable to create CUDA context with OpenGL interop' + ' - context not ready';
   strFFTFuncRetErr = '%s return error: %s';
   strFailToBindArrayToTex = 'Unable to bind CUDA array to OpenGL unmaped t' + 'exture';
   strOutOfAttribSize = 'The amount of device''s data less then size of att' + 'ribute''s data.';

+ 3 - 5
Source/FMX/Physix.NGDManager.pas

@@ -11,19 +11,17 @@ unit Physix.NGDManager;
 
 interface
 
-{$I GLX.Scene.inc}
+{.$I GLX.Scene.inc}
 
 uses
   System.Classes, // TComponent Tlist TWriter TReader TPersistent
   System.SysUtils, // System utilities
   System.Math, // Samevalue isZero to compare single
   System.Types,
-  Physix.NGDImport,
 
+  NGD.Import,
   GLX.VectorTypes,
-
-  GLX.VectorGeometry,
-  // PgxVector TgxVector TgxMatrix PgxMatrix NullHmgVector...
+  GLX.VectorGeometry, // PgxVector TgxVector TgxMatrix PgxMatrix NullHmgVector...
   GLX.VectorLists, // TgxAffineVectorList for Tree
   GLX.XCollection, // TXCollection file function
   GLX.GeometryBB,

+ 1 - 2
Source/FMX/Physix.NGDRagdoll.pas

@@ -11,7 +11,7 @@ uses
   GLX.VectorGeometry,
   GLX.VectorTypes,
   GLX.VectorFileObjects,
-  Physix.NGDImport;
+  NGD.Import;
 
 type
   TNewtonRagdoll = class
@@ -54,7 +54,6 @@ function GetBoneParent(actor: TgxActor; bone: integer): integer;
 
 // =====================================
 implementation
-
 // =====================================
 
 function TNewtonRagdoll.TranslatePos;

+ 1 - 1
Source/FMX/Physix.ODEManager.pas

@@ -35,7 +35,7 @@ uses
   GLX.TerrainRenderer,
   GLX.Graph,
 
-  Physix.ODEImport,
+  ODE.Import,
   Physix.ODEUtils;
 
 type

+ 1 - 1
Source/FMX/Physix.ODERagdoll.pas

@@ -8,7 +8,7 @@ unit Physix.ODERagdoll;
 interface
 
 uses
-  Physix.ODEImport,
+  ODE.Import,
   Physix.ODEUtils,
 
   GLX.VectorTypes,

+ 1 - 1
Source/FMX/Physix.ODESkeletonColliders.pas

@@ -10,7 +10,7 @@ interface
 uses
   System.Classes,
 
-  Physix.ODEImport,
+  ODE.Import,
   GLX.VectorTypes,
   GLX.PersistentClasses,
   GLX.VectorGeometry,

+ 1 - 1
Source/FMX/Physix.ODEUtils.pas

@@ -17,7 +17,7 @@ uses
   System.SysUtils,
   System.Classes,
 
-  Physix.ODEImport,
+  ODE.Import,
   GLX.VectorGeometry,
   GLX.VectorTypes,
   GLX.VectorLists,

+ 16 - 18
Source/GLS.FilePGM.pas

@@ -13,7 +13,7 @@ uses
   Winapi.OpenGL,
   System.Classes,
   System.SysUtils,
-  
+
   GLS.Context,
   GLS.Graphics,
   GLS.TextureFormat,
@@ -22,7 +22,6 @@ uses
 
   CUDA.Utility;
 
-
 type
 
   TGLPGMImage = class(TGLBaseImage)
@@ -32,14 +31,14 @@ type
     procedure SaveToFile(const filename: string); override;
     procedure LoadFromStream(stream: TStream); override;
     procedure SaveToStream(stream: TStream); override;
-    procedure AssignFromTexture(textureContext: TGLContext;
-      const textureHandle: Cardinal; textureTarget: TGLTextureTarget;
-      const CurrentFormat: Boolean; const intFormat: TGLInternalFormat);
-      reintroduce;
+    procedure AssignFromTexture(textureContext: TGLContext; const textureHandle: Cardinal;
+      textureTarget: TGLTextureTarget; const CurrentFormat: Boolean;
+      const intFormat: TGLInternalFormat); reintroduce;
   end;
 
-// ------------------------------------------------------------------
+  // ------------------------------------------------------------------
 implementation
+
 // ------------------------------------------------------------------
 
 // ------------------
@@ -90,8 +89,8 @@ begin
       EInvalidRasterFile.Create(strCUTILFailed);
       exit;
     end;
-  if not cutSavePGMf(PAnsiChar(AnsiString(filename)), System.PSingle(fData),
-    FLOD[0].Width, FLOD[0].Height) then
+  if not cutSavePGMf(PAnsiChar(AnsiString(filename)), System.PSingle(fData), FLOD[0].Width,
+    FLOD[0].Height) then
     raise EInvalidRasterFile.Create('Saving to file failed');
 end;
 
@@ -105,9 +104,9 @@ begin
   Assert(false, 'Stream saving not supported');
 end;
 
-procedure TGLPGMImage.AssignFromTexture(textureContext: TGLContext;
-  const textureHandle: Cardinal; textureTarget: TGLTextureTarget;
-  const CurrentFormat: Boolean; const intFormat: TGLInternalFormat);
+procedure TGLPGMImage.AssignFromTexture(textureContext: TGLContext; const textureHandle: Cardinal;
+  textureTarget: TGLTextureTarget; const CurrentFormat: Boolean;
+  const intFormat: TGLInternalFormat);
 var
   oldContext: TGLContext;
   contextActivate: Boolean;
@@ -136,13 +135,11 @@ begin
     fColorFormat := GL_LUMINANCE;
     fDataType := GL_FLOAT;
     // Check level existence
-    gl.GetTexLevelParameteriv(glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT,
-      @texFormat);
+    gl.GetTexLevelParameteriv(glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, @texFormat);
     if texFormat > 1 then
     begin
       gl.GetTexLevelParameteriv(glTarget, 0, GL_TEXTURE_WIDTH, @FLOD[0].Width);
-      gl.GetTexLevelParameteriv(glTarget, 0, GL_TEXTURE_HEIGHT,
-        @FLOD[0].Height);
+      gl.GetTexLevelParameteriv(glTarget, 0, GL_TEXTURE_HEIGHT, @FLOD[0].Height);
       FLOD[0].Depth := 0;
       residentFormat := OpenGLFormatToInternalFormat(texFormat);
       if CurrentFormat then
@@ -175,9 +172,10 @@ begin
   Result := [dfcRead, dfcWrite];
 end;
 
-//------------------------------------------------
+// ------------------------------------------------
 initialization
-//------------------------------------------------
+
+// ------------------------------------------------
 
 RegisterRasterFormat('pgm', 'Portable Graymap', TGLPGMImage);
 

+ 54 - 0
Source/Physics.ODEUtils.pas

@@ -108,16 +108,22 @@ begin
   m.W.W := 1; //}
 end;
 
+//----------------------------------------------------
+
 procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: PdMatrix3; pos: PdVector3);
 begin
   ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R^), pos^);
 end;
 
+//----------------------------------------------------
+
 procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3; pos: TdVector3);
 begin
   ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R), pos);
 end;
 
+//----------------------------------------------------
+
 procedure DrawBox(Sides: TdVector3);
 var
   lx, ly, lz: single;
@@ -163,6 +169,8 @@ begin
   gl.End_();
 end;
 
+//----------------------------------------------------
+
 function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
 begin
   TransposeMatrix(m);
@@ -177,11 +185,15 @@ begin
   Result[10] := m.Z.Z;
 end;
 
+//----------------------------------------------------
+
 procedure dsDrawBox(pos: PdVector3; R: PdMatrix3; Sides: TdVector3);
 begin
   dsDrawBox(pos^, r^, Sides);
 end;
 
+//----------------------------------------------------
+
 procedure dsDrawBox(pos: TdVector3; R: TdMatrix3; Sides: TdVector3);
 begin
   setTransform(pos, R);
@@ -215,6 +227,8 @@ end;
 
 (*$WARNINGS OFF*)
 
+//----------------------------------------------------
+
 function ConvertdVector3ToVector3f(R: TdVector3): TVector3f;
 begin
   result.X := R[0];
@@ -222,6 +236,8 @@ begin
   result.Z := R[2];
 end;
 
+//----------------------------------------------------
+
 function ConvertdVector3ToVector3f(R: PdVector3): TVector3f;
 begin
   result.X := R[0];
@@ -229,6 +245,8 @@ begin
   result.Z := R[2];
 end;
 
+//----------------------------------------------------
+
 function ConvertdVector3ToVector4f(R: TdVector3): TVector4f; overload;
 begin
   result.X := R[0];
@@ -237,6 +255,8 @@ begin
   result.W := 0;
 end;
 
+//----------------------------------------------------
+
 function ConvertdVector3ToVector4f(R: PdVector3): TVector4f; overload;
 begin
   result.X := R[0];
@@ -245,6 +265,8 @@ begin
   result.W := 0;
 end;
 
+//----------------------------------------------------
+
 function ConvertdVector3ToAffineVector(R: PdVector3): TAffineVector; overload;
 begin
   result.X := R[0];
@@ -252,6 +274,8 @@ begin
   result.Z := R[2];
 end;
 
+//----------------------------------------------------
+
 function ConvertdVector3ToAffineVector(R: TdVector3): TAffineVector; overload;
 begin
   result.X := R[0];
@@ -259,6 +283,8 @@ begin
   result.Z := R[2];
 end;
 
+//----------------------------------------------------
+
 function ConvertVector3fTodVector3(R: TVector3f): TdVector3;
 begin
   result[0] := R.X;
@@ -266,6 +292,8 @@ begin
   result[2] := R.Z;
 end;
 
+//----------------------------------------------------
+
 function ConvertVector3fToPdVector3(R: TVector3f): PdVector3;
 begin
   result[0] := R.X;
@@ -273,6 +301,8 @@ begin
   result[2] := R.Z;
 end;
 
+//----------------------------------------------------
+
 function ConvertVector4fTodVector3(R: TVector4f): TdVector3;
 begin
   result[0] := R.X;
@@ -281,6 +311,8 @@ begin
   result[3] := 0;
 end;
 
+//----------------------------------------------------
+
 function ConvertVector4fToPdVector3(R: TVector4f): PdVector3;
 begin
   result[0] := R.X;
@@ -296,12 +328,16 @@ begin
   result := ConvertdVector3ToVector3f(dBodyGetPosition(Body));
 end;
 
+//----------------------------------------------------
+
 procedure PositionSceneObjectForGeom(Geom: PdxGeom);
 begin
   if Assigned(Geom.Data) then
     PositionSceneObject(TGLBaseSceneObject(Geom.Data), Geom);
 end;
 
+//----------------------------------------------------
+
 function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
 var
   pos, Pos2: PdVector3;
@@ -344,6 +380,8 @@ begin
   end;
 end;
 
+//----------------------------------------------------
+
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 var
   m: TGLMatrix;
@@ -353,6 +391,8 @@ begin
   result := VectorNormalize(m.Z);
 end;
 
+//----------------------------------------------------
+
 procedure PositionSceneObject(GLBaseSceneObject: TGLBaseSceneObject; Geom: PdxGeom);
 var
   Scale: TAffineVector;
@@ -373,6 +413,8 @@ begin
   Cube.CubeDepth := Sides[2]; // 2
 end;
 
+//----------------------------------------------------
+
 procedure CopyPosFromGeomToGL(Geom: PdxGeom; GLBaseSceneObject: TGLBaseSceneObject);
 var
   v: TGLVector;
@@ -405,6 +447,8 @@ begin
   dGeomSetRotation(Geom, R^);
 end;
 
+//----------------------------------------------------
+
 function CreateGeomFromCube(Cube: TGLCube; Space: PdxSpace): PdxGeom;
 var
   Geom: PdxGeom;
@@ -414,6 +458,8 @@ begin
   result := Geom;
 end;
 
+//----------------------------------------------------
+
 function CreateBodyFromCube(var Geom: PdxGeom; Cube: TGLCube; World: PdxWorld; Space: PdxSpace): PdxBody;
 var
   Body: PdxBody;
@@ -429,6 +475,8 @@ begin
   end;
 end;
 
+//----------------------------------------------------
+
 function CreateTriMeshFromBaseMesh(
   GLBaseMesh: TGLBaseMesh;
   Space: PdxSpace;
@@ -507,6 +555,8 @@ begin
   end;
 end;
 
+//----------------------------------------------------
+
 procedure CopyBodyFromCube(Body: PdxBody; var Geom: PdxGeom; Cube: TGLCube;
   Space: PdxSpace);
 var
@@ -525,6 +575,8 @@ begin
   Geom.data := Cube;
 end;
 
+//----------------------------------------------------
+
 function dBodyToBodyDistance(Body1, Body2: PdxBody): TdReal;
 begin
   result := dVector3Length(Vector3SUB(Body1.posr.pos, Body2.posr.pos));
@@ -549,6 +601,8 @@ begin
       PositionSceneObject(TGLBaseSceneObject(GeomList[i].data), GeomList[i]);
 end;
 
+//----------------------------------------------------
+
 function CreateODEPlaneFromGLPlane(Plane: TGLPlane; Space: PdxSpace): PdxGeom;
 var
   Pos, Direction: TGLVector;