Skip to content

Commit

Permalink
Update getting-started to 2.30.2
Browse files Browse the repository at this point in the history
  • Loading branch information
smack0007 committed Sep 30, 2024
1 parent 1ad0309 commit 55b52f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
17 changes: 17 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@
},
"problemMatcher": ["$deno"]
},
{
"label": "Run Getting Started",
"group": {
"kind": "none",
"isDefault": true
},
"type": "deno",
"command": "task",
"args": ["start"],
"options": {
"env": {
"GDK_BACKEND": "wayland"
},
"cwd": "${workspaceFolder}/examples/getting-started"
},
"problemMatcher": ["$deno"]
},
{
"label": "Run Hello World",
"group": {
Expand Down
2 changes: 1 addition & 1 deletion examples/getting-started/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"imports": { "@smack0007/sdl-ts": "jsr:@smack0007/sdl-ts" },
"imports": { "@smack0007/sdl-ts": "jsr:@smack0007/sdl-ts@2.30.2" },
"tasks": {
"start": "deno run --unstable-ffi --allow-env --allow-ffi --allow-read=. ./main.ts"
}
Expand Down
23 changes: 8 additions & 15 deletions examples/getting-started/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SDL } from "@smack0007/sdl-ts";

function main(): number {
function main(): void {
SDL.Init(SDL.InitFlags.VIDEO);

const window = SDL.CreateWindow(
Expand All @@ -9,21 +9,11 @@ function main(): number {
SDL.WindowPos.CENTERED,
1024,
768,
SDL.WindowFlags.SHOWN | SDL.WindowFlags.RESIZABLE
SDL.WindowFlags.SHOWN | SDL.WindowFlags.RESIZABLE,
);

if (window == null) {
console.error(`Failed to create window: ${SDL.GetError()}`);
return 1;
}

const renderer = SDL.CreateRenderer(window, 0, SDL.RendererFlags.ACCELERATED);

if (renderer === null) {
console.error(`Failed to create window: ${SDL.GetError()}`);
return 1;
}

SDL.RenderClear(renderer);
SDL.RenderPresent(renderer);

Expand All @@ -41,8 +31,11 @@ function main(): number {

SDL.DestroyWindow(window);
SDL.Quit();

return 0;
}

Deno.exit(main());
try {
main();
} catch (error) {
console.error(error);
Deno.exit(1);
}

0 comments on commit 55b52f7

Please sign in to comment.