使用来自 python 64 位的 ANGLE dll 的 eglInitialize 失败
eglInitialize failure using ANGLE dll from python 64 bits
我使用 ANGLE dll 有一段时间了 运行 来自 32 位 python(pi3d 模块)的 windows OpenGLES2.0 代码但是我无法得到它适用于 64 位。我有 compiled the libraries,在某个阶段,在我现在无法访问的另一台笔记本电脑上,它确实比这更进一步。这是代码的精简版本,可重现当前停止的位置。
import ctypes
import pygame
import os
EGL_DEFAULT_DISPLAY = 0
EGL_NO_DISPLAY = 0
EGL_TRUE = 1
pygame.init()
d = pygame.display.set_mode((0, 0), pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
info = pygame.display.Info()
width, height = info.current_w, info.current_h
#path = "C:/Program Files (x86)/Google/Chrome/Application/42.0.2311.152"
#path = "C:\Program Files (x86)\Google\Chrome\Application\42.0.2311.135"
path = "" # compiled ANGLE dll files in same directory
d3dcompiler = ctypes.WinDLL(os.path.join(path, "d3dcompiler_47.dll"))
opengles = ctypes.WinDLL(os.path.join(path, "libglesv2.dll"))
openegl = ctypes.WinDLL(os.path.join(path, "libegl.dll"))
display = openegl.eglGetDisplay(EGL_DEFAULT_DISPLAY)
assert display != EGL_NO_DISPLAY #<<<<<<<<<<<<<<<<<<<<<<
r = openegl.eglInitialize(display, None, None)
print('eglInitialize() returned {}'.format(r))
assert r == EGL_TRUE #<<<<<<<<<<<<<<<<<<<<<<
可能是 32 位整数作为参数给出或预期作为返回值的类型,而不是 64 位无符号整数。这通常发生在指针值(句柄)上,因为 64 位 windows 有 32 位整数和 64 位指针。定义 argtypes
和 restypes
属性可能会有所帮助,或者至少有助于发现问题。
import ctypes.wintypes as wt
openegl.elgGetDisplay.argtypes = [wt.HDC]
openegl.elgGetDisplay.restype = c_void_p
openegl.eglInitialize.argtypes = [c_void_p, POINTER(c_int32), POINTER(c_int32)]
openegl.eglInitialize.restype = c_uint
然后
display = openegl.eglGetDisplay(None)
assert display.value is not None
r = openegl.eglInitialize(display, None, None)
可能有效(我没有安装那个库所以无法验证)。
我使用 ANGLE dll 有一段时间了 运行 来自 32 位 python(pi3d 模块)的 windows OpenGLES2.0 代码但是我无法得到它适用于 64 位。我有 compiled the libraries,在某个阶段,在我现在无法访问的另一台笔记本电脑上,它确实比这更进一步。这是代码的精简版本,可重现当前停止的位置。
import ctypes
import pygame
import os
EGL_DEFAULT_DISPLAY = 0
EGL_NO_DISPLAY = 0
EGL_TRUE = 1
pygame.init()
d = pygame.display.set_mode((0, 0), pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
info = pygame.display.Info()
width, height = info.current_w, info.current_h
#path = "C:/Program Files (x86)/Google/Chrome/Application/42.0.2311.152"
#path = "C:\Program Files (x86)\Google\Chrome\Application\42.0.2311.135"
path = "" # compiled ANGLE dll files in same directory
d3dcompiler = ctypes.WinDLL(os.path.join(path, "d3dcompiler_47.dll"))
opengles = ctypes.WinDLL(os.path.join(path, "libglesv2.dll"))
openegl = ctypes.WinDLL(os.path.join(path, "libegl.dll"))
display = openegl.eglGetDisplay(EGL_DEFAULT_DISPLAY)
assert display != EGL_NO_DISPLAY #<<<<<<<<<<<<<<<<<<<<<<
r = openegl.eglInitialize(display, None, None)
print('eglInitialize() returned {}'.format(r))
assert r == EGL_TRUE #<<<<<<<<<<<<<<<<<<<<<<
可能是 32 位整数作为参数给出或预期作为返回值的类型,而不是 64 位无符号整数。这通常发生在指针值(句柄)上,因为 64 位 windows 有 32 位整数和 64 位指针。定义 argtypes
和 restypes
属性可能会有所帮助,或者至少有助于发现问题。
import ctypes.wintypes as wt
openegl.elgGetDisplay.argtypes = [wt.HDC]
openegl.elgGetDisplay.restype = c_void_p
openegl.eglInitialize.argtypes = [c_void_p, POINTER(c_int32), POINTER(c_int32)]
openegl.eglInitialize.restype = c_uint
然后
display = openegl.eglGetDisplay(None)
assert display.value is not None
r = openegl.eglInitialize(display, None, None)
可能有效(我没有安装那个库所以无法验证)。