Skip to content

Commit

Permalink
use root.unwrap on a vertex layout in boids
Browse files Browse the repository at this point in the history
  • Loading branch information
reczkok committed Jan 23, 2025
1 parent 70cf646 commit 1d61eb3
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions apps/typegpu-docs/src/content/examples/simulation/boids/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,10 @@ const paramsBuffer = root
.$usage('storage');

const triangleVertexBuffer = root
.createBuffer(d.arrayOf(d.f32, 6), [
0.0,
triangleSize,
-triangleSize / 2,
-triangleSize / 2,
triangleSize / 2,
-triangleSize / 2,
.createBuffer(d.arrayOf(d.vec2f, 3), [
d.vec2f(0.0, triangleSize),
d.vec2f(-triangleSize / 2, -triangleSize / 2),
d.vec2f(triangleSize / 2, -triangleSize / 2),
])
.$usage('vertex');

Expand Down Expand Up @@ -276,24 +273,19 @@ const computeModule = root.device.createShaderModule({
}),
});

const vertexLayout = tgpu['~unstable'].vertexLayout((n) =>
d.arrayOf(d.location(0, d.vec2f), n),
);

console.log(root.unwrap(vertexLayout));

const pipeline = root.device.createRenderPipeline({
layout: root.device.createPipelineLayout({
bindGroupLayouts: [root.unwrap(renderBindGroupLayout)],
}),
vertex: {
module: renderModule,
buffers: [
{
arrayStride: 2 * 4,
attributes: [
{
shaderLocation: 0,
offset: 0,
format: 'float32x2' as const,
},
],
},
],
buffers: [root.unwrap(vertexLayout)],
},
fragment: {
module: renderModule,
Expand Down

0 comments on commit 1d61eb3

Please sign in to comment.