pyglet

Pyglet OpenGL drawing anti-aliasing

流过昼夜 提交于 2019-12-23 07:08:43
问题 I've been looking around for a way to anti-alias lines in OpenGL, but none of them seem to work... here's some example code: import pyglet from pyglet.gl import * window = pyglet.window.Window(resizable=True) @window.event def on_draw(): window.clear() pyglet.gl.glColor4f(1.0,0,0,1.0) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable (GL_BLEND) glEnable (GL_LINE_SMOOTH); glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE) glLineWidth (3) pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i',

Python Video Framework

随声附和 提交于 2019-12-22 08:06:46
问题 I'm looking for a Python framework that will enable me to play video as well as draw on that video (for labeling purposes). I've tried Pyglet, but this doesn't seem to work particularly well - when drawing on an existing video, there is flicker (even with double buffering and all of that good stuff), and there doesn't seem to be a way to get the frame index in the video during the per-frame callback (only elapsed time since the last frame). 回答1: Try a Python wrapper for OpenCV such as ctypes

Resource Not Found Exception in pyglet

 ̄綄美尐妖づ 提交于 2019-12-21 09:22:06
问题 I'm using Python 2.6.6 and pyglet 1.1.4. In my "Erosion" folder, I have "Erosion.py" and a folder named "Images." Inside images, there are .png images. One image is named "Guard.png." In "Erosion.py" there is a segment that goes like so: pyglet.resource.path = ['Images'] pyglet.resource.reindex() self.image = pyglet.resource.image('%s%s' % (character, '.png')) When I run this, I am given File "C:\Python26\lib\site-packages\pyglet\resource.py", line 394, in file raise ResourceNotFoundException

how to play mp3

眉间皱痕 提交于 2019-12-21 04:31:24
问题 my problem starts here: pyttsx and gTTS module errors gTTS works well, takes text from text file, but first creates mp3 file, then if I want listen, I must call this mp3, so it is good but it would be better if I can avoid any audio files, and get just read from text file. maybe somehow I can use google voice to read from text file..? anyway main question now is other if I can use only gTTS what is the best way to play mp3 on Windows 10-64 bit, Python 3.5 ok with os: import os os.startfile("D

Why is pyglet so slow compared to pygame?

萝らか妹 提交于 2019-12-21 02:21:14
问题 Here is the code. 5000 bouncing spinning red squares. (16x16 png) On the pygame version I get 30 fps but 10 fps with pyglet. Isnt OpenGl supposed to be faster for this kind of thing? pygame version: import pygame, sys, random from pygame.locals import * import cProfile # Set FPS FPS = 60.0 clock = pygame.time.Clock() # Set window WINDOWWIDTH= 800 WINDOWHEIGHT = 600 pygame.init() screen = pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT)) screen.fill((0,0,0)) background = screen.copy()

Why is pyglet so slow compared to pygame?

百般思念 提交于 2019-12-21 02:21:07
问题 Here is the code. 5000 bouncing spinning red squares. (16x16 png) On the pygame version I get 30 fps but 10 fps with pyglet. Isnt OpenGl supposed to be faster for this kind of thing? pygame version: import pygame, sys, random from pygame.locals import * import cProfile # Set FPS FPS = 60.0 clock = pygame.time.Clock() # Set window WINDOWWIDTH= 800 WINDOWHEIGHT = 600 pygame.init() screen = pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT)) screen.fill((0,0,0)) background = screen.copy()

How to do a non-blocking URL fetch in Python

六眼飞鱼酱① 提交于 2019-12-20 11:36:11
问题 I am writing a GUI app in Pyglet that has to display tens to hundreds of thumbnails from the Internet. Right now, I am using urllib.urlretrieve to grab them, but this blocks each time until they are finished, and only grabs one at a time. I would prefer to download them in parallel and have each one display as soon as it's finished, without blocking the GUI at any point. What is the best way to do this? I don't know much about threads, but it looks like the threading module might help? Or

How to do a non-blocking URL fetch in Python

跟風遠走 提交于 2019-12-20 11:36:05
问题 I am writing a GUI app in Pyglet that has to display tens to hundreds of thumbnails from the Internet. Right now, I am using urllib.urlretrieve to grab them, but this blocks each time until they are finished, and only grabs one at a time. I would prefer to download them in parallel and have each one display as soon as it's finished, without blocking the GUI at any point. What is the best way to do this? I don't know much about threads, but it looks like the threading module might help? Or

How to play streaming audio using pyglet?

纵然是瞬间 提交于 2019-12-18 14:35:00
问题 The goal of this question is trying to figure out how to play streaming audio using pyglet. The first is just making sure you're able to play mp3 files using pyglet, that's the purpose of this first snippet: import sys import inspect import requests import pyglet from pyglet.media import * pyglet.lib.load_library('avbin') pyglet.have_avbin = True def url_to_filename(url): return url.split('/')[-1] def download_file(url, filename=None): filename = filename or url_to_filename(url) with open

How to play streaming audio using pyglet?

风格不统一 提交于 2019-12-18 14:33:34
问题 The goal of this question is trying to figure out how to play streaming audio using pyglet. The first is just making sure you're able to play mp3 files using pyglet, that's the purpose of this first snippet: import sys import inspect import requests import pyglet from pyglet.media import * pyglet.lib.load_library('avbin') pyglet.have_avbin = True def url_to_filename(url): return url.split('/')[-1] def download_file(url, filename=None): filename = filename or url_to_filename(url) with open