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
SysUtils, variants, Classes,
uengShaderFile, uengShaderGenerator, uengShaderPart,
uengShaderFile, uengShaderGeneratorEx, uengShaderPart,
uengShaderFileGenerics, uengShaderFileTypes;

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

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

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

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

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TShaderGenerator.Create(const aOwner: TShaderFile; const aGenerator: TengShaderGenerator);
constructor TShaderGenerator.Create(const aOwner: TShaderFile; const aName: String);
var
i: Integer;
s: String;
begin
inherited Create;
inherited Create(aOwner, aName);
fOwner := aOwner;
fGenerator := aGenerator;
fProperties := TPropertyMap.Create(true);
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;

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


Loading…
Cancel
Save