2
0

GLS.ShaderTextureSharing.pas 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. //
  2. // This unit is part of the GLScene Engine, http://glscene.org
  3. //
  4. unit GLS.ShaderTextureSharing;
  5. (*
  6. This shader allows to apply multiple textures, gathering them from existing materials.
  7. This allows saving resources, since you can reference the textures of any material in
  8. any materialLibrary.
  9. Note that actually the component references a Material (not a texture) but
  10. it uses that material's texture. The referenced material settings will be ignored,
  11. but the texture's settings (like TextureMode, ImageGamma, ImageBrightness) will be used.
  12. Instead the local material settings (listed in the collection) will be used.
  13. *)
  14. interface
  15. uses
  16. System.Classes,
  17. System.SysUtils,
  18. GLScene,
  19. GLContext,
  20. GLTexture,
  21. GLVectorTypes,
  22. GLVectorGeometry,
  23. GlColor,
  24. GLMaterial,
  25. GLS.Strings,
  26. GLVectorFileObjects,
  27. XOpenGL,
  28. GLState,
  29. GLPersistentClasses,
  30. GLCoordinates,
  31. GLRenderContextInfo;
  32. type
  33. TGLTextureSharingShader = class;
  34. TGLTextureSharingShaderMaterial = class(TGLInterfacedCollectionItem, IGLMaterialLibrarySupported)
  35. private
  36. FTextureMatrix: TMatrix;
  37. FNeedToUpdateTextureMatrix: Boolean;
  38. FTextureMatrixIsUnitary: Boolean;
  39. FLibMaterial: TGLLibMaterial;
  40. FTexOffset: TGLCoordinates2;
  41. FTexScale: TGLCoordinates2;
  42. FBlendingMode: TGLBlendingMode;
  43. FSpecular: TGLColor;
  44. FAmbient: TGLColor;
  45. FDiffuse: TGLColor;
  46. FEmission: TGLColor;
  47. FShininess: TGLShininess;
  48. FMaterialLibrary: TGLMaterialLibrary;
  49. FLibMaterialName: TGLLibMaterialName;
  50. procedure SetAmbient(const Value: TGLColor);
  51. procedure SetDiffuse(const Value: TGLColor);
  52. procedure SetEmission(const Value: TGLColor);
  53. procedure SetShininess(const Value: TGLShininess);
  54. procedure SetSpecular(const Value: TGLColor);
  55. procedure SetMaterialLibrary(const Value: TGLMaterialLibrary);
  56. procedure SetLibMaterialName(const Value: TGLLibMaterialName);
  57. procedure SetBlendingMode(const Value: TGLBlendingMode);
  58. procedure SetLibMaterial(const Value: TGLLibMaterial);
  59. procedure SetTexOffset(const Value: TGLCoordinates2);
  60. procedure SetTexScale(const Value: TGLCoordinates2);
  61. function GetTextureMatrix: TMatrix;
  62. function GetTextureMatrixIsUnitary: Boolean;
  63. protected
  64. procedure coordNotifychange(Sender: TObject);
  65. procedure OtherNotifychange(Sender: TObject);
  66. function GetDisplayName: string; override;
  67. function GetTextureSharingShader: TGLTextureSharingShader;
  68. // Implementing IGLMaterialLibrarySupported.
  69. function GetMaterialLibrary: TGLAbstractMaterialLibrary; virtual;
  70. public
  71. procedure Apply(var rci: TGLRenderContextInfo);
  72. procedure UnApply(var rci: TGLRenderContextInfo);
  73. constructor Create(Collection: TCollection); override;
  74. destructor Destroy; override;
  75. property LibMaterial: TGLLibMaterial read FLibMaterial write SetLibMaterial;
  76. property TextureMatrix: TMatrix read GetTextureMatrix;
  77. property TextureMatrixIsUnitary: Boolean read GetTextureMatrixIsUnitary;
  78. published
  79. property TexOffset: TGLCoordinates2 read FTexOffset write SetTexOffset;
  80. property TexScale: TGLCoordinates2 read FTexScale write SetTexScale;
  81. property BlendingMode: TGLBlendingMode read FBlendingMode write SetBlendingMode;
  82. property Emission: TGLColor read FEmission write SetEmission;
  83. property Ambient: TGLColor read FAmbient write SetAmbient;
  84. property Diffuse: TGLColor read FDiffuse write SetDiffuse;
  85. property Specular: TGLColor read FSpecular write SetSpecular;
  86. property Shininess: TGLShininess read FShininess write SetShininess;
  87. property MaterialLibrary: TGLMaterialLibrary read FMaterialLibrary write SetMaterialLibrary;
  88. property LibMaterialName: TGLLibMaterialName read FLibMaterialName write SetLibMaterialName;
  89. end;
  90. TGLTextureSharingShaderMaterials = class(TOwnedCollection)
  91. protected
  92. function GetItems(const AIndex: Integer): TGLTextureSharingShaderMaterial;
  93. procedure SetItems(const AIndex: Integer; const Value: TGLTextureSharingShaderMaterial);
  94. function GetParent: TGLTextureSharingShader;
  95. public
  96. function Add: TGLTextureSharingShaderMaterial;
  97. constructor Create(AOwner: TGLTextureSharingShader);
  98. property Items[const AIndex: Integer]: TGLTextureSharingShaderMaterial read GetItems write SetItems; default;
  99. end;
  100. TGLTextureSharingShader = class(TGLShader)
  101. private
  102. FMaterials: TGLTextureSharingShaderMaterials;
  103. FCurrentPass: Integer;
  104. procedure SetMaterials(const Value: TGLTextureSharingShaderMaterials);
  105. protected
  106. procedure DoApply(var rci: TGLRenderContextInfo; Sender: TObject); override;
  107. function DoUnApply(var rci: TGLRenderContextInfo): Boolean; override;
  108. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  109. public
  110. constructor Create(AOwner: TComponent); override;
  111. destructor Destroy; override;
  112. function AddLibMaterial(const ALibMaterial: TGLLibMaterial): TGLTextureSharingShaderMaterial;
  113. function FindLibMaterial(const ALibMaterial: TGLLibMaterial): TGLTextureSharingShaderMaterial;
  114. published
  115. property Materials: TGLTextureSharingShaderMaterials read FMaterials write SetMaterials;
  116. end;
  117. //================================================
  118. implementation
  119. //================================================
  120. //-----------------------------------
  121. // TGLTextureSharingShaderMaterial
  122. //-----------------------------------
  123. procedure TGLTextureSharingShaderMaterial.Apply(var rci: TGLRenderContextInfo);
  124. begin
  125. if not Assigned(FLibMaterial) then
  126. Exit;
  127. xgl.BeginUpdate;
  128. if Assigned(FLibMaterial.Shader) then
  129. begin
  130. case FLibMaterial.Shader.ShaderStyle of
  131. ssHighLevel: FLibMaterial.Shader.Apply(rci, FLibMaterial);
  132. ssReplace:
  133. begin
  134. FLibMaterial.Shader.Apply(rci, FLibMaterial);
  135. Exit;
  136. end;
  137. end;
  138. end;
  139. if not FLibMaterial.Material.Texture.Disabled then
  140. begin
  141. if not (GetTextureMatrixIsUnitary) then
  142. begin
  143. rci.GLStates.SetGLTextureMatrix(TextureMatrix);
  144. end;
  145. end;
  146. if moNoLighting in FLibMaterial.Material.MaterialOptions then
  147. rci.GLStates.Disable(stLighting);
  148. if stLighting in rci.GLStates.States then
  149. begin
  150. rci.GLStates.SetGLMaterialColors(cmFront,
  151. Emission.Color, Ambient.Color, Diffuse.Color, Specular.Color, Shininess);
  152. rci.GLStates.PolygonMode :=FLibMaterial.Material.PolygonMode;
  153. end
  154. else
  155. FLibMaterial.Material.FrontProperties.ApplyNoLighting(rci, cmFront);
  156. if (stCullFace in rci.GLStates.States) then
  157. begin
  158. case FLibMaterial.Material.FaceCulling of
  159. fcBufferDefault: if not rci.bufferFaceCull then
  160. begin
  161. rci.GLStates.Disable(stCullFace);
  162. FLibMaterial.Material.BackProperties.Apply(rci, cmBack);
  163. end;
  164. fcCull: ; // nothing to do
  165. fcNoCull:
  166. begin
  167. rci.GLStates.Disable(stCullFace);
  168. FLibMaterial.Material.BackProperties.Apply(rci, cmBack);
  169. end;
  170. else
  171. Assert(False);
  172. end;
  173. end
  174. else
  175. begin
  176. // currently NOT culling
  177. case FLibMaterial.Material.FaceCulling of
  178. fcBufferDefault:
  179. begin
  180. if rci.bufferFaceCull then
  181. rci.GLStates.Enable(stCullFace)
  182. else
  183. FLibMaterial.Material.BackProperties.Apply(rci, cmBack);
  184. end;
  185. fcCull: rci.GLStates.Enable(stCullFace);
  186. fcNoCull: FLibMaterial.Material.BackProperties.Apply(rci, cmBack);
  187. else
  188. Assert(False);
  189. end;
  190. end;
  191. // Apply Blending mode
  192. if not rci.ignoreBlendingRequests then
  193. case BlendingMode of
  194. bmOpaque:
  195. begin
  196. rci.GLStates.Disable(stBlend);
  197. rci.GLStates.Disable(stAlphaTest);
  198. end;
  199. bmTransparency:
  200. begin
  201. rci.GLStates.Enable(stBlend);
  202. rci.GLStates.Enable(stAlphaTest);
  203. rci.GLStates.SetBlendFunc(bfSrcAlpha, bfOneMinusSrcAlpha);
  204. end;
  205. bmAdditive:
  206. begin
  207. rci.GLStates.Enable(stBlend);
  208. rci.GLStates.Enable(stAlphaTest);
  209. rci.GLStates.SetBlendFunc(bfSrcAlpha, bfOne);
  210. end;
  211. bmAlphaTest50:
  212. begin
  213. rci.GLStates.Disable(stBlend);
  214. rci.GLStates.Enable(stAlphaTest);
  215. rci.GLStates.SetGLAlphaFunction(cfGEqual, 0.5);
  216. end;
  217. bmAlphaTest100:
  218. begin
  219. rci.GLStates.Disable(stBlend);
  220. rci.GLStates.Enable(stAlphaTest);
  221. rci.GLStates.SetGLAlphaFunction(cfGEqual, 1.0);
  222. end;
  223. bmModulate:
  224. begin
  225. rci.GLStates.Enable(stBlend);
  226. rci.GLStates.Enable(stAlphaTest);
  227. rci.GLStates.SetBlendFunc(bfDstColor, bfZero);
  228. end;
  229. else
  230. Assert(False);
  231. end;
  232. // Fog switch
  233. if moIgnoreFog in FLibMaterial.Material.MaterialOptions then
  234. begin
  235. if stFog in rci.GLStates.States then
  236. begin
  237. rci.GLStates.Disable(stFog);
  238. Inc(rci.fogDisabledCounter);
  239. end;
  240. end;
  241. if not Assigned(FLibMaterial.Material.TextureEx) then
  242. begin
  243. if Assigned(FLibMaterial.Material.Texture) then
  244. FLibMaterial.Material.Texture.Apply(rci);
  245. end
  246. else
  247. begin
  248. if Assigned(FLibMaterial.Material.Texture) and not FLibMaterial.Material.TextureEx.IsTextureEnabled(0) then
  249. FLibMaterial.Material.Texture.Apply(rci)
  250. else
  251. if FLibMaterial.Material.TextureEx.Count > 0 then
  252. FLibMaterial.Material.TextureEx.Apply(rci);
  253. end;
  254. if Assigned(FLibMaterial.Shader) then
  255. begin
  256. case FLibMaterial.Shader.ShaderStyle of
  257. ssLowLevel: FLibMaterial.Shader.Apply(rci, FLibMaterial);
  258. end;
  259. end;
  260. xgl.EndUpdate;
  261. end;
  262. procedure TGLTextureSharingShaderMaterial.coordNotifychange(Sender: TObject);
  263. begin
  264. FNeedToUpdateTextureMatrix := True;
  265. GetTextureSharingShader.NotifyChange(Self);
  266. end;
  267. constructor TGLTextureSharingShaderMaterial.Create(Collection: TCollection);
  268. begin
  269. inherited;
  270. FSpecular := TGLColor.Create(Self);
  271. FSpecular.OnNotifyChange := OtherNotifychange;
  272. FAmbient := TGLColor.Create(Self);
  273. FAmbient.OnNotifyChange := OtherNotifychange;
  274. FDiffuse := TGLColor.Create(Self);
  275. FDiffuse.OnNotifyChange := OtherNotifychange;
  276. FEmission := TGLColor.Create(Self);
  277. FEmission.OnNotifyChange := OtherNotifychange;
  278. FTexOffset := TGLCoordinates2.CreateInitialized(Self, NullHmgVector, csPoint2d);
  279. FTexOffset.OnNotifyChange := coordNotifychange;
  280. FTexScale := TGLCoordinates2.CreateInitialized(Self, XYZHmgVector, csPoint2d);
  281. FTexScale.OnNotifyChange := coordNotifychange;
  282. FNeedToUpdateTextureMatrix := True;
  283. end;
  284. destructor TGLTextureSharingShaderMaterial.Destroy;
  285. begin
  286. FSpecular.Free;
  287. FAmbient.Free;
  288. FDiffuse.Free;
  289. FEmission.Free;
  290. FTexOffset.Free;
  291. FTexScale.Free;
  292. inherited;
  293. end;
  294. function TGLTextureSharingShaderMaterial.GetDisplayName: string;
  295. var
  296. st: string;
  297. begin
  298. if Assigned(MaterialLibrary) then
  299. st := MaterialLibrary.Name
  300. else
  301. st := '';
  302. Result := '[' + st + '.' + Self.LibMaterialName + ']';
  303. end;
  304. function TGLTextureSharingShaderMaterial.GetMaterialLibrary: TGLAbstractMaterialLibrary;
  305. begin
  306. Result := FMaterialLibrary;
  307. end;
  308. function TGLTextureSharingShaderMaterial.GetTextureMatrix: TMatrix;
  309. begin
  310. if FNeedToUpdateTextureMatrix then
  311. begin
  312. if not (TexOffset.Equals(NullHmgVector) and TexScale.Equals(XYZHmgVector)) then
  313. begin
  314. FTextureMatrixIsUnitary := False;
  315. FTextureMatrix := CreateScaleAndTranslationMatrix(TexScale.AsVector, TexOffset.AsVector)
  316. end
  317. else
  318. FTextureMatrixIsUnitary := True;
  319. FNeedToUpdateTextureMatrix := False;
  320. end;
  321. Result := FTextureMatrix;
  322. end;
  323. function TGLTextureSharingShaderMaterial.GetTextureMatrixIsUnitary: Boolean;
  324. begin
  325. if FNeedToUpdateTextureMatrix then
  326. GetTextureMatrix;
  327. Result := FTextureMatrixIsUnitary;
  328. end;
  329. function TGLTextureSharingShaderMaterial.GetTextureSharingShader: TGLTextureSharingShader;
  330. begin
  331. if Collection is TGLTextureSharingShaderMaterials then
  332. Result := TGLTextureSharingShaderMaterials(Collection).GetParent
  333. else
  334. Result := nil;
  335. end;
  336. procedure TGLTextureSharingShaderMaterial.OtherNotifychange(Sender: TObject);
  337. begin
  338. GetTextureSharingShader.NotifyChange(Self);
  339. end;
  340. procedure TGLTextureSharingShaderMaterial.SetAmbient(const Value: TGLColor);
  341. begin
  342. FAmbient.Assign(Value);
  343. end;
  344. procedure TGLTextureSharingShaderMaterial.SetBlendingMode(const Value: TGLBlendingMode);
  345. begin
  346. FBlendingMode := Value;
  347. end;
  348. procedure TGLTextureSharingShaderMaterial.SetDiffuse(const Value: TGLColor);
  349. begin
  350. FDiffuse.Assign(Value);
  351. end;
  352. procedure TGLTextureSharingShaderMaterial.SetEmission(const Value: TGLColor);
  353. begin
  354. FEmission.Assign(Value);
  355. end;
  356. procedure TGLTextureSharingShaderMaterial.SetLibMaterialName(const Value: TGLLibMaterialName);
  357. begin
  358. FLibMaterialName := Value;
  359. if (FLibMaterialName = '') or (FMaterialLibrary = nil) then
  360. FLibMaterial := nil
  361. else
  362. SetLibMaterial(FMaterialLibrary.LibMaterialByName(FLibMaterialName));
  363. end;
  364. procedure TGLTextureSharingShaderMaterial.SetLibMaterial(const Value: TGLLibMaterial);
  365. begin
  366. FLibMaterial := Value;
  367. if FLibMaterial <> nil then
  368. begin
  369. FLibMaterialName := FLibMaterial.DisplayName;
  370. FMaterialLibrary := TGLMaterialLibrary(TGLLibMaterials(Value.Collection).Owner);
  371. if not (csloading in GetTextureSharingShader.ComponentState) then
  372. begin
  373. FTexOffset.Assign(FLibMaterial.TextureOffset);
  374. FTexScale.Assign(FLibMaterial.TextureScale);
  375. FBlendingMode := FLibMaterial.Material.BlendingMode;
  376. fEmission.Assign(FLibMaterial.Material.FrontProperties.Emission);
  377. fAmbient.Assign(FLibMaterial.Material.FrontProperties.Ambient);
  378. fDiffuse.Assign(FLibMaterial.Material.FrontProperties.Diffuse);
  379. fSpecular.Assign(FLibMaterial.Material.FrontProperties.Specular);
  380. fShininess := FLibMaterial.Material.FrontProperties.Shininess;
  381. end;
  382. end;
  383. end;
  384. procedure TGLTextureSharingShaderMaterial.SetMaterialLibrary(const Value: TGLMaterialLibrary);
  385. begin
  386. FMaterialLibrary := Value;
  387. if (FLibMaterialName = '') or (FMaterialLibrary = nil) then
  388. FLibMaterial := nil
  389. else
  390. SetLibMaterial(FMaterialLibrary.LibMaterialByName(FLibMaterialName));
  391. end;
  392. procedure TGLTextureSharingShaderMaterial.SetShininess(const Value: TGLShininess);
  393. begin
  394. FShininess := Value;
  395. end;
  396. procedure TGLTextureSharingShaderMaterial.SetSpecular(const Value: TGLColor);
  397. begin
  398. FSpecular.Assign(Value);
  399. end;
  400. procedure TGLTextureSharingShaderMaterial.SetTexOffset(const Value: TGLCoordinates2);
  401. begin
  402. FTexOffset.Assign(Value);
  403. FNeedToUpdateTextureMatrix := True;
  404. end;
  405. procedure TGLTextureSharingShaderMaterial.SetTexScale(const Value: TGLCoordinates2);
  406. begin
  407. FTexScale.Assign(Value);
  408. FNeedToUpdateTextureMatrix := True;
  409. end;
  410. procedure TGLTextureSharingShaderMaterial.UnApply(var rci: TGLRenderContextInfo);
  411. begin
  412. if not Assigned(FLibMaterial) then
  413. Exit;
  414. if Assigned(FLibMaterial.Shader) then
  415. begin
  416. case FLibMaterial.Shader.ShaderStyle of
  417. ssLowLevel: FLibMaterial.Shader.UnApply(rci);
  418. ssReplace:
  419. begin
  420. FLibMaterial.Shader.UnApply(rci);
  421. Exit;
  422. end;
  423. end;
  424. end;
  425. FLibMaterial.Material.UnApply(rci);
  426. if not FLibMaterial.Material.Texture.Disabled then
  427. if not (GetTextureMatrixIsUnitary) then
  428. begin
  429. rci.GLStates.ResetGLTextureMatrix;
  430. end;
  431. if Assigned(FLibMaterial.Shader) then
  432. begin
  433. case FLibMaterial.Shader.ShaderStyle of
  434. ssHighLevel: FLibMaterial.Shader.UnApply(rci);
  435. end;
  436. end;
  437. end;
  438. //-----------------------------------
  439. // TGLTextureSharingShader
  440. //-----------------------------------
  441. function TGLTextureSharingShader.AddLibMaterial(const ALibMaterial: TGLLibMaterial): TGLTextureSharingShaderMaterial;
  442. begin
  443. Result := FMaterials.Add;
  444. Result.SetLibMaterial(ALibMaterial);
  445. end;
  446. constructor TGLTextureSharingShader.Create(AOwner: TComponent);
  447. begin
  448. inherited;
  449. FMaterials := TGLTextureSharingShaderMaterials.Create(Self);
  450. ShaderStyle := ssReplace;
  451. end;
  452. destructor TGLTextureSharingShader.Destroy;
  453. begin
  454. FMaterials.Free;
  455. inherited;
  456. end;
  457. procedure TGLTextureSharingShader.DoApply(var rci: TGLRenderContextInfo; Sender: TObject);
  458. begin
  459. if Materials.Count > 0 then
  460. begin
  461. rci.GLStates.Enable(stDepthTest);
  462. rci.GLStates.DepthFunc := cfLEqual;
  463. Materials[0].Apply(rci);
  464. FCurrentPass := 1;
  465. end;
  466. end;
  467. function TGLTextureSharingShader.DoUnApply(var rci: TGLRenderContextInfo): Boolean;
  468. begin
  469. Result := False;
  470. if Materials.Count > 0 then
  471. begin
  472. Materials[FCurrentPass - 1].UnApply(rci);
  473. if FCurrentPass < Materials.Count then
  474. begin
  475. Materials[FCurrentPass].Apply(rci);
  476. Inc(FCurrentPass);
  477. Result := True;
  478. end
  479. else
  480. begin
  481. rci.GLStates.DepthFunc := cfLess;
  482. rci.GLStates.Disable(stBlend);
  483. rci.GLStates.Disable(stAlphaTest);
  484. FCurrentPass := 0;
  485. end;
  486. end;
  487. end;
  488. function TGLTextureSharingShader.FindLibMaterial(const ALibMaterial: TGLLibMaterial): TGLTextureSharingShaderMaterial;
  489. var
  490. I: Integer;
  491. begin
  492. Result := nil;
  493. for I := 0 to FMaterials.Count - 1 do
  494. if FMaterials[I].FLibMaterial = ALibMaterial then
  495. begin
  496. Result := FMaterials[I];
  497. Break;
  498. end;
  499. end;
  500. procedure TGLTextureSharingShader.Notification(AComponent: TComponent; Operation: TOperation);
  501. var
  502. I: Integer;
  503. begin
  504. inherited;
  505. if Operation = opRemove then
  506. begin
  507. if AComponent is TGLMaterialLibrary then
  508. begin
  509. for I := 0 to Materials.Count - 1 do
  510. begin
  511. if Materials.Items[I].MaterialLibrary = AComponent then
  512. Materials.Items[I].MaterialLibrary := nil;
  513. end;
  514. end;
  515. end;
  516. end;
  517. procedure TGLTextureSharingShader.SetMaterials(const Value: TGLTextureSharingShaderMaterials);
  518. begin
  519. FMaterials.Assign(Value);
  520. end;
  521. //-----------------------------------
  522. // TGLTextureSharingShaderMaterials
  523. //-----------------------------------
  524. function TGLTextureSharingShaderMaterials.Add: TGLTextureSharingShaderMaterial;
  525. begin
  526. Result := (inherited Add) as TGLTextureSharingShaderMaterial;
  527. end;
  528. constructor TGLTextureSharingShaderMaterials.Create(AOwner: TGLTextureSharingShader);
  529. begin
  530. inherited Create(AOwner, TGLTextureSharingShaderMaterial);
  531. end;
  532. function TGLTextureSharingShaderMaterials.GetItems(const AIndex: Integer): TGLTextureSharingShaderMaterial;
  533. begin
  534. Result := (inherited Items[AIndex]) as TGLTextureSharingShaderMaterial;
  535. end;
  536. function TGLTextureSharingShaderMaterials.GetParent: TGLTextureSharingShader;
  537. begin
  538. Result := TGLTextureSharingShader(GetOwner);
  539. end;
  540. procedure TGLTextureSharingShaderMaterials.SetItems(const AIndex: Integer; const Value: TGLTextureSharingShaderMaterial);
  541. begin
  542. inherited Items[AIndex] := Value;
  543. end;
  544. //================================================
  545. initialization
  546. //================================================
  547. RegisterClasses([TGLTextureSharingShader, TGLTextureSharingShaderMaterials,
  548. TGLTextureSharingShaderMaterial]);
  549. end.