FastVM / Web49

Web49: WebAssembly Interpeter
MIT License
322 stars 15 forks source link

How to use raywasm? #12

Open konsumer opened 1 year ago

konsumer commented 1 year ago

So, I downloaded the mac asset from last successful action workflow, and compiled this:

#include "raylib.h"

int main(void) {
  const int screenWidth = 800;
  const int screenHeight = 450;

  InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing");
  Texture2D texture = LoadTexture("raylib_logo.png");

  while (!WindowShouldClose()) {
    BeginDrawing();
    ClearBackground(RAYWHITE);
    DrawTexture(texture, screenWidth / 2 - texture.width / 2, screenHeight / 2 - texture.height / 2, WHITE);
    DrawText("this IS a texture!", 360, 370, 10, GRAY);
    EndDrawing();
  }

  UnloadTexture(texture);
  CloseWindow();
  return 0;
}

with ./emraylib textures_logo_raylib.c -o textures_logo_raylib then ran ./raywasm textures_logo_raylib.wasm, and it opens and closes, without error. Do I need to structure my code differently?

konsumer commented 1 year ago

I tried this, too (no texture, use emscripten_set_main_loop):

#include <emscripten/emscripten.h>
#include "raylib.h"

const int screenWidth = 800;
const int screenHeight = 450;

void UpdateDrawFrame(void);

int main(void) {
  InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
  emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
  CloseWindow();
  return 0;
}

void UpdateDrawFrame(void) {
  BeginDrawing();
  ClearBackground(RAYWHITE);
  DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
  EndDrawing();
}

Which also compiled fine, but does not open a widow.

konsumer commented 1 year ago

I saw this but it doesn't seem to work (same problem.)

ShawSumma commented 1 year ago

There's a bunch of bugs and i have little time. RayWASM is not exactly working well.

ShawSumma commented 1 year ago

Originally RayWASM started as a test of integrating api other than WASI into Web49's api.

konsumer commented 1 year ago

I totally understand. No prob!