Skip to content

How to use raywasm? #12

Open
Open

Description

@konsumer

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?

Activity

  1. konsumer commented on Jan 26, 2023

    @konsumer
    Author

    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.

  2. konsumer commented on Jan 28, 2023

    @konsumer
    Author

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

  3. ShawSumma commented on May 7, 2023

    @ShawSumma
    Member

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

  4. ShawSumma commented on May 7, 2023

    @ShawSumma
    Member

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

  5. konsumer commented on May 7, 2023

    @konsumer
    Author

    I totally understand. No prob!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions