Downgrade OpenGL version requirement to 3.1

There are only a few features required from newer versions, and they
can be achieved via extensions. This significantly improves compatibility.
This commit is contained in:
Hector Martin 2022-12-20 16:22:05 +09:00
parent d8284befd3
commit 84aebae6a8
9 changed files with 5415 additions and 794 deletions

View File

@ -10,8 +10,8 @@ import subprocess
cmdline = (
'glad --out-path {dest} --api gl:core=3.3 '
' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug '
'glad --out-path {dest} --api gl:core=3.1 '
' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_ARB_instanced_arrays,GL_KHR_debug '
'c --header-only --debug'
)

View File

@ -1,4 +1,6 @@
#version GLSL_VERSION
#extension GL_ARB_explicit_attrib_location : require
#define {WHICH_PROGRAM}
#define NOT_TRANSPARENT
#define DECORATION_SHIFT {DECORATION_SHIFT}

View File

@ -18,7 +18,8 @@
#include "banned.h"
// Required minimum OpenGL version
#define OPENGL_REQUIRED_VERSION_MAJOR 3
#define OPENGL_REQUIRED_VERSION_MINOR 3
#define OPENGL_REQUIRED_VERSION_MINOR 1
#define GLSL_VERSION 140
#define GLFW_MOD_KITTY (GLFW_MOD_LAST * 2)
#define UNUSED __attribute__ ((unused))
#define PYNOARG PyObject *__a1 UNUSED, PyObject *__a2 UNUSED

6192
kitty/gl-wrapper.h generated

File diff suppressed because it is too large Load Diff

View File

@ -306,7 +306,7 @@ add_located_attribute_to_vao(ssize_t vao_idx, GLint aloc, GLint size, GLenum dat
break;
}
if (divisor) {
glVertexAttribDivisor(aloc, divisor);
glVertexAttribDivisorARB(aloc, divisor);
}
unbind_buffer(buf);
}

View File

@ -9,8 +9,6 @@
#include "data-types.h"
#include "gl-wrapper.h"
#define GLSL_VERSION (OPENGL_REQUIRED_VERSION_MAJOR * 100 + OPENGL_REQUIRED_VERSION_MINOR * 10)
typedef struct {
GLint size, index;
} UniformBlock;

View File

@ -789,7 +789,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
if (is_first_window) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_REQUIRED_VERSION_MAJOR);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_REQUIRED_VERSION_MINOR);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true);
// We don't use depth and stencil buffers
glfwWindowHint(GLFW_DEPTH_BITS, 0);

View File

@ -1,4 +1,5 @@
#version GLSL_VERSION
#extension GL_ARB_explicit_attrib_location : require
// Have to use fixed locations here as all variants of the program share the same VAO
layout(location=0) in vec4 src;

View File

@ -773,7 +773,7 @@ draw_cells_interleaved_premult(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen
}
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, os_window->offscreen_framebuffer);
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, os_window->offscreen_texture_id, 0);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, os_window->offscreen_texture_id, 0);
/* if (glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) fatal("Offscreen framebuffer not complete"); */
bind_program(CELL_BG_PROGRAM);
if (!has_bgimage(os_window)) {