简体   繁体   English

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

[英]eglInitialize failure using ANGLE dll from python 64 bits

I've been using the ANGLE dlls for a while to run OpenGLES2.0 code on windows from 32 bit python (pi3d module) However I can't get it to work with 64 bits. 我一直在使用角度dll来在32位python(pi3d模块)的Windows上运行OpenGLES2.0代码,但是我无法使其在64位上工作。 I have compiled the libraries and at one stage, on a different laptop to which I don't have access now, it did get further than this. 我已经编译了这些库,并且在一个阶段,使用了我现在无法访问的另一台笔记本电脑,它的功能远不止于此。 This is a stripped down version of the code that reproduces the point where it currently stops. 这是简化的代码版本,可重现当前停止的位置。

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             #<<<<<<<<<<<<<<<<<<<<<< 

Probably a 32-bit integer is given as an argument or expected as the type for the returned value instead of a 64-bit unsigned integer. 可能将32位整数作为参数或作为返回值的类型,而不是64位无符号整数。 This happens commonly for pointer values (handles) since 64-bit windows has 32-bit integers and 64-bit pointers. 因为64位窗口具有32位整数和64位指针,所以这种情况通常发生在指针值(句柄)上。 Defining argtypes and restypes attributes may help, or at least help to spot the problems. 定义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

then 然后

display = openegl.eglGetDisplay(None)
assert display.value is not None
r = openegl.eglInitialize(display, None, None)

might work (I don't have that library installed so I can't verify). 可能有效(我没有安装该库,因此无法验证)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM