小编use*_*966的帖子

PySDL2问题与SDL_Surface / LP_SDL_Surface

我用python 3.3和PySDL2 0.5运行win7。创建曲面时(无论使用哪种方法),我都会得到LP_SDL_Surface而不是SDL_Surface。LP_SDL_Surface缺少您期望的任何方法和属性。这是使用文档中示例代码的问题:

import os
os.environ["PYSDL2_DLL_PATH"] = os.path.dirname(os.path.abspath(__file__))

import sys
import ctypes
from sdl2 import *

def main():
    SDL_Init(SDL_INIT_VIDEO)
    window = SDL_CreateWindow(b"Hello World",
                              SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                              592, 460, SDL_WINDOW_SHOWN)
    windowsurface = SDL_GetWindowSurface(window)

    image = SDL_LoadBMP(b"exampleimage.bmp")
    SDL_BlitSurface(image, None, windowsurface, None)
    print(image.h)

    SDL_UpdateWindowSurface(window)
    SDL_FreeSurface(image)

    running = True
    event = SDL_Event()
    while running:
        while SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == SDL_QUIT:
                running = False
                break

    SDL_DestroyWindow(window)
    SDL_Quit()
    return 0

if __name__ == "__main__":
    sys.exit(main())
Run Code Online (Sandbox Code Playgroud)

追溯为:

Traceback (most recent call last):
File "C:/.../test.py", …
Run Code Online (Sandbox Code Playgroud)

python sdl pysdl2 geometry-surface

5
推荐指数
1
解决办法
1181
查看次数

标签 统计

geometry-surface ×1

pysdl2 ×1

python ×1

sdl ×1