Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make examples work #70

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EventType, WindowBuilder } from "jsr:@divy/[email protected]";
const window = new WindowBuilder("Hello, Deno!", 640, 480).build();
const canvas = window.canvas();

for (const event of window.events()) {
for await (const event of window.events()) {
if (event.type == EventType.Quit) {
break;
} else if (event.type == EventType.Draw) {
Expand Down
2 changes: 1 addition & 1 deletion examples/bouncy_rects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function frame() {
}

// Fire up the event loop
for (const event of window.events()) {
for await (const event of window.events()) {
switch (event.type) {
case EventType.Draw:
await frame();
Expand Down
2 changes: 1 addition & 1 deletion examples/font/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function frame() {
stepFrame();
}

for (const event of window.events()) {
for await (const event of window.events()) {
if (event.type == EventType.Quit) Deno.exit(0);
else if (event.type == EventType.Draw) frame();
}
2 changes: 1 addition & 1 deletion examples/resizable_window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const window = new WindowBuilder("Hello, Deno!", 640, 480).resizable().build();
const canvas = window.canvas();

const fps = FPS();
for (const event of window.events()) {
for await (const event of window.events()) {
fps();
if (event.type == EventType.Quit) {
break;
Expand Down
2 changes: 1 addition & 1 deletion examples/sprite/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function frame() {
sleepSync(10);
}

for (const event of window.events()) {
for await (const event of window.events()) {
switch (event.type) {
case EventType.Draw:
frame();
Expand Down
2 changes: 1 addition & 1 deletion examples/stars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ for (let i = 0; i < star_count; i++) {
stars.push(star);
}

for (const event of window.events()) {
for await (const event of window.events()) {
if (event.type == EventType.Quit) Deno.exit(0);
else if (event.type == EventType.Draw) {
canvas.setDrawColor(0, 0, 0, 255);
Expand Down
3 changes: 1 addition & 2 deletions examples/texture/texture.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
EventType,
PixelFormat,
Rect,
TextureAccess,
WindowBuilder,
} from "../../mod.ts";
Expand All @@ -23,7 +22,7 @@ canvas.copy(texture);
canvas.present();

event_loop:
for (const event of window.events()) {
for await (const event of window.events()) {
switch (event.type) {
case EventType.Quit:
case EventType.KeyDown:
Expand Down
11 changes: 5 additions & 6 deletions webgpu-examples/boids/boids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
Rect,
Texture,
TextureAccess,
Window,
WindowBuilder,
} from "../../mod.ts";
import { FPS } from "../../examples/utils.ts";

class Boids {
particleCount: number;
Expand Down Expand Up @@ -60,7 +60,7 @@ class Boids {
format: "rgba8unorm-srgb",
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
});
const { padded, unpadded } = getRowPadding(this.dimensions.width);
const { padded } = getRowPadding(this.dimensions.width);
this.outputBuffer = this.device.createBuffer({
label: "Capture",
size: padded * this.dimensions.height,
Expand Down Expand Up @@ -263,7 +263,7 @@ class Boids {
view: view,
loadOp: "clear",
storeOp: "store",
loadValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 },
},
],
});
Expand Down Expand Up @@ -384,10 +384,8 @@ const boids = new Boids({
}, await getDevice());
boids.init();

const tick = FPS(100);

async function loop() {
const event = boids.window.events().next().value;
const event = (await boids.window.events().next()).value;
switch (event.type) {
// case EventType.Re: {
// const { width, height } = event;
Expand All @@ -408,6 +406,7 @@ async function loop() {
case EventType.Quit:
case EventType.KeyDown:
Deno.exit(0);
break;
default:
break;
}
Expand Down
Loading