我正在使用 PyOpenGL 制作游戏,并希望将一些图像作为一些叠加层(例如,暂停按钮)在屏幕上显示。我怎样才能做到这一点?
我试过使用glBitmap()
,但它不起作用。
这就是我所拥有的:
pauseimg = pygame.image.load(path + "pause.png").convert_alpha()
def blit_image(x,y,w,h,img,r,g,b):
glColor3f(r,g,b)
glWindowPos2f(x,y)
glBitmap(w,h,0,0,0,0,img)
blit_image(300,300,313,115,pauseimg,1,1,1)
我希望它会 blit 图像,但它却抛出了一个异常:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/latebind.py", line 41, in __call__
return self._finalCall( *args, **named )
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".py", line 438, in <module>
blit_image(300,300,313,115,pauseimg,1,1,1)
File ".py", line 135, in blit_image
glBitmap(w,h,0,0,0,0,img)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/latebind.py", line 45, in __call__
return self._finalCall( *args, **named )
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/wrapper.py", line 675, in wrapperCall
pyArgs = tuple( calculate_pyArgs( args ))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/wrapper.py", line 436, in calculate_pyArgs
yield converter(args[index], self, args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/converters.py", line 135, in __call__
return self.function( incoming )
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/arrays/arraydatatype.py", line 149, in asArray
return cls.getHandler(value).asArray( value, typeCode or cls.typeConstant )
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenGL/arrays/arraydatatype.py", line 53, in __call__
typ.__module__, type.__name__, repr(value)[:50]
TypeError: ('No array-type handler for type pygame.type (value: <Surface(313x114x32 SW)>) registered', <OpenGL.converters.CallFuncPyConverter object at 0x111a720b8>)```