schveiguy / raylib-d

Resurrected copy of onroundit's raylib-d
zlib License
57 stars 14 forks source link

LoadTextureFromImage not working #46

Closed bagomot closed 11 months ago

bagomot commented 11 months ago

Example code;

Image image = LoadImage("test.png");
Texture2D texture = LoadTextureFromImage(image);

Output:

INFO: FILEIO: [test.png] File loaded successfully INFO: IMAGE: Data loaded successfully (279x343 | R8G8B8 | 1 mipmaps) Error Program exited with code -1073741819

Raylib version: 5.0.0 Raylib-d version: 5.0.0 OS: Windows 11 x64

Similar C code works.

schveiguy commented 11 months ago

Do you have a full example? Are you calling InitWindow before all this?

bagomot commented 11 months ago

Do you have a full example? Are you calling InitWindow before all this?

You are right, if I run the example https://github.com/D-a-n-i-l-o/raylib-d_examples/blob/main/examples/textures/051_textures_image_loading/source/app.d, then everything works. In my program this is probably executed before the window is called.

schveiguy commented 11 months ago

Yeah InitWindow actually also initializes some things that are needed for textures. See this wiki entry. https://github.com/raysan5/raylib/wiki/Frequently-Asked-Questions#why-does-calling-loadtexture-crash-my-program