3 回答
TA贡献1765条经验 获得超5个赞
我设法解决了您的细分错误。以下是在Mac上启用vsync的工作代码:-
import sys
def enable_vsync():
if sys.platform != 'darwin':
return
try:
import ctypes
import ctypes.util
ogl = ctypes.cdll.LoadLibrary(ctypes.util.find_library("OpenGL"))
v = ctypes.c_int(1)
ogl.CGLGetCurrentContext.argtypes = []
ogl.CGLGetCurrentContext.restype = ctypes.c_void_p
ogl.CGLSetParameter.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p]
ogl.CGLSetParameter.restype = ctypes.c_int
context = ogl.CGLGetCurrentContext()
ogl.CGLSetParameter(context, 222, ctypes.pointer(v))
except Exception as e:
print("Unable to set vsync mode, using driver defaults: {}".format(e))
在创建和设置上下文后,只需调用此enable_vsync()函数即可。
添加回答
举报