Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用PySDL2将SDL_曲面传递给SDL_LockTexture?_Python_Sdl 2_Pysdl2 - Fatal编程技术网

Python 如何使用PySDL2将SDL_曲面传递给SDL_LockTexture?

Python 如何使用PySDL2将SDL_曲面传递给SDL_LockTexture?,python,sdl-2,pysdl2,Python,Sdl 2,Pysdl2,我正在尝试将SDL_曲面成员传递给SDL_LockTexture: texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height) surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000) SDL_Loc

我正在尝试将SDL_曲面成员传递给SDL_LockTexture:

texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height)
surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)
SDL_LockTexture(texture, 0, ctypes.byref(surface.contents.pixels), ctypes.byref(surface.contents.pitch))

TypeError: byref() argument must be a ctypes instance, not 'int'
SDL_曲面定义如下:

SDL_LockTexture定义如下:


调用SDL_CreateRGBSurface后,调试器会说曲面的像素和基音成员都是int类型。我做错了什么?

我也遇到了同样的问题,试图将像素传递到
PyOpenGL
函数中。由于某些原因,该字段存储为
int
。您需要将其强制转换为
无效指针
。尝试:

SDL_LockTexture(texture, 0, ctypes.byref(ctypes.c_void_p(surface.contents.pixels)), ctypes.byref(ctypes.c_int(surface.contents.pitch))
SDL_LockTexture = _bind("SDL_LockTexture", [POINTER(SDL_Texture), POINTER(SDL_Rect), POINTER(c_void_p), POINTER(c_int)], c_int)
SDL_LockTexture(texture, 0, ctypes.byref(ctypes.c_void_p(surface.contents.pixels)), ctypes.byref(ctypes.c_int(surface.contents.pitch))