You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is pyglet bug if we import cocos outside "real" process:
This is not working:
from multiprocessing import Process
import cocos
class HelloWorld(cocos.layer.Layer):
def __init__(self):
super().__init__()
label = cocos.text.Label(
'Hello, world',
font_name='Times New Roman',
font_size=32,
anchor_x='center', anchor_y='center'
)
label.position = 320, 240
self.add(label)
def test_cocos():
cocos.director.director.init()
hello_layer = HelloWorld()
main_scene = cocos.scene.Scene(hello_layer)
cocos.director.director.run(main_scene)
p = Process(
target=test_cocos
)
p.start()
p.join()
And produce
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
self.run()
File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "c.py", line 21, in test_cocos
cocos.director.director.init()
File "/home/bux/Projets/synergine2/venv3.5/lib/python3.5/site-packages/cocos/director.py", line 327, in init
self.window = window.Window(*args, **kwargs)
File "/home/bux/Projets/synergine2/venv3.5/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 163, in init
super(XlibWindow, self).init(*args, **kwargs)
File "/home/bux/Projets/synergine2/venv3.5/lib/python3.5/site-packages/pyglet/window/init.py", line 515, in init
context = config.create_context(gl.current_context)
File "/home/bux/Projets/synergine2/venv3.5/lib/python3.5/site-packages/pyglet/gl/xlib.py", line 186, in create_context
return XlibContextARB(self, share)
File "/home/bux/Projets/synergine2/venv3.5/lib/python3.5/site-packages/pyglet/gl/xlib.py", line 296, in init
super(XlibContext13, self).init(config, share)
File "/home/bux/Projets/synergine2/venv3.5/lib/python3.5/site-packages/pyglet/gl/xlib.py", line 199, in init
raise gl.ContextException('Could not create GL context')
pyglet.gl.ContextException: Could not create GL context
But this don't procduce errors:
from multiprocessing import Process
def test_cocos():
import cocos
class HelloWorld(cocos.layer.Layer):
def __init__(self):
super().__init__()
label = cocos.text.Label(
'Hello, world',
font_name='Times New Roman',
font_size=32,
anchor_x='center', anchor_y='center'
)
label.position = 320, 240
self.add(label)
cocos.director.director.init()
hello_layer = HelloWorld()
main_scene = cocos.scene.Scene(hello_layer)
cocos.director.director.run(main_scene)
p = Process(
target=test_cocos
)
p.start()
p.join()
Maybe it can be fixed (really initialize pyglet when used) ? Or speak about in doc (if it's not already done ... :s)
The text was updated successfully, but these errors were encountered:
from multiprocessing import Process
import time
def test_window():
import pyglet # Must import pyglet here in the process with your window initialization!
window = pyglet.window.Window()
time.sleep(5)
if __name__ == '__main__':
p = Process(target=test_window)
p.start()
There is pyglet bug if we import cocos outside "real" process:
This is not working:
And produce
But this don't procduce errors:
Maybe it can be fixed (really initialize pyglet when used) ? Or speak about in doc (if it's not already done ... :s)
The text was updated successfully, but these errors were encountered: