mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 00:38:10 +02:00
Check for required extensions
This commit is contained in:
@@ -6,7 +6,7 @@ import glfw
|
|||||||
import OpenGL.GL as gl
|
import OpenGL.GL as gl
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from kitty.shaders import ShaderProgram, GL_VERSION, Sprites
|
from kitty.shaders import ShaderProgram, GL_VERSION, Sprites, check_for_required_extensions
|
||||||
from kitty.fonts import set_font_family, cell_size
|
from kitty.fonts import set_font_family, cell_size
|
||||||
|
|
||||||
textured_shaders = (
|
textured_shaders = (
|
||||||
@@ -148,6 +148,7 @@ def _main():
|
|||||||
raise SystemExit("glfwCreateWindow failed")
|
raise SystemExit("glfwCreateWindow failed")
|
||||||
glfw.glfwMakeContextCurrent(window)
|
glfw.glfwMakeContextCurrent(window)
|
||||||
glfw.glfwSwapInterval(1)
|
glfw.glfwSwapInterval(1)
|
||||||
|
check_for_required_extensions()
|
||||||
|
|
||||||
# If everything went well the following calls
|
# If everything went well the following calls
|
||||||
# will display the version of opengl being used
|
# will display the version of opengl being used
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from .config import load_config
|
|||||||
from .constants import appname, str_version, config_dir
|
from .constants import appname, str_version, config_dir
|
||||||
from .boss import Boss
|
from .boss import Boss
|
||||||
from .utils import fork_child, hangup
|
from .utils import fork_child, hangup
|
||||||
from .shaders import GL_VERSION
|
from .shaders import GL_VERSION, check_for_required_extensions
|
||||||
import glfw
|
import glfw
|
||||||
|
|
||||||
|
|
||||||
@@ -52,6 +52,7 @@ def run_app(opts, args):
|
|||||||
glfw.glfwSetWindowTitle(window, appname.encode('utf-8'))
|
glfw.glfwSetWindowTitle(window, appname.encode('utf-8'))
|
||||||
try:
|
try:
|
||||||
glfw.glfwMakeContextCurrent(window)
|
glfw.glfwMakeContextCurrent(window)
|
||||||
|
check_for_required_extensions()
|
||||||
glfw.glfwSwapInterval(1)
|
glfw.glfwSwapInterval(1)
|
||||||
boss = Boss(window, window_width, window_height, opts, args)
|
boss = Boss(window, window_width, window_height, opts, args)
|
||||||
glfw.glfwSetFramebufferSizeCallback(window, boss.on_window_resize)
|
glfw.glfwSetFramebufferSizeCallback(window, boss.on_window_resize)
|
||||||
|
|||||||
@@ -13,12 +13,25 @@ from .fonts import render_cell, cell_size
|
|||||||
|
|
||||||
GL_VERSION = (3, 3)
|
GL_VERSION = (3, 3)
|
||||||
VERSION = GL_VERSION[0] * 100 + GL_VERSION[1] * 10
|
VERSION = GL_VERSION[0] * 100 + GL_VERSION[1] * 10
|
||||||
|
REQUIRED_EXTENSIONS = frozenset('GL_ARB_copy_image GL_ARB_texture_storage'.split())
|
||||||
|
|
||||||
|
|
||||||
def array(*args, dtype=gl.GLfloat):
|
def array(*args, dtype=gl.GLfloat):
|
||||||
return (dtype * len(args))(*args)
|
return (dtype * len(args))(*args)
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_required_extensions():
|
||||||
|
num = gl.glGetIntegerv(gl.GL_NUM_EXTENSIONS)
|
||||||
|
required = set(REQUIRED_EXTENSIONS)
|
||||||
|
for i in range(num):
|
||||||
|
ext = gl.glGetStringi(gl.GL_EXTENSIONS, i).decode('utf-8')
|
||||||
|
required.discard(ext)
|
||||||
|
if not required:
|
||||||
|
break
|
||||||
|
if required:
|
||||||
|
raise RuntimeError('Your OpenGL implementation is missing the following required extensions: %s' % ','.join(required))
|
||||||
|
|
||||||
|
|
||||||
class Sprites:
|
class Sprites:
|
||||||
''' Maintain sprite sheets of all rendered characters on the GPU as a texture
|
''' Maintain sprite sheets of all rendered characters on the GPU as a texture
|
||||||
array with each texture being a sprite sheet. '''
|
array with each texture being a sprite sheet. '''
|
||||||
|
|||||||
Reference in New Issue
Block a user