Browse Source

* use TengShaderGeneratorEx for library

* updated submodule: ShaderFile
master
Bergmann89 8 years ago
parent
commit
1b2fc8d297
2 changed files with 13 additions and 29 deletions
  1. +1
    -1
      ShaderFile
  2. +12
    -28
      libShaderFile.lpr

+ 1
- 1
ShaderFile

@@ -1 +1 @@
Subproject commit b56cc6b31440bb5c5f98ea44e0dd241d36bc1b08
Subproject commit 46d9bcc9e4cb654372190c403f6bd26b9a70b60d

+ 12
- 28
libShaderFile.lpr View File

@@ -4,7 +4,7 @@ library libShaderFile;


uses uses
SysUtils, variants, Classes, SysUtils, variants, Classes,
uengShaderFile, uengShaderGenerator, uengShaderPart,
uengShaderFile, uengShaderGeneratorEx, uengShaderPart,
uengShaderFileGenerics, uengShaderFileTypes; uengShaderFileGenerics, uengShaderFileTypes;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -64,24 +64,20 @@ type
TShaderFile = class; TShaderFile = class;
TShaderGenerator = class; TShaderGenerator = class;


TPropertyMap = specialize TutlMap<string, variant>;
TShaderGeneratorHandleHashSet = specialize TutlHashSet<TlsfShaderGeneratorHandle>; TShaderGeneratorHandleHashSet = specialize TutlHashSet<TlsfShaderGeneratorHandle>;
TShaderGeneratorHashSet = specialize TutlHashSet<TShaderGenerator>; TShaderGeneratorHashSet = specialize TutlHashSet<TShaderGenerator>;
TStreamHashSet = specialize TutlHashSet<TStream>; TStreamHashSet = specialize TutlHashSet<TStream>;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TShaderGenerator = class(TObject)
TShaderGenerator = class(TengShaderGeneratorEx)
private private
fOwner: TShaderFile; fOwner: TShaderFile;
fGenerator: TengShaderGenerator;
fProperties: TPropertyMap;
fPropertyNames: String; fPropertyNames: String;
fPropertyValue: String; fPropertyValue: String;
fGeneratedCode: String; fGeneratedCode: String;
public public
property Owner: TShaderFile read fOwner; property Owner: TShaderFile read fOwner;
property PropertyNames: String read fPropertyNames; property PropertyNames: String read fPropertyNames;
property Properties: TPropertyMap read fProperties;


function GetProperty(const aIndex: Integer): PAnsiChar; function GetProperty(const aIndex: Integer): PAnsiChar;
function GetProperty(const aName: String): PAnsiChar; function GetProperty(const aName: String): PAnsiChar;
@@ -89,8 +85,7 @@ type
function SetProperty(const aName: String; const aValue: PAnsiChar): TlsfErrorCode; function SetProperty(const aName: String; const aValue: PAnsiChar): TlsfErrorCode;
function GenerateCode: PAnsiChar; function GenerateCode: PAnsiChar;


constructor Create(const aOwner: TShaderFile; const aGenerator: TengShaderGenerator);
destructor Destroy; override;
constructor Create(const aOwner: TShaderFile; const aName: String);
end; end;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -711,14 +706,14 @@ end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TShaderGenerator.GenerateCode: PAnsiChar; function TShaderGenerator.GenerateCode: PAnsiChar;
var var
kvp: TPropertyMap.TKeyValuePair;
kvp: TStringVariantMap.TKeyValuePair;
c: TengShaderCode; c: TengShaderCode;
begin begin
for kvp in fProperties.KeyValuePairs do for kvp in fProperties.KeyValuePairs do
fGenerator.PropertyByName[kvp.Key] := kvp.Value;
PropertyByName[kvp.Key] := kvp.Value;
c := TengShaderCode.Create; c := TengShaderCode.Create;
try try
fGenerator.GenerateCode(c);
inherited GenerateCode(c);
fGeneratedCode := c.Text; fGeneratedCode := c.Text;
result := PAnsiChar(fGeneratedCode); result := PAnsiChar(fGeneratedCode);
finally finally
@@ -727,26 +722,15 @@ begin
end; end;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TShaderGenerator.Create(const aOwner: TShaderFile; const aGenerator: TengShaderGenerator);
constructor TShaderGenerator.Create(const aOwner: TShaderFile; const aName: String);
var var
i: Integer;
s: String;
begin begin
inherited Create;
inherited Create(aOwner, aName);
fOwner := aOwner; fOwner := aOwner;
fGenerator := aGenerator;
fProperties := TPropertyMap.Create(true);
fPropertyNames := ''; fPropertyNames := '';
for i := 0 to fGenerator.PropertyCount-1 do begin
fProperties.Add(fGenerator.PropertyNames[i], fGenerator.PropertyByIndex[i]);
fPropertyNames := fPropertyNames + fGenerator.PropertyNames[i] + sLineBreak;
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TShaderGenerator.Destroy;
begin
FreeAndNil(fProperties);
inherited Destroy;
for s in fProperties.Keys do
fPropertyNames := fPropertyNames + s + sLineBreak;
end; end;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -793,7 +777,7 @@ begin
SetLastError(LSF_ERR_INVALID_GENERATOR_NAME, 'a generator with the name ''' + aName + ''' does not exist'); SetLastError(LSF_ERR_INVALID_GENERATOR_NAME, 'a generator with the name ''' + aName + ''' does not exist');
exit; exit;
end; end;
result := TShaderGenerator.Create(self, Generator[aName]);
result := TShaderGenerator.Create(self, aName);
fGenerators.Add(result); fGenerators.Add(result);
ShaderGenerators.Add(result); ShaderGenerators.Add(result);
end; end;


Loading…
Cancel
Save