Bigfoot71 / raymob

Simple raylib implementation for Android
Other
86 stars 19 forks source link

Created textures not displaying on Android #14

Closed ASGART1907 closed 6 months ago

ASGART1907 commented 6 months ago

The texture I can create on desktop cannot be created on Android. The path is correct. Am I keeping the image in the wrong place? Here is my code: `#include "raymob.h"

include

include

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

static void UpdateDrawFrame(Texture2D texture);

int main() { InitWindow(screenWidth, screenHeight, "./raylib");

SetTargetFPS(60);          

Texture2D texture = LoadTexture("../rocket2.png");

while (!WindowShouldClose()) {
    UpdateDrawFrame(texture);
}

CloseWindow();              
return 0;

}

static void UpdateDrawFrame(Texture2D texture) { BeginDrawing(); ClearBackground(BLACK); DrawTexture(texture,100,100,RAYWHITE); EndDrawing(); } `

Bigfoot71 commented 6 months ago

Always check the logs in these cases. You use ../ in your code to access the directory, which won't work.

If you want to include files in your application, you have the assets directory along this path from the root of your project: app/src/main/assets.

So, put your image rocket2.png in the assets directory and simply use LoadTexture("rocket2.png"). You can also put it in a subdirectory and use LoadTexture("images/rocket2.png").

Note that on Android, you should prefer using raylib functions to load all your files from the assets directory; they are configured to use the AssetManager on Android.

ASGART1907 commented 6 months ago

This works. Thank you very much for your reply...