pyglet

AttributeError with Pyglet

匆匆过客 提交于 2019-12-08 12:41:53
问题 I'm literally starting in Pyglet, and I tried the simplest program with it (A hello world window). import pyglet window = pyglet.window.Window(width=640, height=480, caption="Hola Mundo!") pyglet.app.run() But when I run it, I get an AttributeError: AttributeError: 'module' has no attribute 'window' 回答1: It is likely that you have a file in the cwd called pyglet . When importing modules, python first looks at the cwd before looking in the global list of installed packages. Rename that file

pyglet/avbin misses beginning and end of video

。_饼干妹妹 提交于 2019-12-07 20:28:36
问题 I have a problem that when playing a video with pyglet apparently the beginning and the end of the stream is not handled correctly. The player ignores the first keyframe and thus shows glitches images until the it finds the second keyframe. Likewise the on_eos-event is not fire but python chrashes because it apparently tries to load more frames. import pyglet vidPath = "test.mp4" window = pyglet.window.Window() player = pyglet.media.Player() source = pyglet.media.load(vidPath) player.queue

OpenGL basics: calling glDrawElements once per object

五迷三道 提交于 2019-12-07 17:57:05
问题 continuing on from my explorations of the basics of OpenGL (see this question), I'm trying to figure out the basic principles of drawing a scene with OpenGL. I am trying to render a simple cube repeated n times in every direction. My method appears to yield terrible performance : 1000 cubes brings performance below 50fps (on a QuadroFX 1800, roughly a GeForce 9600GT). My method for drawing these cubes is as follows: done once: set up a vertex buffer and array buffer containing my cube

ray intersection misses the target

丶灬走出姿态 提交于 2019-12-07 17:45:49
问题 I'm trying to pick a 3d point. I read various sites but my code doesn't work. on right mouse click: glGetFloatv(GL_MODELVIEW_MATRIX,mv_mat) glGetFloatv(GL_PROJECTION_MATRIX,p_mat) ip_mat = np.linalg.inv(mat4(p_mat)) # clip = array[ # (2*x)/window_width-1 # 1-(y*2)/window.height # -1 # 1 camera_coord = np.dot(ip_mat,clip) camera_coord = np.array([camera_coord[0,0],camera_coord[0,1],-1,0]) imv_mat = np.linalg.inv(mat4(mv_mat)) ray_world = np.dot(imv_mat,camera_coord) ray_world = np.array([ray

how to display a numpy array with pyglet?

荒凉一梦 提交于 2019-12-07 07:23:34
问题 I have a label matrix with dimension (100*100), stored as a numpy array, and I would like to display the matrix with pyglet. My original idea is to use this matrix to form a new pyglet image using function pyglet.image.ImageData(). It requres a buffer of the imagedata as an input, however I have no idea how to get a right formated buffer from the numpy array. Any one have any idea? ps. my current solution: 3d_label = numpy.empty([100,100,3]) 3d_label[:,:,0] = label * 255 # value range of

Can't draw() sprites in pyglet

喜你入骨 提交于 2019-12-07 07:13:33
问题 For some reason, I can't get pyglet to draw sprites. Here's my code: import pyglet game = pyglet.window.Window(640, 480, "I'm a window") batch = pyglet.graphics.Batch() pyglet.resource.path = ["."] pyglet.resource.reindex() image = pyglet.resource.image("hextile.png") pyglet.sprite.Sprite(image, x=200, y=300, batch=batch) pyglet.text.Label('DING', font_name='Arial', font_size=24, x=100, y=100, batch=batch) @game.event def on_draw(): game.clear() batch.draw() #image.blit(0, 0) pyglet.app.run()

pyglet/avbin misses beginning and end of video

久未见 提交于 2019-12-06 16:01:13
I have a problem that when playing a video with pyglet apparently the beginning and the end of the stream is not handled correctly. The player ignores the first keyframe and thus shows glitches images until the it finds the second keyframe. Likewise the on_eos-event is not fire but python chrashes because it apparently tries to load more frames. import pyglet vidPath = "test.mp4" window = pyglet.window.Window() player = pyglet.media.Player() source = pyglet.media.load(vidPath) player.queue(source) player.play() @player.event def on_eos(): print('video end') @window.event def on_draw(): window

OpenGL basics: calling glDrawElements once per object

a 夏天 提交于 2019-12-06 01:35:24
continuing on from my explorations of the basics of OpenGL (see this question ), I'm trying to figure out the basic principles of drawing a scene with OpenGL. I am trying to render a simple cube repeated n times in every direction. My method appears to yield terrible performance : 1000 cubes brings performance below 50fps (on a QuadroFX 1800, roughly a GeForce 9600GT). My method for drawing these cubes is as follows: done once: set up a vertex buffer and array buffer containing my cube vertices in model space set up an array buffer indexing the cube for drawing as 12 triangles done for each

ray intersection misses the target

China☆狼群 提交于 2019-12-06 00:24:46
I'm trying to pick a 3d point. I read various sites but my code doesn't work. on right mouse click: glGetFloatv(GL_MODELVIEW_MATRIX,mv_mat) glGetFloatv(GL_PROJECTION_MATRIX,p_mat) ip_mat = np.linalg.inv(mat4(p_mat)) # clip = array[ # (2*x)/window_width-1 # 1-(y*2)/window.height # -1 # 1 camera_coord = np.dot(ip_mat,clip) camera_coord = np.array([camera_coord[0,0],camera_coord[0,1],-1,0]) imv_mat = np.linalg.inv(mat4(mv_mat)) ray_world = np.dot(imv_mat,camera_coord) ray_world = np.array([ray_world[0],ray_world[1],ray_world[2]]) ray_world = ray_world/np.linalg.norm(ray_world) Intersect_sphere

how to display a numpy array with pyglet?

时光毁灭记忆、已成空白 提交于 2019-12-05 13:09:52
I have a label matrix with dimension (100*100), stored as a numpy array, and I would like to display the matrix with pyglet. My original idea is to use this matrix to form a new pyglet image using function pyglet.image.ImageData(). It requres a buffer of the imagedata as an input, however I have no idea how to get a right formated buffer from the numpy array. Any one have any idea? ps. my current solution: 3d_label = numpy.empty([100,100,3]) 3d_label[:,:,0] = label * 255 # value range of label is [0,1] 3d_label[:,:,1] = label * 255 3d_label[:,:,2] = label * 255 image_data = ctypes.string_at(id