pyglet

why might my pyglet vertex lists and batches be very slow on Windows?

I'm writing opengl code in python using the library pyglet. When I draw to the screen using pyglet.graphics.vertex_list or pyglet.graphics.batch objects, they are very slow (~0.1 fps) compared to plain old pyglet.graphics.draw() or just glVertex() calls, which are about 40fps for the same geometry. In Linux the vertex_list is about the s...

opengl set texture color with vertex color

Because I need to display a huge number of labels that move independently, I need to render a label in pyglet to a texture (otherwise updating the vertex list for each glyph is too slow). I have a solution to do this, but my problem is that the texture that contains the glyphs is black, but I'd like it to be red. See the example below: ...

PyOpenGl or pyglet?

I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet Which would you recommend and why? ...

Get Data from OpenGL glReadPixels(using Pyglet)

I'm using Pyglet(and OpenGL) in Python on an application, I'm trying to use glReadPixels to get the RGBA values for a set of pixels. It's my understanding that OpenGL returns the data as packed integers, since that's how they are stored on the hardware. However for obvious reasons I'd like to get it into a normal format for working wit...

Differences between Python game libraries Pygame and Pyglet?

I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days. How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use? Finally, would you say that one is more Pythonic than the other? ...

HowTo put region of Pyglet image into PIL Image?

My app reads frames from video (using pyglet), extracts a 'strip' (i.e. region - full width by 1 to 6 video lines), then pastes each strip (appends it) into an image that can later be written out an *.png file. Problem is Pyglet GL images are stored in graphics memory, so are very limited re size. My current klunky workaround is build u...

How to convert a Pyglet image to a PIL image?

i want to convert a Pyglet.AbstractImage object to an PIL image for further manipulation here are my codes from pyglet import image from PIL import Image pic = image.load('pic.jpg') data = pic.get_data('RGB', pic.pitch) im = Image.fromstring('RGB', (pic.width, pic.height), data) im.show() but the image shown went wrong. so how to conv...

How to do a non-blocking URL fetch in Python

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, wit...

Python Video Framework

Hi, 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 ...

Programmatic control of python optimization ?

I've been playing with pyglet. It's very nice. However, if I run my code, which is in an executable file (call it game.py) prefixed with the usual #!/usr/bin/env python by doing ./game.py then it's a bit clunky. But if I run it with python -O ./game.py or PYTHONOPTIMIZE=1 ./game.py then its super-smooth. I'm don't care m...

Creating a new input event dispatcher in Pyglet (infra red input)

I recently asked this question in the pyglet-users group, but got response, so I'm trying here instead. I would like to extend Pyglet to be able to use an infra red input device supported by lirc. I've used pyLirc before ( http://pylirc.mccabe.nu/ ) with PyGame and I want to rewrite my application to use Pyglet instead. To see if a but...

Start with pyglet or pygame?

Hey, I would like to know what is the best to start with, pyglet or pygame? Which one is faster and which one is more active? I would also like to know if pyglet will get python 3 support, because I have read here that it might not be possible or it would take a long time. Would it be better to choose pygame, because of the python 3 ...

detecting two simultaneous keys in pyglet (python)

Hi there... I wanted to know how to detect when two keys are simultaneously pressed using pyglet. I currently have def on_text_motion(self, motion): (dx,dy) = ARROW_KEY_TO_VERSOR[motion] self.window.move_dx_dy((dx,dy)) But this only gets arrow keys one at a time... I'd like to distinguish between the combination UP+LEFT an...

OpenGL Picking with Pyglet

I'm trying to implement picking using Pyglet's OpenGL wrapper, but I'm having trouble converting a C tutorial to Python. Specifically the part below. #define BUFSIZE 512 GLuint selectBuf[BUFSIZE] void startPicking(int cursorX, int cursorY) { GLint viewport[4]; glSelectBuffer(BUFSIZE,selectBuf); glRenderMode(GL_SELECT); ...

How to keep pyglet from clearing the screen ?

I want to draw a scene and sequentially add lines to it. But pyglet keeps updating without control :( , so all I get is blinks from pyglet.gl import * window=pyglet.window.Window() def drawline(): ... @window.event def on_draw(): drawline() pyglet.app.run() should I change the decorator(if there exist options) or what? Tha...

problem with pyglet playing video

hello . I'm new to pyglet and i have a problem with video.. I'm trying to play a video using pyglet .. but instead of playing the video in the window it just exits immediately and terminates .. do you guys have any solution for this problem how can i hold the window to play vedio?? i use windows vista 64x with python 2.5 please help ...

How to use on_mouse_motion to move around a lable via pyglet?

How can one move a label around in the hello world example using the on_mouse_motion function? The docs aren't clicking for me. on_mouse-motion hello_world_example.py ...

Render and scroll through multiline paragraphs using pyglet and ScrollableTextLayout

How can one display and scroll through a multi-line strings (contain "\n") via pyglet using the features of ScrollableTextLayout? STL crops what is display, and seems to be the most efficient way to implement scrolling. However I have no idea as to how to use it. The docs do not elucidate much to me. SomeText: string = "Some multilin...

Play Subset of audio file using Pyglet

How can I use the pyglet API for sound to play subsets of a sound file e.g. from 1 second in to 3.5seconds of a 6 second sound clip? I can load a sound file and play it, and can seek to the start of the interval desired, but am wondering how to stop playback at the point indicated? ...

Pythonic and efficient way of finding adjacent cells in grid

I am building a tile based app in Python using pyglet/openGL wherein I'll need to find the all of the adjacent cells for a given cell. I am working in one quadrant of a Cartesian grid. Each cell has an x and y value indicating it's position in the grid( x_coord and y_coord ). These are not pixel values, rather grid positions. I am lookin...