Output OpenGL version in debug config
This commit is contained in:
parent
0f00b0cfb6
commit
d89e68f5e9
6 changed files with 26 additions and 7 deletions
|
|
@ -17,7 +17,7 @@
|
|||
from .child import cmdline_of_pid
|
||||
from .cli import version
|
||||
from .constants import extensions_dir, is_macos, is_wayland, kitty_base_dir, kitty_exe, shell_path
|
||||
from .fast_data_types import Color, SingleKey, num_users, wayland_compositor_data
|
||||
from .fast_data_types import Color, SingleKey, num_users, opengl_version_string, wayland_compositor_data
|
||||
from .options.types import Options as KittyOpts
|
||||
from .options.types import defaults
|
||||
from .options.utils import KeyboardMode, KeyDefinition
|
||||
|
|
@ -246,6 +246,7 @@ def debug_config(opts: KittyOpts) -> str:
|
|||
p(f.read().strip())
|
||||
if not is_macos:
|
||||
p('Running under:', green(compositor_name()))
|
||||
p(green('OpenGL:'), opengl_version_string())
|
||||
p(green('Frozen:'), 'True' if getattr(sys, 'frozen', False) else 'False')
|
||||
p(green('Paths:'))
|
||||
p(yellow(' kitty:'), os.path.realpath(kitty_exe()))
|
||||
|
|
|
|||
|
|
@ -1580,3 +1580,4 @@ def terminfo_data() -> bytes:...
|
|||
def wayland_compositor_data() -> Tuple[int, Optional[str]]:...
|
||||
def monotonic() -> float: ...
|
||||
def timed_debug_print(x: str) -> None: ...
|
||||
def opengl_version_string() -> str: ...
|
||||
|
|
|
|||
21
kitty/gl.c
21
kitty/gl.c
|
|
@ -38,12 +38,22 @@ check_for_gl_error(void UNUSED *ret, const char *name, GLADapiproc UNUSED funcpt
|
|||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
gl_version_string(void) {
|
||||
static char buf[256];
|
||||
int gl_major = GLAD_VERSION_MAJOR(global_state.gl_version);
|
||||
int gl_minor = GLAD_VERSION_MINOR(global_state.gl_version);
|
||||
const char *gvs = (const char*)glGetString(GL_VERSION);
|
||||
snprintf(buf, sizeof(buf), "'%s' Detected version: %d.%d", gvs, gl_major, gl_minor);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
gl_init(void) {
|
||||
static bool glad_loaded = false;
|
||||
if (!glad_loaded) {
|
||||
int gl_version = gladLoadGL(glfwGetProcAddress);
|
||||
if (!gl_version) {
|
||||
global_state.gl_version = gladLoadGL(glfwGetProcAddress);
|
||||
if (!global_state.gl_version) {
|
||||
fatal("Loading the OpenGL library failed");
|
||||
}
|
||||
if (!global_state.debug_rendering) {
|
||||
|
|
@ -57,10 +67,9 @@ gl_init(void) {
|
|||
ARB_TEST(texture_storage);
|
||||
#undef ARB_TEST
|
||||
glad_loaded = true;
|
||||
int gl_major = GLAD_VERSION_MAJOR(gl_version);
|
||||
int gl_minor = GLAD_VERSION_MINOR(gl_version);
|
||||
const char *gvs = (const char*)glGetString(GL_VERSION);
|
||||
if (global_state.debug_rendering) printf("[%.3f] GL version string: '%s' Detected version: %d.%d\n", monotonic_t_to_s_double(monotonic()), gvs, gl_major, gl_minor);
|
||||
int gl_major = GLAD_VERSION_MAJOR(global_state.gl_version);
|
||||
int gl_minor = GLAD_VERSION_MINOR(global_state.gl_version);
|
||||
if (global_state.debug_rendering) printf("[%.3f] GL version string: %s\n", monotonic_t_to_s_double(monotonic()), gl_version_string());
|
||||
if (gl_major < OPENGL_REQUIRED_VERSION_MAJOR || (gl_major == OPENGL_REQUIRED_VERSION_MAJOR && gl_minor < OPENGL_REQUIRED_VERSION_MINOR)) {
|
||||
fatal("OpenGL version is %d.%d, version >= 3.3 required for kitty", gl_major, gl_minor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ typedef struct {
|
|||
|
||||
|
||||
void gl_init(void);
|
||||
const char* gl_version_string(void);
|
||||
void update_surface_size(int w, int h, GLuint offscreen_texture_id);
|
||||
void free_texture(GLuint *tex_id);
|
||||
void free_framebuffer(GLuint *fb_id);
|
||||
|
|
|
|||
|
|
@ -1406,6 +1406,11 @@ dbus_user_notification_activated(uint32_t notification_id, const char* action) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static PyObject*
|
||||
opengl_version_string(PyObject *self UNUSED, PyObject *args UNUSED) {
|
||||
return PyUnicode_FromString(global_state.gl_version ? gl_version_string() : "");
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
glfw_init(PyObject UNUSED *self, PyObject *args) {
|
||||
const char* path;
|
||||
|
|
@ -2228,6 +2233,7 @@ static PyMethodDef module_methods[] = {
|
|||
METHODB(cocoa_hide_other_apps, METH_NOARGS),
|
||||
METHODB(cocoa_minimize_os_window, METH_VARARGS),
|
||||
{"glfw_init", (PyCFunction)glfw_init, METH_VARARGS, ""},
|
||||
METHODB(opengl_version_string, METH_NOARGS),
|
||||
{"glfw_terminate", (PyCFunction)glfw_terminate, METH_NOARGS, ""},
|
||||
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""},
|
||||
{"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""},
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ typedef struct {
|
|||
CloseRequest quit_request;
|
||||
bool redirect_mouse_handling;
|
||||
WindowLogoTable *all_window_logos;
|
||||
int gl_version;
|
||||
} GlobalState;
|
||||
|
||||
extern GlobalState global_state;
|
||||
|
|
|
|||
Loading…
Reference in a new issue