Simple-OpenGL-Image-Library icon indicating copy to clipboard operation
Simple-OpenGL-Image-Library copied to clipboard

Applied patch to not crash on 3.2+ core profiles

Open smirgol opened this issue 7 years ago • 5 comments

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=727175

Most SOIL functions crash if OpenGL context is 3.2+ core profile. SOIL calls glGetString with a value that is no longer valid, and then sends the returned null pointer to strstr.

This patch checks the OpenGL version at runtime, and uses a glGetString function that is appropriate and available. It doesn't crash if, for whatever reason, glGetString returns a null pointer.

smirgol avatar Apr 12 '18 18:04 smirgol

Hey thanks! I'm curious, but why are the files are severely different? It seems like you've changed a heck of a lot more then just glGetString

kbranigan avatar Apr 12 '18 18:04 kbranigan

Uhm, that's a good question. All I added were the changes from the patch you can find in the bugreport I've linked above, along with a comment that it was patched and where I did get the patch from. Somehow the diff thinks I've changed everything? Might be due to line-endings (I'm on linux), don't know - it's my first pull request ever. :)

smirgol avatar Apr 12 '18 20:04 smirgol

Yep, line-endings. I've changed them back to windows-style. By doing that I've accidentially commited a codeblocks file, which I've then deleted. Here's a patch with the changes only, in case you cannot use the pull request: fix_glGetString_crash.txt

smirgol avatar Apr 12 '18 20:04 smirgol

Thinking about the changes, it likely won't work on windows and maybe mac due to the usage of glXGetProcAddressARB. Maybe the SOIL_internal_has_OGL_capability function could be improved by using parts of njcrawford's code. Can't test that for windows and mac unfortunately.

smirgol avatar Apr 12 '18 21:04 smirgol

I can test it on mac and windows if it's in a state you think it'd work, but unfortunately I'm not familiar with OpenGL 3.2+

kbranigan avatar Apr 17 '18 19:04 kbranigan