Mitchell Barton | 25 Jun 17:59 2016
Picon

Re: on_player_eos event not working when trying to play through a list of mp3 files with Pyglet

Yeah, I kept on getting the same error you mentioned of the source being queued already if they weren't static. So setting them as static resources was vital. I did have some problems with certain sounds, for some reason one mp3 files on_player_eos event wasnt firing, but all the other sources I had worked fine. 

I'm now trying to add a few other things to my code, running Terminal's 'say' command on top of the music being played with pyglet. I play the songs I have, and then have terminal pick random words out of a list that then 'says' them repeatedly. It seems to work at first, but then freezes, running the code forever and not responding to any window events until I force quit the Python interpreter. 

So my question is, is it possible to run commands in the command line while a pyglet application is running without the application freezing?

Here is my code


On Sat, Jun 25, 2016 at 9:57 AM Mitchell Barton <mitchellcliftonbarton <at> gmail.com> wrote:
Yeah, I kept on getting the same error you mentioned of the source being queued already if they weren't static. So setting them as static resources was vital. I did have some problems with certain sounds, for some reason one mp3 files on_player_eos event wasnt firing, but all the other sources I had worked fine. 

I'm now trying to add a few other things to my code, running Terminal's 'say' command on top of the music being played with pyglet. I play the songs I have, and then have terminal pick random words out of a list that then 'says' them repeatedly. It seems to work at first, but then freezes, running the code forever and not responding to any window events until I force quit the Python interpreter. 

So my question is, is it possible to run commands in the command line while a pyglet application is running without the application freezing?

Here is my code

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Serdar Yegulalp | 25 Jun 16:03 2016

Setting processor affinity to aid performance

One of the little performance tweaks I've come across for Pyglet involves setting the processor affinity for the running app. The Python interpreter is effectively single-threaded, and so allowing it to run with the default affinity (all cores) can actually harm performance in some cases.

Consequently, setting the affinity of the running process to a single core can sometimes speed it up, because there's less context switching and less cache eviction..

I'm not sure how to accomplish this in Linux or on MacOS, but in Windows, it's easy enough:

import ctypes
k32 = ctypes.windll.kernel32
k32.SetProcessAffinityMask(k32.GetCurrentProcess(), 1)

I'm doing this with a game I'm working on now and it provides a noticeable, if not terribly dramatic, speedup.

I also use this in conjunction with bumping the process priority slightly, something I've discussed before:

ctypes.windll.kernel32.SetPriorityClass(-1, 0x8000))

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Sean Miller | 24 Jun 03:54 2016
Picon

'pyglet.gl.lib.GLException: invalid operation' error


--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Paulo Martins | 21 Jun 00:06 2016
Picon
Gravatar

Get current mouse/cursor position (x and y)

Hi,

Imagine that I am in a "update(dt)" function doing animation stuff, and need to position some sprite according to the mouse position: is there an easy way, like a function, to get the current mouse position (x, y coordinates)?
Or the only way is to creat something like a global variable x and y and keep track/registe the mouse x, y inside the on_mouse_motion event each time it moves, since the start of the app?

I am tired and sleepy, working in a hurry because of deadlines, searched but can't find an easy way - sorry if this question is stupid and has an obvious answer I am not seeing in this moment.

Thanks, all the best 

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Paulo Martins | 20 Jun 23:54 2016
Picon
Gravatar

Get current mouse/cursor position (x and y)


Hi,

Imagine that I am in a "update(dt)" function doing animation stuff, and need to position some sprite according to the mouse position: is there an easy way to get the current mouse position (x, y coordinates)?
Or the only way is to creat something like a global variable x and y and keep track/registe the mouse x, y inside the on_mouse_motion event each time it moves?

I am tired and sleepy, working in a hurry because of deadlines, searched but can't find an easy way - sorry if this question is stupid and has an obvious answer I am not seeing in this moment.

All the best 

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Jesse Cox | 20 Jun 19:05 2016
Picon

This is the best software ever! :)

Here is my new screensaver/lock for Ubuntu. Have any suggestions?

https://youtu.be/i5xjszpul-Q

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Mitchell Barton | 16 Jun 23:45 2016
Picon

on_player_eos event not working when trying to play through a list of mp3 files with Pyglet

I'm trying to shuffle a list of mp3 files and then play through them with pyglet. Once the player runs out of sources I want to re-shuffle the list, and then play through them again. This process would happen infinitely. I have been able to get pyglet to play through the sources once, but the on_player_eos event is never fired when I run out of sources. I'm not sure exactly what I am doing wrong, or if I am approaching it in the wrong way. I've tried a couple ways of doing it, but have had no luck getting it to work. Here is the code

import os, sys, random, pyglet from random import shuffle song1 = pyglet.media.load('beats/breathe.mp3') song2 = pyglet.media.load('beats/everything.mp3') song3 = pyglet.media.load('beats/jazz.mp3') player = pyglet.media.Player() # Play beatz def beatz(): playlist = [song1, song2, song3] shuffle(playlist) player.queue(playlist[0]) player.queue(playlist[1]) player.queue(playlist[2]) player.play() def on_player_eos(): print('repeating') beatz() player.on_player_eos = on_player_eos

I have also tried replacing the 'player.on_player_eos = on_player_eos' with

player.push_handlers(on_player_eos)

But it doesnt seem to do anything either. Any help appreciated.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Paul Craven | 2 Jun 19:20 2016

avbin and sound support

I'm working with some people trying to get Pyglet working on Macs and Linux machines.

Ubuntu 16 seems to have moved avbin to 'unstable.' This makes it difficult to find and install. It also doesn't bode well for the future of using avbin for sound support.

On the Mac, installing avbin 11 via the installer, and we are having problems getting Python to find avbin.

Pyglet does NOT fall back nicely if it can't find avbin and seems to crash even if a program doesn't use sound.

What are other people's experiences with avbin? Any hope for some fixes?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Benjamin Moran | 1 Jun 09:55 2016
Picon

Pull request opened for shader class

I opened up a pull request for my simple ShaderProgram class I worked on a few months ago. This is likely not suitable for merging in it's current state, but I wanted to potentially spark up a bit of conversation on what should be added/changed/modified/removed. The pull request is here:
https://bitbucket.org/pyglet/pyglet/pull-requests/24/shader_class/diff
The changes consist of two new files, so you could just copy/paste those into a local directory for playing around with.
Feel free to express your horror at what you see. It's obviously not finished :)

-------------------------------------------------
The rest of this post are just some thoughts I've been having with regards to modern OpenGL and pyglet:

When playing around with shaders and pyglet, some things come up: If you use a newer OpenGL context, you have to give up all the nice pyglet graphics classes and roll everything yourself. This is fine for advanced use cases, but it's a huge drawback not being able to take advantage of the awesome pyglet batches and other niceties. Using an OpenGL 3.0 context bridges the gap, but of course this doesn't work on OSX (and old functions are not even guaranteed to be available anyway by the spec). Looking towards to a possible future where it might become necessary to support OpenGL Core profiles, some thoughts are:

1. Fill the code base with a bunch of "if context > 3.0" statements and a ton of duplicated methods for legacy and core OpenGL.
2. Re-write the necessary pyglet classes to use the OpenGL Core profile, including a default set of basic shaders that mimic the current functionality.

Option 1 seems foolhardy. Option 2 might be the best way to go. Perhaps this timeframe would tie in with the eventual end of life for Python 2.x in 2020. Dropping both Python 2 and legacy OpenGL at the same time would allow a nice refresh.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Benjamin Moran | 30 May 05:18 2016
Picon

A simple fixed resolution viewport with camera for 2D games

Hey guys,

I thought I'd share this snippet here: https://bitbucket.org/snippets/treehousegames/g6Xdg
Most of the code is from the fixed resolution viewport that is in the pyglet example code, but I've tweaked it a bit such as turning it into a context manager, and implementing a simple 2D camera. The camera in particular seems to be a challenge for beginners, so maybe this could help someone.
It's used like this:

# make an instance of the viewport:
viewport = FixedResolutionViewport(target_window, resolution)

# to use it without involving a camera, simply do:
with viewport:
    window.clear()
    batch.draw()

# If you want to use the camera, it must be specifically set before drawing:
with viewport:
    window.clear()
    viewport.set_camera(300, 0)
    batch.draw()

# If you want to display a static HUD on top of your scrolling scene, you can reset the view and draw a second batch:
with viewport:
    window.clear()
    viewport.set_camera(300, 0)
    main_batch.draw()
    viewport.reset_camera()
    hud_batch.draw()




   

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
'Charles' via pyglet-users | 28 May 08:16 2016

Setting RGBA for sprite regions

I am trying to create a way I can change specific colors on regions on a sprite.

Right now, my method is to take the original texture, slice it into two regions, top and bottom. Create two sprites for each, make sure they offset each other properly, then simply set the RGBA values on the sprite I want. However, this seems inefficient as now I have two sprites that must be updated constantly and makes it awkward when I want to adjust the color height. For example, if the player steps into water, the water may have varying depth. Constantly creating sprites as the level rises or lowers, pixel by pixel, would be a big performance hit I would imagine.

I've thought about the image data access and setting pixels, but this would affect all of the sprites that use that image, or am I wrong? Also, my method falls short when I want to just take a section of the sprite (say like an 8x8 square in the center) and color it. Since it can't be resolved through square regions.

Maybe I am complicating it too much or is there is an alternate method?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Gmane