Skip to content

Commit 7e20f86

Browse files
committed
CLean up formatting
1 parent b1efc28 commit 7e20f86

File tree

9 files changed

+126
-152
lines changed

9 files changed

+126
-152
lines changed

intro_flutter_gpu/codelab_rebuild.yaml

Lines changed: 81 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ steps:
166166
167167
// Define our triangle vertices
168168
const floatsPerVertex = 2;
169-
final vertices = Float32List.fromList([
170-
-0.5, -0.5, // First vertex
171-
0.5, -0.5, // Second vertex
172-
0.0, 0.5, // Third vertex
173-
]);
169+
final vertices = Float32List.fromList([-0.5, -0.5, 0.5, -0.5, 0.0, 0.5]);
174170
175171
// Create a GPU buffer for our vertices
176172
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
@@ -366,7 +362,7 @@ steps:
366362
final vert = shaderLibrary['SimpleVertex'];
367363
if (vert == null) {
368364
throw Exception('Failed to load SimpleVertex vertex shader');
369-
@@ -63,18 +59,16 @@ class TrianglePainter extends CustomPainter {
365+
@@ -63,14 +59,16 @@ class TrianglePainter extends CustomPainter {
370366
throw Exception('Failed to load SimpleFragment fragment shader');
371367
}
372368
@@ -375,30 +371,28 @@ steps:
375371
376372
- // Define our triangle vertices
377373
- const floatsPerVertex = 2;
374+
- final vertices = Float32List.fromList([-0.5, -0.5, 0.5, -0.5, 0.0, 0.5]);
378375
+ const floatsPerVertex = 5; // Now 2 for position + 3 for color
379-
final vertices = Float32List.fromList([
380-
- -0.5, -0.5, // First vertex
381-
- 0.5, -0.5, // Second vertex
382-
- 0.0, 0.5, // Third vertex
376+
+ final vertices = Float32List.fromList([
383377
+ // Format: x, y, r, g, b
384-
+ -0.5, -0.5, 1.0, 0.0, 0.0, // bottom left - red
385-
+ 0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
386-
+ 0.0, 0.5, 0.0, 0.0, 1.0, // top - blue
387-
]);
378+
+ -0.5, -0.5, 1.0, 0.0, 0.0,
379+
+ 0.5, -0.5, 0.0, 1.0, 0.0,
380+
+ 0.0, 0.5, 0.0, 0.0, 1.0,
381+
+ ]);
388382
389383
- // Create a GPU buffer for our vertices
390384
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
391385
ByteData.sublistView(vertices),
392386
);
393-
@@ -82,7 +76,6 @@ class TrianglePainter extends CustomPainter {
387+
@@ -78,7 +76,6 @@ class TrianglePainter extends CustomPainter {
394388
throw Exception('Failed to create vertices device buffer');
395389
}
396390
397391
- // Bind the pipeline and vertex buffer
398392
renderPass.bindPipeline(pipeline);
399393
400394
final verticesView = gpu.BufferView(
401-
@@ -95,10 +88,8 @@ class TrianglePainter extends CustomPainter {
395+
@@ -91,10 +88,8 @@ class TrianglePainter extends CustomPainter {
402396
vertices.length ~/ floatsPerVertex,
403397
);
404398
@@ -457,7 +451,7 @@ steps:
457451
patch-u: |
458452
--- b/intro_flutter_gpu/step_03/lib/main.dart
459453
+++ a/intro_flutter_gpu/step_03/lib/main.dart
460-
@@ -61,12 +61,19 @@ class TrianglePainter extends CustomPainter {
454+
@@ -61,12 +61,18 @@ class TrianglePainter extends CustomPainter {
461455
462456
final pipeline = gpu.gpuContext.createRenderPipeline(vert, frag);
463457
@@ -467,15 +461,14 @@ steps:
467461
// Format: x, y, r, g, b
468462
+
469463
+ // Triangle #1
470-
-0.5, -0.5, 1.0, 0.0, 0.0, // bottom left - red
471-
0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
472-
- 0.0, 0.5, 0.0, 0.0, 1.0, // top - blue
473-
+ -0.5, 0.5, 0.0, 0.0, 1.0, // top left - blue
474-
+
464+
-0.5, -0.5, 1.0, 0.0, 0.0,
465+
0.5, -0.5, 0.0, 1.0, 0.0,
466+
- 0.0, 0.5, 0.0, 0.0, 1.0,
467+
+ -0.5, 0.5, 0.0, 0.0, 1.0,
475468
+ // Triangle #2
476-
+ 0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
477-
+ 0.5, 0.5, 1.0, 1.0, 0.0, // top right - yellow
478-
+ -0.5, 0.5, 0.0, 0.0, 1.0, // top left - blue
469+
+ 0.5, -0.5, 0.0, 1.0, 0.0,
470+
+ 0.5, 0.5, 1.0, 1.0, 0.0,
471+
+ -0.5, 0.5, 0.0, 0.0, 1.0,
479472
]);
480473
481474
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
@@ -493,24 +486,23 @@ steps:
493486
patch-u: |
494487
--- b/intro_flutter_gpu/step_04/lib/main.dart
495488
+++ a/intro_flutter_gpu/step_04/lib/main.dart
496-
@@ -66,14 +66,14 @@ class TrianglePainter extends CustomPainter {
489+
@@ -66,13 +66,13 @@ class TrianglePainter extends CustomPainter {
497490
// Format: x, y, r, g, b
498491
499492
// Triangle #1
500-
- -0.5, -0.5, 1.0, 0.0, 0.0, // bottom left - red
501-
- 0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
502-
- -0.5, 0.5, 0.0, 0.0, 1.0, // top left - blue
503-
+ -0.5, -0.5, 0.0, 0.0, 1.0, // bottom left - blue
504-
+ 0.5, -0.5, 1.0, 1.0, 0.0, // bottom right - yellow
505-
+ -0.5, 0.5, 1.0, 0.0, 0.0, // top left - red
506-
493+
- -0.5, -0.5, 1.0, 0.0, 0.0,
494+
- 0.5, -0.5, 0.0, 1.0, 0.0,
495+
- -0.5, 0.5, 0.0, 0.0, 1.0,
496+
+ -0.5, -0.5, 0.0, 0.0, 1.0,
497+
+ 0.5, -0.5, 1.0, 1.0, 0.0,
498+
+ -0.5, 0.5, 1.0, 0.0, 0.0,
507499
// Triangle #2
508-
- 0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
509-
- 0.5, 0.5, 1.0, 1.0, 0.0, // top right - yellow
510-
- -0.5, 0.5, 0.0, 0.0, 1.0, // top left - blue
511-
+ 0.5, -0.5, 1.0, 1.0, 0.0, // bottom right - yellow
512-
+ 0.5, 0.5, 0.0, 1.0, 0.0, // top right - green
513-
+ -0.5, 0.5, 1.0, 0.0, 0.0, // top left - red
500+
- 0.5, -0.5, 0.0, 1.0, 0.0,
501+
- 0.5, 0.5, 1.0, 1.0, 0.0,
502+
- -0.5, 0.5, 0.0, 0.0, 1.0,
503+
+ 0.5, -0.5, 1.0, 1.0, 0.0,
504+
+ 0.5, 0.5, 0.0, 1.0, 0.0,
505+
+ -0.5, 0.5, 1.0, 0.0, 0.0,
514506
]);
515507
516508
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
@@ -528,7 +520,7 @@ steps:
528520
patch-u: |
529521
--- b/intro_flutter_gpu/step_05/lib/main.dart
530522
+++ a/intro_flutter_gpu/step_05/lib/main.dart
531-
@@ -61,19 +61,19 @@ class TrianglePainter extends CustomPainter {
523+
@@ -61,18 +61,18 @@ class TrianglePainter extends CustomPainter {
532524
533525
final pipeline = gpu.gpuContext.createRenderPipeline(vert, frag);
534526
@@ -539,20 +531,19 @@ steps:
539531
+ // Format: x, y, u, v
540532
541533
// Triangle #1
542-
- -0.5, -0.5, 0.0, 0.0, 1.0, // bottom left - blue
543-
- 0.5, -0.5, 1.0, 1.0, 0.0, // bottom right - yellow
544-
- -0.5, 0.5, 1.0, 0.0, 0.0, // top left - red
545-
+ -0.5, -0.5, 0.0, 0.0, // bottom left
546-
+ 0.5, -0.5, 1.0, 0.0, // bottom right
547-
+ -0.5, 0.5, 0.0, 1.0, // top left
548-
534+
- -0.5, -0.5, 0.0, 0.0, 1.0,
535+
- 0.5, -0.5, 1.0, 1.0, 0.0,
536+
- -0.5, 0.5, 1.0, 0.0, 0.0,
537+
+ -0.5, -0.5, 0.0, 0.0,
538+
+ 0.5, -0.5, 1.0, 0.0,
539+
+ -0.5, 0.5, 0.0, 1.0,
549540
// Triangle #2
550-
- 0.5, -0.5, 1.0, 1.0, 0.0, // bottom right - yellow
551-
- 0.5, 0.5, 0.0, 1.0, 0.0, // top right - green
552-
- -0.5, 0.5, 1.0, 0.0, 0.0, // top left - red
553-
+ 0.5, -0.5, 1.0, 0.0, // bottom right
554-
+ 0.5, 0.5, 1.0, 1.0, // top right
555-
+ -0.5, 0.5, 0.0, 1.0, // top left
541+
- 0.5, -0.5, 1.0, 1.0, 0.0,
542+
- 0.5, 0.5, 0.0, 1.0, 0.0,
543+
- -0.5, 0.5, 1.0, 0.0, 0.0,
544+
+ 0.5, -0.5, 1.0, 0.0,
545+
+ 0.5, 0.5, 1.0, 1.0,
546+
+ -0.5, 0.5, 0.0, 1.0,
556547
]);
557548
558549
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
@@ -615,31 +606,29 @@ steps:
615606
patch-u: |
616607
--- b/intro_flutter_gpu/step_06/lib/main.dart
617608
+++ a/intro_flutter_gpu/step_06/lib/main.dart
618-
@@ -61,19 +61,19 @@ class TrianglePainter extends CustomPainter {
609+
@@ -61,18 +61,18 @@ class TrianglePainter extends CustomPainter {
619610
620611
final pipeline = gpu.gpuContext.createRenderPipeline(vert, frag);
621612
622613
- const floatsPerVertex = 4; // Now 2 for position + 2 for UV
623614
+ const floatsPerVertex = 4; // 2 for position + 2 for UV
624615
final vertices = Float32List.fromList([
625616
// Format: x, y, u, v
626-
-
627-
+
628-
// Triangle #1
629-
- -0.5, -0.5, 0.0, 0.0, // bottom left
630-
- 0.5, -0.5, 1.0, 0.0, // bottom right
631-
- -0.5, 0.5, 0.0, 1.0, // top left
632-
+ -0.8, -0.8, -1.0, -1.0, // bottom left
633-
+ 0.8, -0.8, 1.0, -1.0, // bottom right
634-
+ -0.8, 0.8, -1.0, 1.0, // top left
635617
618+
// Triangle #1
619+
- -0.5, -0.5, 0.0, 0.0,
620+
- 0.5, -0.5, 1.0, 0.0,
621+
- -0.5, 0.5, 0.0, 1.0,
622+
+ -0.8, -0.8, -1.0, -1.0,
623+
+ 0.8, -0.8, 1.0, -1.0,
624+
+ -0.8, 0.8, -1.0, 1.0,
636625
// Triangle #2
637-
- 0.5, -0.5, 1.0, 0.0, // bottom right
638-
- 0.5, 0.5, 1.0, 1.0, // top right
639-
- -0.5, 0.5, 0.0, 1.0, // top left
640-
+ 0.8, -0.8, 1.0, -1.0, // bottom right
641-
+ 0.8, 0.8, 1.0, 1.0, // top right
642-
+ -0.8, 0.8, -1.0, 1.0, // top left
626+
- 0.5, -0.5, 1.0, 0.0,
627+
- 0.5, 0.5, 1.0, 1.0,
628+
- -0.5, 0.5, 0.0, 1.0,
629+
+ 0.8, -0.8, 1.0, -1.0,
630+
+ 0.8, 0.8, 1.0, 1.0,
631+
+ -0.8, 0.8, -1.0, 1.0,
643632
]);
644633
645634
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
@@ -771,25 +760,24 @@ steps:
771760
772761
@override
773762
void paint(Canvas canvas, Size size) {
774-
@@ -61,16 +98,12 @@ class TrianglePainter extends CustomPainter {
763+
@@ -61,15 +98,12 @@ class TrianglePainter extends CustomPainter {
775764
776765
final pipeline = gpu.gpuContext.createRenderPipeline(vert, frag);
777766
778767
- const floatsPerVertex = 4; // 2 for position + 2 for UV
779768
+ const floatsPerVertex = 4;
780769
final vertices = Float32List.fromList([
781770
// Format: x, y, u, v
782-
-
783-
- // Triangle #1
784-
-0.8, -0.8, -1.0, -1.0, // bottom left
785-
0.8, -0.8, 1.0, -1.0, // bottom right
786-
-0.8, 0.8, -1.0, 1.0, // top left
787771
-
772+
- // Triangle #1
773+
-0.8, -0.8, -1.0, -1.0,
774+
0.8, -0.8, 1.0, -1.0,
775+
-0.8, 0.8, -1.0, 1.0,
788776
- // Triangle #2
789-
0.8, -0.8, 1.0, -1.0, // bottom right
790-
0.8, 0.8, 1.0, 1.0, // top right
791-
-0.8, 0.8, -1.0, 1.0, // top left
792-
@@ -83,6 +116,22 @@ class TrianglePainter extends CustomPainter {
777+
0.8, -0.8, 1.0, -1.0,
778+
0.8, 0.8, 1.0, 1.0,
779+
-0.8, 0.8, -1.0, 1.0,
780+
@@ -82,6 +116,22 @@ class TrianglePainter extends CustomPainter {
793781
throw Exception('Failed to create vertices device buffer');
794782
}
795783
@@ -812,7 +800,7 @@ steps:
812800
renderPass.bindPipeline(pipeline);
813801
814802
final verticesView = gpu.BufferView(
815-
@@ -95,6 +144,14 @@ class TrianglePainter extends CustomPainter {
803+
@@ -94,6 +144,14 @@ class TrianglePainter extends CustomPainter {
816804
vertices.length ~/ floatsPerVertex,
817805
);
818806
@@ -881,10 +869,10 @@ steps:
881869
final model = vm.Matrix4.rotationY(angle);
882870
+ final view = vm.Matrix4.translation(vm.Vector3(0.0, 0.0, -2.0));
883871
+ final projection = vm.makePerspectiveMatrix(
884-
+ vm.radians(45), // 45-degree field of view
885-
+ size.aspectRatio, // Screen aspect ratio
886-
+ 0.1, // Near clipping plane
887-
+ 100.0, // Far clipping plane
872+
+ vm.radians(45),
873+
+ size.aspectRatio,
874+
+ 0.1,
875+
+ 100.0,
888876
+ );
889877
890878
- // Create uniform buffer with transformation matrix
@@ -934,12 +922,12 @@ steps:
934922
+ const floatsPerVertex = 6; // 3 for position + 3 for color
935923
final vertices = Float32List.fromList([
936924
- // Format: x, y, u, v
937-
- -0.8, -0.8, -1.0, -1.0, // bottom left
938-
- 0.8, -0.8, 1.0, -1.0, // bottom right
939-
- -0.8, 0.8, -1.0, 1.0, // top left
940-
- 0.8, -0.8, 1.0, -1.0, // bottom right
941-
- 0.8, 0.8, 1.0, 1.0, // top right
942-
- -0.8, 0.8, -1.0, 1.0, // top left
925+
- -0.8, -0.8, -1.0, -1.0,
926+
- 0.8, -0.8, 1.0, -1.0,
927+
- -0.8, 0.8, -1.0, 1.0,
928+
- 0.8, -0.8, 1.0, -1.0,
929+
- 0.8, 0.8, 1.0, 1.0,
930+
- -0.8, 0.8, -1.0, 1.0,
943931
+ // Format: x, y, z, r, g, b
944932
+
945933
+ // Back Face
@@ -992,22 +980,16 @@ steps:
992980
]);
993981
994982
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(
995-
@@ -116,17 +158,15 @@ class TrianglePainter extends CustomPainter {
983+
@@ -116,7 +158,6 @@ class TrianglePainter extends CustomPainter {
996984
throw Exception('Failed to create vertices device buffer');
997985
}
998986
999987
- // Create transformation matrices
1000988
final model = vm.Matrix4.rotationY(angle);
1001989
final view = vm.Matrix4.translation(vm.Vector3(0.0, 0.0, -2.0));
1002990
final projection = vm.makePerspectiveMatrix(
1003-
- vm.radians(45), // 45-degree field of view
1004-
- size.aspectRatio, // Screen aspect ratio
1005-
- 0.1, // Near clipping plane
1006-
- 100.0, // Far clipping plane
1007-
+ vm.radians(45),
1008-
+ size.aspectRatio,
1009-
+ 0.1,
1010-
+ 100.0,
991+
@@ -126,7 +167,6 @@ class TrianglePainter extends CustomPainter {
992+
100.0,
1011993
);
1012994
1013995
- // Pack matrices into uniform buffer

intro_flutter_gpu/step_01/lib/main.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ class TrianglePainter extends CustomPainter {
6868

6969
// Define our triangle vertices
7070
const floatsPerVertex = 2;
71-
final vertices = Float32List.fromList([
72-
-0.5, -0.5, // First vertex
73-
0.5, -0.5, // Second vertex
74-
0.0, 0.5, // Third vertex
75-
]);
71+
final vertices = Float32List.fromList([-0.5, -0.5, 0.5, -0.5, 0.0, 0.5]);
7672

7773
// Create a GPU buffer for our vertices
7874
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(

intro_flutter_gpu/step_02/lib/main.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class TrianglePainter extends CustomPainter {
6464
const floatsPerVertex = 5; // Now 2 for position + 3 for color
6565
final vertices = Float32List.fromList([
6666
// Format: x, y, r, g, b
67-
-0.5, -0.5, 1.0, 0.0, 0.0, // bottom left - red
68-
0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
69-
0.0, 0.5, 0.0, 0.0, 1.0, // top - blue
67+
-0.5, -0.5, 1.0, 0.0, 0.0,
68+
0.5, -0.5, 0.0, 1.0, 0.0,
69+
0.0, 0.5, 0.0, 0.0, 1.0,
7070
]);
7171

7272
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(

intro_flutter_gpu/step_03/lib/main.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ class TrianglePainter extends CustomPainter {
6666
// Format: x, y, r, g, b
6767

6868
// Triangle #1
69-
-0.5, -0.5, 1.0, 0.0, 0.0, // bottom left - red
70-
0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
71-
-0.5, 0.5, 0.0, 0.0, 1.0, // top left - blue
72-
69+
-0.5, -0.5, 1.0, 0.0, 0.0,
70+
0.5, -0.5, 0.0, 1.0, 0.0,
71+
-0.5, 0.5, 0.0, 0.0, 1.0,
7372
// Triangle #2
74-
0.5, -0.5, 0.0, 1.0, 0.0, // bottom right - green
75-
0.5, 0.5, 1.0, 1.0, 0.0, // top right - yellow
76-
-0.5, 0.5, 0.0, 0.0, 1.0, // top left - blue
73+
0.5, -0.5, 0.0, 1.0, 0.0,
74+
0.5, 0.5, 1.0, 1.0, 0.0,
75+
-0.5, 0.5, 0.0, 0.0, 1.0,
7776
]);
7877

7978
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(

intro_flutter_gpu/step_04/lib/main.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ class TrianglePainter extends CustomPainter {
6666
// Format: x, y, r, g, b
6767

6868
// Triangle #1
69-
-0.5, -0.5, 0.0, 0.0, 1.0, // bottom left - blue
70-
0.5, -0.5, 1.0, 1.0, 0.0, // bottom right - yellow
71-
-0.5, 0.5, 1.0, 0.0, 0.0, // top left - red
72-
69+
-0.5, -0.5, 0.0, 0.0, 1.0,
70+
0.5, -0.5, 1.0, 1.0, 0.0,
71+
-0.5, 0.5, 1.0, 0.0, 0.0,
7372
// Triangle #2
74-
0.5, -0.5, 1.0, 1.0, 0.0, // bottom right - yellow
75-
0.5, 0.5, 0.0, 1.0, 0.0, // top right - green
76-
-0.5, 0.5, 1.0, 0.0, 0.0, // top left - red
73+
0.5, -0.5, 1.0, 1.0, 0.0,
74+
0.5, 0.5, 0.0, 1.0, 0.0,
75+
-0.5, 0.5, 1.0, 0.0, 0.0,
7776
]);
7877

7978
final verticesDeviceBuffer = gpu.gpuContext.createDeviceBufferWithCopy(

0 commit comments

Comments
 (0)