Better error message when GLEW initialization fails

This commit is contained in:
Kovid Goyal 2017-10-25 14:32:44 +05:30
parent c5c8a18c99
commit e43a26d64c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 7 additions and 7 deletions

View File

@ -67,17 +67,17 @@ check_for_gl_error(int line) {
#endif
static PyObject*
glew_init(PyObject UNUSED *self) {
glew_init(PyObject UNUSED *self, PyObject *is_wayland) {
#ifndef __APPLE__
GLenum err = glewInit();
if (err != GLEW_OK) {
PyErr_Format(PyExc_RuntimeError, "GLEW init failed: [%d] %s", err, glewGetErrorString(err));
return NULL;
if (PyObject_IsTrue(is_wayland)) {
fatal("GLEW init failed: [%d] %s. On Wayland, GLEW must be compiled with the EGL backend instead of the GLX backend.", err, glewGetErrorString(err));
} else fatal("GLEW init failed: [%d] %s", err, glewGetErrorString(err));
}
#define ARB_TEST(name) \
if (!GLEW_ARB_##name) { \
PyErr_Format(PyExc_RuntimeError, "The OpenGL driver on this system is missing the required extension: ARB_%s", #name); \
return NULL; \
fatal("The OpenGL driver on this system is missing the required extension: ARB_%s", #name); \
}
ARB_TEST(texture_storage);
#undef ARB_TEST

View File

@ -158,7 +158,7 @@ def initialize_window(window, opts):
w, h = window.get_window_size()
viewport_size.x_ratio = viewport_size.width / float(w)
viewport_size.y_ratio = viewport_size.height / float(h)
glewInit()
glewInit(iswayland)
glfw_swap_interval(0)
clear_buffers(window.swap_buffers, color_as_int(opts.background))
# We dont turn this on as it causes rendering performance to be much worse,

View File

@ -596,7 +596,7 @@ PYWRAP0(check_for_extensions) {
#define M(name, arg_type) {#name, (PyCFunction)name, arg_type, NULL}
#define MW(name, arg_type) {#name, (PyCFunction)py##name, arg_type, NULL}
static PyMethodDef module_methods[] = {
{"glewInit", (PyCFunction)glew_init, METH_NOARGS, NULL},
{"glewInit", (PyCFunction)glew_init, METH_O, NULL},
M(compile_program, METH_VARARGS),
MW(check_for_extensions, METH_NOARGS),
MW(create_vao, METH_NOARGS),