BlazingRenderer / BRender

Modernized fork of BRender
MIT License
49 stars 5 forks source link

Segmentation Fault, OpenGL Functions Failed To Load When Attempting To Run Robot Demo #1

Closed austinrseabolt closed 2 years ago

austinrseabolt commented 2 years ago

Compiled on Artix Linux, an Ubuntu 20.04 VM, and MacOS Monterey on Apple Silicon M1. (I've tried this using different graphics drivers as well.) Artix build returns the following info via stdout upon run: INFO: VIDEO: OpenGL Version = 3.2.0 NVIDIA 5.15.43.04 INFO: VIDEO: OpenGL Vendor = NVIDIA Corporation INFO: VIDEO: OpenGL Renderer = NVIDIA GeForce GTX 1070/PCIe/SSE2

MacOS build returns stdout: ERROR: VIDEO: Unable to load OpenGL functions. zsh: segmentation fault ./robot

Additional Error Dialogue: ASSERTION FAILED: CrocDE-BRender/brender-crocde-1.4.0-dev/v1db/actsupt.c:142: "NULL pointer to the parent's new child : a != NULL"

Please mark closed if this is user error on my end

Rexhunter99 commented 2 years ago

Did you update the OpenGL loaders to utilize the MacOS equivalent to LoadProcAddress? If it is using glad, you'll need to pass said function into the gladLoader function. This might be relevant to solving the issue if it is not a software/hardware issue on your end: https://www.khronos.org/opengl/wiki/Load_OpenGL_Functions#MacOSX

Based on what is said there, NSSymbol is the equivalent to use if you must use a LoadProcAddress equivalent, if that isn't necessary you can just call the OpenGL functions as long as they don't resolve to NULL because since MacOS 10.2, all OpenGL functions/extensions are soft linked and the only way to tell if they are actually valid functions is if the extension string exists.

Still, if it fails after all that, you simply lack the hardware features.

crocguy0688 commented 2 years ago

It uses glLoadGen to generate the bindings. It's now pretty old and unmaintained, so I'm not surprised it doesn't work on Mac.

I don't have a Mac to test on, so I probably won't be able to investigate. I'll keep the issue open in the meantime though.

Rexhunter99 commented 2 years ago

It uses glLoadGen to generate the bindings. It's now pretty old and unmaintained, so I'm not surprised it doesn't work on Mac.

Ah I see, apparently MacOS has its own special include header for modern OpenGL, "OpenGL/gl3.h" as opposed to the standardised "GL/glext.h" I too have no access to an Apple device and won't be able to assist more than giving some ideas on how to get the OpenGL contexts working.

austinrseabolt commented 2 years ago

Thanks for the feedback, I'll do some tinkering and see what I can find as far as the Mac OpenGL libraries. I am curious as to why I may be getting this issue on my Desktop PC running Artix and my Ubuntu VMs as well - not sure what the differences are between this and the engine running CrocDE, but CrocDE will run just fine in both environments whereas the robot demo returns segfault errors. I'm not super familiar with C/C++, so it definitely could be user error.

crocguy0688 commented 2 years ago

On the Linux side, it's almost certainly related to not being able to load shaders. Make sure you're running the program from the dat directory. The robot example was a quick hack to demonstrate BRender usage, and there's almost no error checking, unlike CrocDE.

crocguy0688 commented 2 years ago

I've just switched the bindings from glLoadGen to GLAD, can you please give it another try?

austinrseabolt commented 2 years ago

Seems my problem in Linux is that I wasn't running the binary from the dat directory. Did that without cloning the latest commit and it ran fine. New commit also allows me to run on MacOS. Thanks!