Requesting OpenGL Version for Render Context can cause late exceptions
- Dominant language
- C#
- Stars
- 804
- Forks
- 294
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 1
Description
Render Contexts are created with a requested OpenGL version. The function `UpdateContextVersion` can fail silently, leading to difficult to debug exceptions.
For example, on a `Intel(R) HD Graphics 4000` (e.g. Lenovo T430s), running the ModernOpenGLSample throwns an exception, saying that `glCreateShader` cannot be loaded. This seems to defy logic as the OpenGL version of the context is 4_4. The issue is:
``` cs
var hrc = gl.CreateContextAttribsARB(IntPtr.Zero, attributes);
Win32.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero);
Win32.wglDeleteContext(renderContextHandle);
Win32.wglMakeCurrent(deviceContextHandle, hrc);
renderContextHandle = hrc;
```
After the call to `gl.CreateContextAttribsARB` we may return a null render context handle. Then we proceed to make it current. Any further calls will fail.
A short-term fix would be to throw an exception if the result is null. A better fix would be for the creator of a render context to specify their desired OpenGL version, as well as the minimum version that can be fallen back to.
The fact that we don't throw here leads to late exceptions that are far removed from the root cause and extremely difficult to debug. However, as this functionality relates to render contexts (which will be updated at least slightly in 3.0) it may be best to wait till then before fixing this bug.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.