SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.78k stars 1.06k forks source link

Memory error in Raylib #75

Open predo2810 opened 1 year ago

predo2810 commented 1 year ago

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))

zment4 commented 1 year ago

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 commented 1 year ago

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

predo2810 commented 1 year ago

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

zment4 commented 1 year ago

Windows 10 Home

predo2810 commented 1 year ago

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

zment4 commented 1 year ago

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 😢

predo2810 commented 1 year ago

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

zment4 commented 1 year ago

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.

predo2810 commented 1 year ago

@zment4 Yeaaah! Thank you dude :D

zment4 commented 1 year ago

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.

predo2810 commented 1 year ago

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

(For further improvements)

zment4 commented 1 year ago

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.

predo2810 commented 1 year ago

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 :,)

zment4 commented 1 year ago

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.

predo2810 commented 1 year ago

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

predo2810 commented 1 year ago

@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...

Thomas-Dvorak commented 1 month ago

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 .