forked from edivando-fpc/BGRABitmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbgracanvasgl.pas
1874 lines (1674 loc) · 67.4 KB
/
bgracanvasgl.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ ***************************************************************************
* *
* This file is part of BGRABitmap library which is distributed under the *
* modified LGPL. *
* *
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
************************* BGRABitmap library ******************************
- Drawing routines with transparency and antialiasing with Lazarus.
Offers also various transforms.
- These routines allow to manipulate 32bit images in BGRA format or RGBA
format (depending on the platform).
- This code is under modified LGPL (see COPYING.modifiedLGPL.txt).
This means that you can link this library inside your programs for any purpose.
Only the included part of the code must remain LGPL.
- If you make some improvements to this library, please notify here:
http://www.lazarus.freepascal.org/index.php/topic,12037.0.html
********************* Contact : Circular at operamail.com *******************
******************************* CONTRIBUTOR(S) ******************************
- Edivando S. Santos Brasil | [email protected]
(Compatibility with FPC ($Mode objfpc/delphi) and delphi VCL 11/2018)
***************************** END CONTRIBUTOR(S) *****************************}
Unit BGRACanvasGL;
{$i bgrabitmap.inc}{$H+}
interface
uses
Classes, SysUtils, Types, BGRATypes,{$IFNDEF FPC} GraphType,{$ENDIF} BGRAGraphics, BGRABitmapTypes,
BGRAOpenGLType, BGRATransform, BGRAPath,
BGRASSE, BGRAMatrix3D;
type
TBGLPath = class;
TBGLCustomCanvas = class;
TBGLCustomShader = class
protected
procedure StartUse; virtual; abstract;
procedure EndUse; virtual; abstract;
end;
TBGLCustomArray = class
protected
FBuffer: BGRADWord;
function GetCount: integer; virtual; abstract;
function GetRecordSize: integer; virtual; abstract;
public
constructor Create(ABufferAddress: pointer; ACount: integer; ARecordSize: integer); virtual; abstract;
property Count: integer read GetCount;
property RecordSize: integer read GetRecordSize;
property Handle: BGRADWord read FBuffer;
end;
{ TAttributeVariable }
TAttributeVariable = object
protected
FOwner: TObject;
FAttribute: BGRADWord;
FVectorSize: integer;
FArray: TBGLCustomArray;
FRecordOffset: integer;
FFloat: boolean;
procedure Init(AOwner: TObject; AAttribute: BGRADWord; AVectorSize: integer;
AFloat: boolean);
public
property Source: TBGLCustomArray read FArray write FArray;
property RecordOffset: integer read FRecordOffset write FRecordOffset;
property Handle: BGRADWord read FAttribute;
property VectorSize: integer read FVectorSize;
property IsFloat: boolean read FFloat;
property Owner: TObject read FOwner;
end;
TBGLCustomElementArray = class
protected
function GetCount: integer; virtual; abstract;
public
constructor Create(const AElements: array of integer); virtual; abstract;
procedure Draw(ACanvas: TBGLCustomCanvas; APrimitive: TOpenGLPrimitive; AAttributes: array of TAttributeVariable); virtual; abstract;
property Count: integer read GetCount;
end;
{ TBGLCustomLighting }
TBGLCustomLighting = class
private
FCurrentShader: TBGLCustomShader;
function GetActiveShader: TBGLCustomShader;
procedure SetActiveShader(AValue: TBGLCustomShader);
protected
function GetSupportShaders: boolean; virtual;
function GetShader(AName: string): TBGLCustomShader;
procedure SetShader(AName: string; AValue: TBGLCustomShader);
procedure SetAmbiantLightF(AAmbiantLight: TColorF); virtual; abstract;
function GetAmbiantLightF: TColorF; virtual; abstract;
function GetBuiltInLightingEnabled: boolean; virtual; abstract;
procedure SetBuiltInLightingEnabled(AValue: boolean); virtual; abstract;
public
ShaderList: TStringList;
destructor Destroy; override;
function AddDirectionalLight(AColor: TColorF; ADirection: TPoint3D): integer; virtual; abstract;
function AddPointLight(AColor: TColorF; APosition: TPoint3D; ALinearAttenuation, AQuadraticAttenuation: single): integer; virtual; abstract;
procedure ClearLights; virtual; abstract;
function RemoveLight(AIndex: integer): boolean; virtual; abstract;
procedure SetSpecularIndex(AIndex: integer); virtual; abstract;
function MakeVertexShader(ASource: string): BGRADWord; virtual; abstract;
function MakeFragmentShader(ASource: string): BGRADWord; virtual; abstract;
function MakeShaderProgram(AVertexShader, AFragmentShader: BGRADWord): BGRADWord; virtual; abstract;
procedure DeleteShaderObject(AShader: BGRADWord); virtual; abstract;
procedure DeleteShaderProgram(AProgram: BGRADWord); virtual; abstract;
procedure UseProgram(AProgram: BGRADWord); virtual; abstract;
function GetUniformVariable(AProgram: BGRADWord; AName: string): BGRADWord; virtual; abstract;
function GetAttribVariable(AProgram: BGRADWord; AName: string): BGRADWord; virtual; abstract;
procedure SetUniformsingle(AVariable: BGRADWord; const AValue; AElementCount, AComponentCount: integer); virtual; abstract;
procedure SetUniformInteger(AVariable: BGRADWord; const AValue; AElementCount, AComponentCount: integer); virtual; abstract;
procedure BindAttribute(AAttribute: TAttributeVariable); virtual; abstract;
procedure UnbindAttribute(AAttribute: TAttributeVariable); virtual; abstract;
procedure FreeShaders;
property ActiveShader: TBGLCustomShader read GetActiveShader write SetActiveShader;
property Shader[AName: string]: TBGLCustomShader read GetShader write SetShader;
property SupportShaders: boolean read GetSupportShaders;
property AmbiantLightF: TColorF read GetAmbiantLightF write SetAmbiantLightF;
property BuiltInLightingEnabled: boolean read GetBuiltInLightingEnabled write SetBuiltInLightingEnabled;
end;
{ TBGLCustomCanvas }
TBGLCustomCanvas = class
private
FActiveFrameBuffer: TBGLCustomFrameBuffer;
FHeight: integer;
FWidth: integer;
FNoClip: boolean;
FClipRect: TRect;
protected
procedure SwapRect(var r: TRect); overload;
procedure SwapRect(var x1,y1,x2,y2: single); overload;
procedure InternalArc(cx,cy,rx,ry: single; const StartPoint,EndPoint: TPointF; ABorderColor,AOuterFillColor,ACenterFillColor: TBGRAPixel; AOptions: TArcOptions; ADrawChord: boolean = false); overload;
procedure InternalArc(cx,cy,rx,ry: single; StartAngleRad,EndAngleRad: Single; ABorderColor,AOuterFillColor,ACenterFillColor: TBGRAPixel; AOptions: TArcOptions; ADrawChord: boolean = false); overload;
procedure InternalArcInRect(r: TRect; StartAngleRad,EndAngleRad: Single; ABorderColor,AOuterFillColor,ACenterFillColor: TBGRAPixel; AOptions: TArcOptions; ADrawChord: boolean = false); overload;
function ComputeEllipseC(r: TRect; AHasBorder: boolean; out cx,cy,rx,ry: single): boolean;
function GetHeight: integer; virtual;
function GetWidth: integer; virtual;
procedure SetWidth(AValue: integer); virtual;
procedure SetHeight(AValue: integer); virtual;
function GetClipRect: TRect;
procedure SetClipRect(AValue: TRect);
procedure EnableScissor(AValue: TRect); virtual; abstract;
procedure DisableScissor; virtual; abstract;
function GetMatrix: TAffineMatrix; virtual; abstract;
procedure SetMatrix(const AValue: TAffineMatrix); virtual; abstract;
function GetProjectionMatrix: TMatrix4D; virtual;
procedure SetProjectionMatrix(const {%H-}AValue: TMatrix4D); virtual;
procedure SetBlendMode(AValue: TOpenGLBlendMode); virtual; abstract;
function GetBlendMode: TOpenGLBlendMode; virtual; abstract;
function GetFaceCulling: TFaceCulling; virtual; abstract;
procedure SetFaceCulling(AValue: TFaceCulling); virtual; abstract;
procedure SetActiveFrameBuffer(AValue: TBGLCustomFrameBuffer); virtual;
function GetLighting: TBGLCustomLighting; virtual;
procedure InternalStartPutPixel(const pt: TPointF); virtual; abstract;
procedure InternalStartPolyline(const pt: TPointF); virtual; abstract;
procedure InternalStartPolygon(const pt: TPointF); virtual; abstract;
procedure InternalStartTriangleFan(const pt: TPointF); virtual; abstract;
procedure InternalContinueShape(const pt: TPointF); overload; virtual; abstract;
procedure InternalContinueShape(const {%H-}pt: TPoint3D); overload; virtual;
procedure InternalContinueShape(const {%H-}pt: TPoint3D_128); overload; virtual;
procedure InternalContinueShape(const {%H-}pt, {%H-}normal: TPoint3D_128); overload; virtual;
procedure InternalEndShape; virtual; abstract;
procedure InternalSetColor(const AColor: TBGRAPixel); virtual; abstract;
procedure InternalSetColorF(const AColor: TColorF); virtual; abstract;
procedure InternalStartBlend; virtual; abstract;
procedure InternalEndBlend; virtual; abstract;
procedure InternalStartBlendTriangles; virtual; abstract;
procedure InternalStartBlendQuads; virtual; abstract;
procedure InternalEndBlendTriangles; virtual; abstract;
procedure InternalEndBlendQuads; virtual; abstract;
public
constructor Create;
procedure Fill(AColor: TBGRAPixel); virtual; abstract;
procedure PutPixels(const APoints: array of TPointF; AColor: TBGRAPixel); overload; virtual;
procedure PutPixels(const APoints: array of TPointF; const AColors: array of TBGRAPixel); overload; virtual;
procedure Line(x1,y1,x2,y2: single; AColor: TBGRAPixel; ADrawLastPoint: boolean = true); overload;
procedure Line(p1,p2: TPointF; AColor: TBGRAPixel; ADrawLastPoint: boolean = true); overload;
procedure Polylines(const APoints: array of TPointF; AColor: TBGRAPixel; ADrawLastPoints: boolean = true); virtual;
procedure Polygons(const APoints: array of TPointF; AColor: TBGRAPixel); virtual;
procedure FillPolyConvex(const APoints: array of TPointF; AColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true);
procedure FillTriangleLinearColor(pt1,pt2,pt3: TPointF; c1,c2,c3: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload;
procedure FillTriangles(const APoints: array of TPointF; AColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillTrianglesLinearColor(const APoints: array of TPointF; const AColors: array of TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillTrianglesLinearColor(const APoints: array of TPoint3D; const AColors: array of TBGRAPixel); overload; virtual;
procedure FillTrianglesLinearColor(const APoints: array of TPoint3D_128; const AColors: array of TBGRAPixel); overload; virtual;
procedure FillTrianglesLinearColor(const APoints, ANormals: array of TPoint3D_128; const AColors: array of TBGRAPixel); overload; virtual;
procedure FillTrianglesFan(const APoints: array of TPointF; ACenterColor, ABorderColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillTriangleLinearColor(pt1,pt2,pt3: TPointF; c1,c2,c3: TColorF; APixelCenteredCoordinates: boolean = true); overload;
procedure FillTriangles(const APoints: array of TPointF; AColor: TColorF; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillTrianglesLinearColor(const APoints: array of TPointF; const AColors: array of TColorF; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillTrianglesLinearColor(const APoints: array of TPoint3D; const AColors: array of TColorF); overload; virtual;
procedure FillTrianglesLinearColor(const APoints: array of TPoint3D_128; const AColors: array of TColorF); overload; virtual;
procedure FillTrianglesLinearColor(const APoints, ANormals: array of TPoint3D_128; const AColors: array of TColorF); overload; virtual;
procedure FillTrianglesFan(const APoints: array of TPointF; ACenterColor, ABorderColor: TColorF; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillQuadLinearColor(pt1,pt2,pt3,pt4: TPointF; c1,c2,c3,c4: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload;
procedure FillQuads(const APoints: array of TPointF; AColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillQuadsLinearColor(const APoints: array of TPointF; const AColors: array of TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillQuadsLinearColor(const APoints: array of TPoint3D; const AColors: array of TBGRAPixel); overload; virtual;
procedure FillQuadsLinearColor(const APoints: array of TPoint3D_128; const AColors: array of TBGRAPixel); overload; virtual;
procedure FillQuadsLinearColor(const APoints, ANormals: array of TPoint3D_128; const AColors: array of TBGRAPixel); overload; virtual;
procedure FillQuadLinearColor(pt1,pt2,pt3,pt4: TPointF; c1,c2,c3,c4: TColorF; APixelCenteredCoordinates: boolean = true); overload;
procedure FillQuads(const APoints: array of TPointF; AColor: TColorF; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillQuadsLinearColor(const APoints: array of TPointF; const AColors: array of TColorF; APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure FillQuadsLinearColor(const APoints: array of TPoint3D; const AColors: array of TColorF); overload; virtual;
procedure FillQuadsLinearColor(const APoints: array of TPoint3D_128; const AColors: array of TColorF); overload; virtual;
procedure FillQuadsLinearColor(const APoints, ANormals: array of TPoint3D_128; const AColors: array of TColorF); overload; virtual;
procedure DrawPath(APath: TBGLPath; c: TBGRAPixel);
procedure FillPathConvex(APath: TBGLPath; c: TBGRAPixel; APixelCenteredCoordinates: boolean = true);
procedure FillRectLinearColor(r: TRect; ATopLeftColor, ATopRightColor, ABottomRightColor, ABottomLeftColor: TBGRAPixel); overload; virtual;
procedure FillRectLinearColor(x1,y1,x2,y2: single;
ATopLeftColor, ATopRightColor, ABottomRightColor, ABottomLeftColor: TBGRAPixel;
APixelCenteredCoordinates: boolean = true); overload; virtual;
procedure Ellipse(cx,cy,rx,ry: single; AColor: TBGRAPixel); overload;
procedure EllipseInRect(r: TRect; AColor: TBGRAPixel); overload;
procedure Ellipse(cx,cy,rx,ry: single; AColor: TBGRAPixel; AFillColor: TBGRAPixel); overload;
procedure EllipseInRect(r: TRect; AColor: TBGRAPixel; AFillColor: TBGRAPixel); overload;
procedure EllipseLinearColor(cx,cy,rx,ry: single; AColor: TBGRAPixel; AOuterFillColor, AInnerFillColor: TBGRAPixel); overload;
procedure EllipseLinearColorInRect(r: TRect; AColor: TBGRAPixel; AOuterFillColor, AInnerFillColor: TBGRAPixel); overload;
procedure FillEllipse(cx,cy,rx,ry: single; AColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true);
procedure FillEllipseInRect(r: TRect; AColor: TBGRAPixel);
procedure FillEllipseLinearColor(cx, cy, rx, ry: single; AOuterColor, AInnerColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true);
procedure FillEllipseLinearColorInRect(r: TRect; AOuterColor, AInnerColor: TBGRAPixel);
procedure Arc(cx,cy,rx,ry: single; const StartPoint,EndPoint: TPointF; AColor: TBGRAPixel; ADrawChord: boolean; AFillColor: TBGRAPixel); overload;
procedure Arc(cx,cy,rx,ry: single; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; ADrawChord: boolean; AFillColor: TBGRAPixel); overload;
procedure ArcInRect(r: TRect; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; ADrawChord: boolean; AFillColor: TBGRAPixel);
procedure ArcLinearColor(cx,cy,rx,ry: single; const StartPoint,EndPoint: TPointF; AColor: TBGRAPixel; ADrawChord: boolean; AOuterFillColor, AInnerFillColor: TBGRAPixel); overload;
procedure ArcLinearColor(cx,cy,rx,ry: single; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; ADrawChord: boolean; AOuterFillColor, AInnerFillColor: TBGRAPixel); overload;
procedure ArcLinearColorInRect(r: TRect; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; ADrawChord: boolean; AOuterFillColor, AInnerFillColor: TBGRAPixel);
procedure Pie(cx,cy,rx,ry: single; const StartPoint,EndPoint: TPointF; AColor: TBGRAPixel; AFillColor: TBGRAPixel); overload;
procedure Pie(cx,cy,rx,ry: single; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; AFillColor: TBGRAPixel); overload;
procedure PieInRect(r: TRect; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; AFillColor: TBGRAPixel);
procedure PieLinearColor(cx,cy,rx,ry: single; const StartPoint,EndPoint: TPointF; AColor: TBGRAPixel; AOuterFillColor, AInnerFillColor: TBGRAPixel); overload;
procedure PieLinearColor(cx,cy,rx,ry: single; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; AOuterFillColor, AInnerFillColor: TBGRAPixel); overload;
procedure PieLinearColorInRect(r: TRect; StartAngleRad,EndAngleRad: Single; AColor: TBGRAPixel; AOuterFillColor, AInnerFillColor: TBGRAPixel);
procedure Rectangle(r: TRect; AColor: TBGRAPixel); overload;
procedure Rectangle(r: TRect; AColor: TBGRAPixel; AFillColor: TBGRAPixel); overload;
procedure Rectangle(x1,y1,x2,y2: single; AColor: TBGRAPixel); overload;
procedure Rectangle(x1,y1,x2,y2: single; AColor: TBGRAPixel; AFillColor: TBGRAPixel); overload;
procedure Rectangle(x1,y1,x2,y2: single; AColor: TBGRAPixel; w: single; APixelCenteredCoordinates: boolean = true); overload;
procedure Rectangle(x1,y1,x2,y2: single; AColor: TBGRAPixel; w: single; AFillColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload;
procedure RectangleWithin(x1,y1,x2,y2: single; ABorderColor: TBGRAPixel; w: single; AFillColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload;
procedure RectangleWithin(r: TRect; ABorderColor: TBGRAPixel; w: single; AFillColor: TBGRAPixel); overload;
procedure FillRect(x1,y1,x2,y2: single; AColor: TBGRAPixel; APixelCenteredCoordinates: boolean = true); overload;
procedure FillRect(r: TRect; AColor: TBGRAPixel); overload;
procedure FillRect(r: TRectF; AColor: TBGRAPixel; APixelCenteredCoordinates: boolean = false); overload;
procedure FillRect(r: TRect; AScanner: IBGRAScanner); overload; virtual;
procedure RoundRect(x1,y1,x2,y2,rx,ry: single; ABorderColor: TBGRAPixel; options: TRoundRectangleOptions = []); overload;
procedure RoundRect(x1,y1,x2,y2,rx,ry: single; ABorderColor,AFillColor: TBGRAPixel; options: TRoundRectangleOptions = []); overload;
procedure FillRoundRect(x,y,x2,y2,rx,ry: single; AFillColor: TBGRAPixel; options: TRoundRectangleOptions = []; APixelCenteredCoordinates: boolean = true);
procedure Frame3D(var bounds: TRect; width: integer; Style: TGraphicsBevelCut); overload;
procedure Frame3D(var bounds: TRect; width: integer;
Style: TGraphicsBevelCut; LightColor: TBGRAPixel; ShadowColor: TBGRAPixel); overload;
procedure PutImage(x,y: single; ATexture: IBGLTexture; AAlpha: byte = 255); overload;
procedure PutImage(x,y: single; ATexture: IBGLTexture; AColor: TBGRAPixel); overload;
procedure StretchPutImage(x,y,w,h: single; ATexture: IBGLTexture; AAlpha: byte = 255); overload;
procedure StretchPutImage(x,y,w,h: single; ATexture: IBGLTexture; AColor: TBGRAPixel); overload;
procedure StretchPutImage(r: TRect; ATexture: IBGLTexture; AAlpha: byte = 255); overload;
procedure StretchPutImage(r: TRect; ATexture: IBGLTexture; AColor: TBGRAPixel); overload;
procedure PutImageAngle(x,y: single; ATexture: IBGLTexture; angleDeg: single; AAlpha: byte = 255); overload;
procedure PutImageAngle(x,y: single; ATexture: IBGLTexture; angleDeg: single; AColor: TBGRAPixel); overload;
procedure PutImageAffine(const Origin, HAxis, VAxis: TPointF; ATexture: IBGLTexture; AAlpha: byte = 255); overload;
procedure PutImageAffine(const Origin, HAxis, VAxis: TPointF; ATexture: IBGLTexture; AColor: TBGRAPixel); overload;
procedure PutImageAffine(x,y: single; ATexture: IBGLTexture; const AMatrix: TAffineMatrix; AAlpha: byte = 255); overload;
procedure PutImageAffine(x,y: single; ATexture: IBGLTexture; const AMatrix: TAffineMatrix; AColor: TBGRAPixel); overload;
procedure Translate(x,y: single); virtual;
procedure Scale(sx,sy: single); virtual;
procedure RotateDeg(angleCW: single); virtual;
procedure RotateRad(angleCCW: single); virtual;
procedure ResetTransform; virtual;
procedure UseOrthoProjection; overload; virtual;
procedure UseOrthoProjection(AMinX,AMinY,AMaxX,AMaxY: single); overload; virtual;
procedure StartZBuffer; virtual;
procedure EndZBuffer; virtual;
procedure WaitForGPU({%H-}AOption: TWaitForGPUOption); virtual;
function GetImage({%H-}x,{%H-}y,{%H-}w,{%H-}h: integer): TBGRACustomBitmap; virtual;
function CreateFrameBuffer({%H-}AWidth,{%H-}AHeight: integer): TBGLCustomFrameBuffer; virtual;
procedure NoClip;
property ActiveFrameBuffer: TBGLCustomFrameBuffer read FActiveFrameBuffer write SetActiveFrameBuffer;
property Width: integer read GetWidth write SetWidth;
property Height: integer read GetHeight write SetHeight;
property ClipRect: TRect read GetClipRect write SetClipRect;
property Matrix: TAffineMatrix read GetMatrix write SetMatrix;
property ProjectionMatrix: TMatrix4D read GetProjectionMatrix write SetProjectionMatrix;
property BlendMode: TOpenGLBlendMode read GetBlendMode write SetBlendMode;
property FaceCulling: TFaceCulling read GetFaceCulling write SetFaceCulling;
property Lighting: TBGLCustomLighting read GetLighting;
end;
{ TBGLPath }
TBGLPath = class(TBGRAPath)
private
procedure GLDrawProc(const APoints: array of TPointF; AClosed: boolean; AData: pointer);
procedure GLFillProc(const APoints: array of TPointF; AData: pointer);
public
procedure stroke(ACanvas: TBGLCustomCanvas; AColor: TBGRAPixel; AAcceptedDeviation: single = 0.1); overload;
procedure fillConvex(ACanvas: TBGLCustomCanvas; AColor: TBGRAPixel; AAcceptedDeviation: single = 0.1; APixelCenteredCoordinates: boolean = true);
end;
implementation
uses Math, BGRAGradientScanner;
type
TGLStrokeData = record
Color: TBGRAPixel;
Canvas: TBGLCustomCanvas;
end;
TGLFillData = record
Color: TBGRAPixel;
Canvas: TBGLCustomCanvas;
PixelCenteredCoordinates: boolean;
end;
{ TAttributeVariable }
procedure TAttributeVariable.Init(AOwner: TObject; AAttribute: BGRADWord;
AVectorSize: integer; AFloat: boolean);
begin
FOwner := AOwner;
FAttribute:= AAttribute;
FVectorSize:= AVectorSize;
FFloat := AFloat;
FArray := nil;
FRecordOffset := 0;
end;
{ TBGLCustomLighting }
function TBGLCustomLighting.GetActiveShader: TBGLCustomShader;
begin
result := FCurrentShader;
end;
function TBGLCustomLighting.GetSupportShaders: boolean;
begin
result := false;
end;
function TBGLCustomLighting.GetShader(AName: string): TBGLCustomShader;
var index: integer;
begin
if ShaderList = nil then ShaderList := TStringList.Create;
index := ShaderList.IndexOf(AName);
if index = -1 then
result := nil
else
result := TBGLCustomShader(ShaderList.Objects[index]);
end;
procedure TBGLCustomLighting.SetShader(AName: string; AValue: TBGLCustomShader);
var index: integer;
begin
if ShaderList = nil then ShaderList := TStringList.Create;
index := ShaderList.IndexOf(AName);
if AValue = nil then
begin
if index <> -1 then
ShaderList.Delete(index);
end else
begin
if index = -1 then
ShaderList.AddObject(AName,AValue)
else
ShaderList.Objects[index] := AValue;
end;
end;
destructor TBGLCustomLighting.Destroy;
begin
FreeShaders;
FreeAndNil(ShaderList);
inherited Destroy;
end;
procedure TBGLCustomLighting.FreeShaders;
var i: integer;
begin
if Assigned(ShaderList) then
begin
for i := 0 to ShaderList.Count-1 do
ShaderList.Objects[i].Free;
ShaderList.Clear;
end;
end;
procedure TBGLCustomLighting.SetActiveShader(AValue: TBGLCustomShader);
begin
if AValue <> FCurrentShader then
begin
if Assigned(FCurrentShader) then FCurrentShader.EndUse;
FCurrentShader := AValue;
if Assigned(FCurrentShader) then FCurrentShader.StartUse;
end;
end;
{ TBGLPath }
procedure TBGLPath.GLDrawProc(const APoints: array of TPointF;
AClosed: boolean; AData: pointer);
begin
with TGLStrokeData(AData^) do
if AClosed then
Canvas.Polygons(APoints, Color)
else
Canvas.Polylines(APoints, Color);
end;
procedure TBGLPath.GLFillProc(const APoints: array of TPointF; AData: pointer);
begin
with TGLFillData(AData^) do
Canvas.FillPolyConvex(APoints,Color,PixelCenteredCoordinates);
end;
procedure TBGLPath.stroke(ACanvas: TBGLCustomCanvas; AColor: TBGRAPixel; AAcceptedDeviation: single);
var data: TGLStrokeData;
begin
data.Color := AColor;
data.Canvas := ACanvas;
stroke({$IFDEF OBJ}@{$ENDIF}GLDrawProc, AffineMatrixIdentity, AAcceptedDeviation, @data);
end;
procedure TBGLPath.fillConvex(ACanvas: TBGLCustomCanvas; AColor: TBGRAPixel; AAcceptedDeviation: single; APixelCenteredCoordinates: boolean);
var data: TGLFillData;
begin
data.Color := AColor;
data.Canvas := ACanvas;
data.PixelCenteredCoordinates := APixelCenteredCoordinates;
fill({$IFDEF OBJ}@{$ENDIF}GLFillProc, AffineMatrixIdentity, AAcceptedDeviation, @data);
end;
{ TBGLCustomCanvas }
function TBGLCustomCanvas.ComputeEllipseC(r: TRect; AHasBorder: boolean; out
cx, cy, rx, ry: single): boolean;
begin
if (r.right = r.left) or (r.bottom = r.top) then
begin
cx := r.left;
cy := r.top;
rx := 0;
ry := 0;
exit;
end;
SwapRect(r);
cx := (r.left+r.right-1)*0.5;
cy := (r.top+r.bottom-1)*0.5;
rx := (r.right-r.left)*0.5;
ry := (r.bottom-r.top)*0.5;
if AHasBorder then
begin
rx := rx -0.5;
if rx < 0 then rx := 0;
ry := ry -0.5;
if ry < 0 then ry := 0;
end;
result := true;
end;
function TBGLCustomCanvas.GetHeight: integer;
begin
if FActiveFrameBuffer = nil then
result := FHeight
else
result := FActiveFrameBuffer.Height;
end;
function TBGLCustomCanvas.GetWidth: integer;
begin
if FActiveFrameBuffer = nil then
result := FWidth
else
result := FActiveFrameBuffer.Width;
end;
procedure TBGLCustomCanvas.SetWidth(AValue: integer);
begin
if FWidth=AValue then Exit;
FWidth:=AValue;
end;
procedure TBGLCustomCanvas.SetHeight(AValue: integer);
begin
if FHeight=AValue then Exit;
FHeight:=AValue;
end;
function TBGLCustomCanvas.GetClipRect: TRect;
begin
if FNoClip then
result := rect(0,0,Width,Height)
else
result := FClipRect;
end;
procedure TBGLCustomCanvas.SetClipRect(AValue: TRect);
begin
SwapRect(AValue);
with ClipRect do
if (AValue.left = left) and (AValue.top = top) and (AValue.bottom = bottom)
and (AValue.right = right) then exit;
if (AValue.Left = 0) and (AValue.Top = 0) and
(AValue.Right = Width) and (AValue.Bottom = Height) then
NoClip
else
begin
FClipRect := AValue;
EnableScissor(FClipRect);
end;
end;
function TBGLCustomCanvas.GetProjectionMatrix: TMatrix4D;
begin
result := MatrixIdentity4D;
end;
procedure TBGLCustomCanvas.SetProjectionMatrix(const AValue: TMatrix4D);
begin
raise exception.Create('Not implemented');
end;
function TBGLCustomCanvas.GetLighting: TBGLCustomLighting;
begin
result := nil;
raise exception.Create('Not implemented');
end;
procedure TBGLCustomCanvas.InternalContinueShape(const pt: TPoint3D);
begin
raise exception.Create('Not available');
end;
procedure TBGLCustomCanvas.InternalContinueShape(const pt: TPoint3D_128);
begin
raise exception.Create('Not available');
end;
procedure TBGLCustomCanvas.InternalContinueShape(const pt, normal: TPoint3D_128);
begin
raise exception.Create('Not available');
end;
procedure TBGLCustomCanvas.NoClip;
begin
FClipRect := rect(0,0,Width,Height);
FNoClip := true;
DisableScissor;
end;
constructor TBGLCustomCanvas.Create;
begin
FNoClip:= true;
end;
procedure TBGLCustomCanvas.FillTriangles(const APoints: array of TPointF;
AColor: TBGRAPixel; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if (length(APoints) < 3) or (AColor.alpha = 0) then exit;
InternalStartBlendTriangles;
InternalSetColor(AColor);
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
InternalContinueShape(APoints[i]+ofs);
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(const APoints: array of TPointF;
const AColors: array of TBGRAPixel; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendTriangles;
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]+ofs);
end;
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(
const APoints: array of TPoint3D; const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendTriangles;
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(
const APoints: array of TPoint3D_128; const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendTriangles;
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(const APoints,
ANormals: array of TPoint3D_128; const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then raise exception.Create('Length of APoints and AColors do not match');
if length(AColors)<>length(ANormals) then raise exception.Create('Length of APoints and ANormals do not match');
InternalStartBlendTriangles;
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i], ANormals[i]);
end;
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillQuads(const APoints: array of TPointF;
AColor: TBGRAPixel; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if (length(APoints) < 4) or (AColor.alpha = 0) then exit;
InternalStartBlendQuads;
InternalSetColor(AColor);
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
InternalContinueShape(APoints[i]+ofs);
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(const APoints: array of TPointF;
const AColors: array of TBGRAPixel; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendQuads;
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]+ofs);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(
const APoints: array of TPoint3D; const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendQuads;
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(
const APoints: array of TPoint3D_128; const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendQuads;
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(const APoints,
ANormals: array of TPoint3D_128; const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then raise exception.Create('Length of APoints and AColors do not match');
if length(AColors)<>length(ANormals) then raise exception.Create('Length of APoints and ANormals do not match');
InternalStartBlendQuads;
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i], ANormals[i]);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadLinearColor(pt1, pt2, pt3, pt4: TPointF; c1,
c2, c3, c4: TColorF; APixelCenteredCoordinates: boolean);
begin
FillQuadsLinearColor([pt1,pt2,pt3,pt4],[c1,c2,c3,c4],APixelCenteredCoordinates);
end;
procedure TBGLCustomCanvas.FillQuads(const APoints: array of TPointF;
AColor: TColorF; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if (length(APoints) < 4) or (AColor[4] = 0) then exit;
InternalStartBlendQuads;
InternalSetColorF(AColor);
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
InternalContinueShape(APoints[i]+ofs);
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(
const APoints: array of TPointF; const AColors: array of TColorF;
APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendQuads;
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColorF(AColors[i]);
InternalContinueShape(APoints[i]+ofs);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(
const APoints: array of TPoint3D; const AColors: array of TColorF);
var
i: BGRANativeInt;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendQuads;
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColorF(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(
const APoints: array of TPoint3D_128; const AColors: array of TColorF);
var
i: BGRANativeInt;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendQuads;
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColorF(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.FillQuadsLinearColor(const APoints,
ANormals: array of TPoint3D_128; const AColors: array of TColorF);
var
i: BGRANativeInt;
begin
if length(APoints) < 4 then exit;
if length(AColors)<>length(APoints) then raise exception.Create('Length of APoints and AColors do not match');
if length(AColors)<>length(ANormals) then raise exception.Create('Length of APoints and ANormals do not match');
InternalStartBlendQuads;
for i := 0 to length(APoints) - (length(APoints) and 3) - 1 do
begin
InternalSetColorF(AColors[i]);
InternalContinueShape(APoints[i], ANormals[i]);
end;
InternalEndBlendQuads;
end;
procedure TBGLCustomCanvas.PutPixels(const APoints: array of TPointF;
AColor: TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) = 0 then exit;
InternalStartBlend;
InternalSetColor(AColor);
InternalStartPutPixel(APoints[0]);
for i := 1 to high(APoints) do
InternalContinueShape(APoints[i]);
InternalEndBlend;
end;
procedure TBGLCustomCanvas.PutPixels(const APoints: array of TPointF;
const AColors: array of TBGRAPixel);
var
i: BGRANativeInt;
begin
if length(APoints) = 0 then exit;
InternalStartBlend;
InternalSetColor(AColors[0]);
InternalStartPutPixel(APoints[0]);
for i := 1 to high(APoints) do
begin
InternalSetColor(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlend;
end;
procedure TBGLCustomCanvas.FillTrianglesFan(const APoints: array of TPointF;
ACenterColor, ABorderColor: TBGRAPixel; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
firstPoint: boolean;
ofs: TPointF;
begin
if (length(APoints) < 3) or ((ACenterColor.alpha = 0) and (ABorderColor.alpha = 0)) then exit;
InternalStartBlend;
firstPoint := true;
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to high(APoints) do
begin
if isEmptyPointF(APoints[i]) then
begin
if not firstPoint then
begin
InternalEndShape;
firstPoint := true;
end;
end else
begin
if firstPoint then
begin
InternalSetColor(ACenterColor);
InternalStartTriangleFan(APoints[i]+ofs);
InternalSetColor(ABorderColor);
firstPoint := false;
end else
InternalContinueShape(APoints[i]+ofs);
end;
end;
if not firstPoint then InternalEndShape;
InternalEndBlend;
end;
procedure TBGLCustomCanvas.FillTriangleLinearColor(pt1, pt2, pt3: TPointF; c1,
c2, c3: TColorF; APixelCenteredCoordinates: boolean);
begin
FillTrianglesLinearColor([pt1,pt2,pt3],[c1,c2,c3],APixelCenteredCoordinates);
end;
procedure TBGLCustomCanvas.FillTriangles(const APoints: array of TPointF;
AColor: TColorF; APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if (length(APoints) < 3) or (AColor[4] = 0) then exit;
InternalStartBlendTriangles;
InternalSetColorF(AColor);
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
InternalContinueShape(APoints[i]+ofs);
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(
const APoints: array of TPointF; const AColors: array of TColorF;
APixelCenteredCoordinates: boolean);
var
i: BGRANativeInt;
ofs: TPointF;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendTriangles;
if APixelCenteredCoordinates then ofs := PointF(0.5,0.5) else ofs := PointF(0,0);
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
begin
InternalSetColorF(AColors[i]);
InternalContinueShape(APoints[i]+ofs);
end;
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(
const APoints: array of TPoint3D; const AColors: array of TColorF);
var
i: BGRANativeInt;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendTriangles;
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do
begin
InternalSetColorF(AColors[i]);
InternalContinueShape(APoints[i]);
end;
InternalEndBlendTriangles;
end;
procedure TBGLCustomCanvas.FillTrianglesLinearColor(
const APoints: array of TPoint3D_128; const AColors: array of TColorF);
var
i: BGRANativeInt;
begin
if length(APoints) < 3 then exit;
if length(AColors)<>length(APoints) then
raise exception.Create('Length of APoints and AColors do not match');
InternalStartBlendTriangles;
for i := 0 to length(APoints) - (length(APoints) mod 3) - 1 do