この質問は私の以前のものを繰り返しますが、重要な情報を正しくコピーしなかったために以前のものは失敗だったので、やり直さなければなりません。
OpenGL 関数の呼び出しでエラーが発生します。pyglet が OpenGL を正しく初期化していない可能性がありますか? エラーは、以前は機能していた単純な関数で発生します。
def setup_framebuffer(surface):
#Create texture if not done already
if surface.texture is None:
create_texture(surface)
#Render child to parent
if surface.frame_buffer is None:
surface.frame_buffer = glGenFramebuffersEXT(1)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer)
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, surface.texture, 0)
glPushAttrib(GL_VIEWPORT_BIT)
glViewport(0,0,surface._scale[0],surface._scale[1])
glMatrixMode(GL_PROJECTION)
glLoadIdentity() #Load the projection matrix
gluOrtho2D(0,surface._scale[0],0,surface._scale[1])
エラーは次のとおりです。
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer) ctypes.ArgumentError: 引数 2:: 間違った型
型違い?それでは、 glGenFramebuffersEXT(1) は間違ったタイプを与えていますか? なぜでしょうか?
その関数が呼び出される前に、ゲームを管理するクラス インスタンスを初期化します。初期化方法は次のとおりです。
pyglet.options['audio'] = ('alsa','openal','directsound','silent')
self.keys = [False] * 323
self.events = []
self.title = title
self.game_size = game_size
self.first_screen = (1280,720) #Take 120 pixels from the height because the menu bar, window bar and dock takes space
config = pyglet.gl.Config(alpha_size=8,double_buffer=True,sample_buffers=1,samples=4)
self.window = pyglet.window.Window(game_size[0],game_size[1],title,True,config=config)
self.window.set_handler('on_draw',self.game_loop)
self.window.set_handler('on_resize',self.reshaped)
self.window.set_handler('on_key_press',self.keydown)
self.window.set_handler('on_key_release',self.keyup)
self.window.set_handler('on_mouse_press',self.mouse_func)
glViewport(0,0,self.first_screen[0],self.first_screen[1]) #Creates the viewport which is mapped to the window
glEnable(GL_BLEND) #Enable alpha blending
glEnable(GL_TEXTURE_2D) #Enable 2D Textures
glEnable(GL_MULTISAMPLE) #Enable Multisampling anti-aliasing
glEnable(GL_POLYGON_SMOOTH) #Enable antialiased polygons
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glMatrixMode(GL_PROJECTION)
glLoadIdentity() #Load the projection matrix
gluOrtho2D(0,1280,720,0) #Set an orthorgraphic view
self.game_gap = (0,0)
self.on_exit = on_exit
self.mod_key = 1024 if sys.platform == "darwin" else 64
Surface.__init__(self,game_size)
self.screen_change = True
self.frames = [time.time()]
self.fps = 60
self.last_time = 0
self.fade_surface = Surface([1280,720])
pyglet.font.add_file(os.path.dirname(sys.argv[0]) + "/NEUROPOL.ttf")
pyglet.font.load('NEUROPOL')
Surface は私が作成したクラスで、pygame.Surface クラスと少し似ていますが、OpenGL テクスチャを使用します。
そのメソッドは Window と OpenGL をセットアップし (おそらくどちらが問題なのか?)、それを呼び出した後、テクスチャへのレンダリングに setup_framebuffer 関数を使用するゲーム用にいくつかの設定を行いました。次に、pyglet.app.run() が呼び出され、self.window.set_handler('on_draw,self.game_loop) を実行したため、できれば game_loop メソッドを実行する必要がありますが、そこに到達する前にゲームがクラッシュします。
ピグレットを使うのはこれが初めてです。ドキュメントは、私が間違っていることを説明していません。誰でも助けることができますか?
ありがとうございました。