zecruel / CadZinho

Minimalist computer aided design (CAD) software
MIT License
177 stars 28 forks source link

Silent crash if OpenGL version is lower than 3.2 #23

Open tpimh opened 2 years ago

tpimh commented 2 years ago

I have tried to build CadZinho with MSVC (VS2019 for both x64 and x86). These are the libraries that I was using:

The executable launches, but crashes with this error:

Access violation - code c0000005
eax=00000000 ebx=00000001 ecx=4e3a7c0a edx=7473bd44 esi=04bc9378 edi=04bc4a28
eip=00000000 esp=04afe018 ebp=04afe058 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00210246
00000000 ??              ???

With a debugger, I figured out that this is the exact line that crashes: https://github.com/zecruel/CadZinho/blob/843a0643115bff043473d1fac5a9c0d12a2f2977/src/draw_gl.c#L54

How can I debug further to provide valuable information?

tpimh commented 2 years ago

I think the problem is actually with my Windows machine, because I have tried a lot of different combinations of libraries, tried building with MINGW and MSVC, and all produced binaries fail exactly the same. Also, tried precompiled version by @zYg-sys, same result. Not really sure what I am missing, as other OpenGL software runs just fine.

zecruel commented 2 years ago

Hi @tpimh .

It could be a problem with the video card driver on your machine. It has been reported that some default drivers on Windows only support older versions of OpenGL. Try to update the drivers with the official version of the video card manufacturer.

The OpenGL version used in CadZinho is 3.2. It's the same one used in Blender 3D, if you want to test another application.

Another possible cause, which I think is unlikely, is the incompatibility of the GLEW DLL, which may have been compiled for another architecture.

tpimh commented 2 years ago

Yes, this was the case! I checked, and my OpenGL version showed OpenGL 1.1, which after the driver update became 3.3, and CadZinho started just fine. I will update the title of the issue now.

Maybe it's a good idea to implement an OpenGL version check before trying to create context? glGetString(GL_VERSION) should be easy to parse, but maybe there is a way to get major and minor versions separately.