python cocos2d pygame_留一个神python代码——混合使用wxpython和pyglet(cocos2d编辑器)...

该博客介绍了一种在wxPython中混合使用pyglet的技术,以创建一个cocos2d编辑器。通过实现AbstractCanvas类,实现了在不同平台上切换和翻转OpenGL上下文的功能。示例代码展示了如何在wxPython窗口中嵌入pyglet,用于在Python环境中搭建游戏开发环境。
摘要由CSDN通过智能技术生成

import wx

import pyglet

from pyglet.gl import *

import sys

if sys.platform == 'win32':

from pyglet.window.win32 import _user32

from pyglet.gl import wgl

elif sys.platform.startswith('linux'):

from pyglet.image.codecs.gdkpixbuf2 import gdk

from pyglet.gl import glx

class AbstractCanvas(pyglet.event.EventDispatcher):

def __init__(self, context, config):

# Create context (same as pyglet.window.Window.__init__)

if not config:

platform = pyglet.window.get_platform()

display = platform.get_default_display()

screen = display.get_screens()[0]

for template_config in [

pyglet.gl.Config(double_buffer=True, depth_size=24),

pyglet.gl.Config(double_buffer=True, depth_size=16)]:

try:

config = screen.get_best_config(template_config)

break

except pyglet.window.NoSuchConfigException:

pass

if not config:

raise pyglet.window.NoSuchConfigException(

'No standard config is available.')

if not config.is_complete():

config = screen.get_best_config(config)

if not context:

context = config.create_context(pyglet.gl.current_context)

self._display = display

self._screen = screen

self._config 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值