mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
Also check for required OpenGL extensions on OS X
This commit is contained in:
24
kitty/gl.h
24
kitty/gl.h
@@ -652,6 +652,29 @@ VertexAttribPointer(PyObject UNUSED *self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
check_for_extensions(PyObject UNUSED *self) {
|
||||||
|
GLint n = 0, i, left = 2;
|
||||||
|
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||||
|
bool texture_storage = false, texture_buffer_object_rgb32 = false;
|
||||||
|
#define CHECK(name) if (!name) { \
|
||||||
|
if (strstr((const char*)ext, "GL_ARB_" #name) == (const char *)ext) { left--; name = true; } \
|
||||||
|
}
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
const GLubyte *ext = glGetStringi(GL_EXTENSIONS, i);
|
||||||
|
CHECK(texture_storage); CHECK(texture_buffer_object_rgb32);
|
||||||
|
if (left < 1) break;
|
||||||
|
}
|
||||||
|
#undef CHECK
|
||||||
|
if (left > 0) {
|
||||||
|
#define CHECK(name) if (!name) { PyErr_Format(PyExc_RuntimeError, "The OpenGL driver on this system is missing the required extension: GL_ARB_%s", #name); return NULL; }
|
||||||
|
CHECK(texture_storage); CHECK(texture_buffer_object_rgb32);
|
||||||
|
#undef CHECK
|
||||||
|
}
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
int add_module_gl_constants(PyObject *module) {
|
int add_module_gl_constants(PyObject *module) {
|
||||||
#define GLC(x) if (PyModule_AddIntConstant(module, #x, x) != 0) { PyErr_NoMemory(); return 0; }
|
#define GLC(x) if (PyModule_AddIntConstant(module, #x, x) != 0) { PyErr_NoMemory(); return 0; }
|
||||||
GLC(GL_VERSION);
|
GLC(GL_VERSION);
|
||||||
@@ -686,6 +709,7 @@ int add_module_gl_constants(PyObject *module) {
|
|||||||
{"enable_automatic_opengl_error_checking", (PyCFunction)enable_automatic_error_checking, METH_O, NULL}, \
|
{"enable_automatic_opengl_error_checking", (PyCFunction)enable_automatic_error_checking, METH_O, NULL}, \
|
||||||
{"copy_image_sub_data", (PyCFunction)copy_image_sub_data, METH_VARARGS, NULL}, \
|
{"copy_image_sub_data", (PyCFunction)copy_image_sub_data, METH_VARARGS, NULL}, \
|
||||||
{"glewInit", (PyCFunction)_glewInit, METH_NOARGS, NULL}, \
|
{"glewInit", (PyCFunction)_glewInit, METH_NOARGS, NULL}, \
|
||||||
|
{"check_for_extensions", (PyCFunction)check_for_extensions, METH_NOARGS, NULL}, \
|
||||||
METH(Viewport, METH_VARARGS) \
|
METH(Viewport, METH_VARARGS) \
|
||||||
METH(CheckError, METH_NOARGS) \
|
METH(CheckError, METH_NOARGS) \
|
||||||
METH(ClearColor, METH_VARARGS) \
|
METH(ClearColor, METH_VARARGS) \
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from .fast_data_types import (
|
|||||||
GLFW_STENCIL_BITS, Window, change_wcwidth,
|
GLFW_STENCIL_BITS, Window, change_wcwidth,
|
||||||
enable_automatic_opengl_error_checking, glClear, glClearColor, glewInit,
|
enable_automatic_opengl_error_checking, glClear, glClearColor, glewInit,
|
||||||
glfw_init, glfw_set_error_callback, glfw_swap_interval, glfw_terminate,
|
glfw_init, glfw_set_error_callback, glfw_swap_interval, glfw_terminate,
|
||||||
glfw_wait_events, glfw_window_hint, glfw_init_hint_string
|
glfw_wait_events, glfw_window_hint, glfw_init_hint_string, check_for_extensions
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
from .fast_data_types import GLFW_X11_WM_CLASS_NAME, GLFW_X11_WM_CLASS_CLASS
|
from .fast_data_types import GLFW_X11_WM_CLASS_NAME, GLFW_X11_WM_CLASS_CLASS
|
||||||
@@ -220,6 +220,8 @@ def run_app(opts, args):
|
|||||||
viewport_size.x_ratio = viewport_size.width / float(w)
|
viewport_size.x_ratio = viewport_size.width / float(w)
|
||||||
viewport_size.y_ratio = viewport_size.height / float(h)
|
viewport_size.y_ratio = viewport_size.height / float(h)
|
||||||
glewInit()
|
glewInit()
|
||||||
|
if isosx:
|
||||||
|
check_for_extensions()
|
||||||
boss = Boss(window, opts, args)
|
boss = Boss(window, opts, args)
|
||||||
boss.start()
|
boss.start()
|
||||||
clear_buffers(window, opts)
|
clear_buffers(window, opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user