Difficult-Rocket/libs/pyglet/gl/wgl_info.py

39 lines
954 B
Python
Raw Permalink Normal View History

2021-04-16 23:21:06 +08:00
"""Cached information about version and extensions of current WGL
implementation.
"""
2021-09-05 00:50:05 +08:00
from ctypes import *
import warnings
2021-04-16 23:21:06 +08:00
2021-09-05 00:50:05 +08:00
from pyglet.gl.lib import MissingFunctionException
from pyglet.gl.gl import *
from pyglet.gl import gl_info
from pyglet.gl.wgl import *
2021-04-16 23:21:06 +08:00
from pyglet.gl.wglext_arb import *
from pyglet.util import asstr
class WGLInfoException(Exception):
pass
class WGLInfo:
def get_extensions(self):
if not gl_info.have_context():
warnings.warn("Can't query WGL until a context is created.")
return []
try:
return asstr(wglGetExtensionsStringEXT()).split()
except MissingFunctionException:
return asstr(cast(glGetString(GL_EXTENSIONS), c_char_p).value).split()
def have_extension(self, extension):
return extension in self.get_extensions()
_wgl_info = WGLInfo()
get_extensions = _wgl_info.get_extensions
have_extension = _wgl_info.have_extension