Web49 icon indicating copy to clipboard operation
Web49 copied to clipboard

How to use raywasm?

Open konsumer opened this issue 2 years ago • 5 comments

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 avatar Jan 26 '23 02:01 konsumer

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 avatar Jan 26 '23 02:01 konsumer

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

konsumer avatar Jan 28 '23 21:01 konsumer

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

ShawSumma avatar May 07 '23 11:05 ShawSumma

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

ShawSumma avatar May 07 '23 11:05 ShawSumma

I totally understand. No prob!

konsumer avatar May 07 '23 20:05 konsumer