使用来自python 64位的ANGLE dll初始化失败

时间:2016-07-28 23:04:06

标签: python dll opengl-es ctypes

我已经使用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             #<<<<<<<<<<<<<<<<<<<<<< 

1 个答案:

答案 0 :(得分:1)

可能会将32位整数作为参数给出,或者作为返回值的类型而不是64位无符号整数。这通常发生在指针值(句柄)上,因为64位窗口具有32位整数和64位指针。定义argtypesrestypes属性可能有所帮助,或至少有助于发现问题。

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)

可能有用(我没有安装该库,所以我无法验证)。