Chess-Challenge icon indicating copy to clipboard operation
Chess-Challenge copied to clipboard

Memory error in Raylib

Open predo2810 opened this issue 2 years ago • 17 comments

So, when i try to run the application, a console window open, and, after about 1 second of loading, this show up:

image

I don't really know what's happening, and, since the only modifiable file is the MyBot.cs, i don't think it would be fair for me to try to fix this myself...

I'm using visual studio 2022, i installed the C# (.NET) development and the desktop development with C# (I don't I'm missing something)

image (it's in Portuguese and it says: Desktop development with .NET (left one) and Universal Windows platform development (right one))

predo2810 avatar Jul 21 '23 18:07 predo2810

I have the same. I'll try to figure out a workaround but I have really no idea what's going on. And yes on Visual Studio 2022.

zment4 avatar Jul 23 '23 01:07 zment4

If I set SDF_ENABLED I get the same memory error but from LoadFontEx... 🤔

zment4 avatar Jul 23 '23 01:07 zment4

@zment4 something is definitely wrong XD You're using Windows 11?

predo2810 avatar Jul 23 '23 01:07 predo2810

Windows 10 Home

zment4 avatar Jul 23 '23 01:07 zment4

@zment4 ok... so the problem is not windows

predo2810 avatar Jul 23 '23 01:07 predo2810

I tested with a base raylib project, and it fails on creating a GL window. My current thesis on the problem is that my laptop's GPU is not supported by raylib 😢

zment4 avatar Jul 23 '23 02:07 zment4

oh no... That's probably my problem too... i don't really have a GPU so...

predo2810 avatar Jul 23 '23 02:07 predo2810

Talking with people on raylib discord we found the problem was OpenGL version support. Raylib defaults to OpenGL 3.3, but my laptop GPU doesn't support that high. Raylib can be compiled with an earlier version, so they made a test for OpenGL 2.1 and that worked just fine. I'm currently in the process of figuring out how to do it on my own so I can maybe share that if I get it working.

zment4 avatar Jul 23 '23 02:07 zment4

@zment4 Yeaaah! Thank you dude :D

predo2810 avatar Jul 23 '23 03:07 predo2810

Alright, managed to finally test the project with a Raylib DLL built for OpenGL 2.1. After building, the raylib.dll needs to be replaced with this one raylib_ogl21.zip at location Chess-Challenge\bin\Release\net6.0\runtimes\win-x64\native and in case the problem was no support for OpenGL 3.3, this should make it run now.

If I understand the build system correctly, the raylib.dll will get replaced after every build, so it's a bit of a chore, but I'll try to figure out a way to either make the replacing automatic (post-build copy action maybe?) or replace the DLL where it gets copied from in the first place.

zment4 avatar Jul 23 '23 11:07 zment4

@zment4 Perfect, do you want to let the issue open?

(For further improvements)

predo2810 avatar Jul 23 '23 13:07 predo2810

I don't mind either way. Seeing as this is more a workaround than a fix it might as well be left open.

Oh and btw setting up a post-build step for copying the dll to the correct folder like so copy /Y $(ProjectDir)..\raylib_ogl21.dll $(OutDir)runtimes\win-x64\native\raylib.dll made building and running the program so much easier.

zment4 avatar Jul 23 '23 14:07 zment4

I don't mind either way. Seeing as this is more a workaround than a fix it might as well be left open.

Oh and btw setting up a post-build step for copying the dll to the correct folder like so copy /Y $(ProjectDir)..\raylib_ogl21.dll $(OutDir)runtimes\win-x64\native\raylib.dll made building and running the program so much easier.

So, you found a "usable" fix for now? Until now i made nothing except for thinking about what to do because i couldn't test the project :,)

predo2810 avatar Jul 23 '23 15:07 predo2810

Yes, replacing the Raylib-cs provided raylib.dll (which use OpenGL 3.3) with one that was compiled targeting OpenGL 2.1 (the one I linked) fixes the issue for me. With the post-build step copy it's also pretty seamless, after setting it up it works after every build without unnecessary manual copying.

zment4 avatar Jul 23 '23 16:07 zment4

I will test it to see if i get something to work

predo2810 avatar Jul 23 '23 22:07 predo2810

@zment4 - Well, it seems like my computer is worst than i expected... After doing what you said, and even after that, fixing some more things, i still didn't get it to work...

predo2810 avatar Jul 23 '23 23:07 predo2810

I looked further into (at least my) the dotnet command lines and used dotnet run Chess-Challenge.csproj --no-build to run the project and it worked without error. You still have to replace the "raylib.dll" file every time, but that can be fixed from one of the comments from @zment4 .

Thomas-Dvorak avatar May 30 '24 02:05 Thomas-Dvorak