March 18, 2009
Climb California
On Saturday the 28th of March I will be competing in the San Francisco part of the climb california compeition. I will climb 1,197 steps to the 52nd floor of San Francisco’s 555 California in the “Bank of America Climb California” event to help raise money for lung disease research and education. If you feel like sponsoring me, please visit the compeition web page and input my name. Donations are tax deductible.
PyGameSF meetup Tuesday March 24th 10th 6pm @ Main San Francisco Public Library
This months PyGameSF meet up is at the STONG conference room on the first floor of the main San Francisco public library beside civic center BART. The library closes at 8pm so we will be reconviening to frjtz on hayes street for dinner/drinks afterwords. This month’s presentations are:
- Casey Duncan: Going Low-level, A peek under the hood at the C implementation of the Lepton particle engine as an example of how to develop for Python in C for ultimate performance. We’ll take a peek at Lepton itself and take a crack at extending it with C.
- Harry Tormey: Fast prototyping Word games with python and pyglet. An introduction to working with pyglet, the cross-platform windowing and multimedia library. This talk will cover how to structure a game with pyglet, how it differs from working with pygame, best practices for using the pyglet event loop, working with OpenGL vertex arrays to manipulate text and general tips on how not to go insane if you are an OpenGL newbie.
March 6, 2009
An Interview with Alex Holkner
Last month I interviewed both Alex Holkner the main author of Pyglet and Rene Dudfield a contributor to Pygame, you can listen to a recording of the interview with Alex here. The interviews deal with their respective work on Pygame and Pyglet, some of the challenges they faced developing these libraries, what they are currently working on, plans for the future and their experiences competing in competitions like pyweek. This article concerns the first interview with Alex Holkner. Alex has contributed to numerous open source projects apart from Pyglet and is currently doing a PHD at RMIT Univeristy.
If you have ever considered making a game with python chances are while researching the options available you came across both the Pygame and Pyglet libraries. The two libraries have taken very different approaches to the challenge of making games with an interpreted language. With Pygame the focus is on abstracting away low level details like how graphics are rendered. Its main assumption is that such things can be completely detached from the game logic. Most of the functionality in Pygame is built on top of its bindings to the c library Simple Direct Media Layer (SDL). In contrast Pyglet is written almost entirely in python and is mainly an OpenGL based software library, which inherently means its focus is on how graphics get drawn to the screen.
The origins of Pyglet can be traced back to 2006 when Alex participated in a google summer of code project the goal of which was to produce a pure python port of pygame using c-types. The project did not receive a good reaction from the community as the pure python rewrite did not have the performance of the c version and hence was abandoned.
Pyglet was originally just going to be a nice library which used OpenGL functions to render sprites and text. Alex had always meant to write this library to help with common features he found himself implementing every pyweek. Prior to starting development Alex thought about the project some more and based on his summer of code experience realized that a lot of the things that Pygame does with SDL does could be done in python without any c library dependencies. So the original idea behind Pyglet was to gets rid of Pygames distribution problems by having a library which you could drop in a folder and just run without compiling anything, also the libraries focus on OpenGL rendering would compensate somewhat for the interpreted slowness of python. Apart from Avbin, which is an optional component used for audio and video, Pyglet is totally written in pure python.
One of the big potential problems of developing games with Pyglet is it’s reliance on OpenGL to render graphics to the screen. Typically a developer using OpenGL needs to be much more aware of resource management and what options/states he has used at any given moment within an OpenGL context. In contrast SDL, which Pygame is based on, has two options for rendering either using OpenGL or SDL surfaces. Pyglets OpenGL focus is a double edged sword as usually it makes simple sprite based games such as puzzle games a lot tricker than they need to be. Conversely this fact also makes things like developing 3D games or impressive graphics a lot easier. Another problem Pyglet faces comes from its design decision to avoid c where ever possible. A consequence of using only an interpreted language like python and no c is that it makes some game related tasks such as writing a real time audio loop practically impossible with any kind of CPU left to spare.
During the course of the interview Alex highlighted both of these problems. A suggested solution was to revaluate one of the core design decision’s behind Pyglet and allow for critical parts of Pyglet to be rewritten in c and tied in to the existing python code base using c-types. However such a rewrite would require a large investment of time and Alex is very busy completing his PHD. Also the current development version of Pyglet available from the subversion repository still requires a large amount of work to be stable and usable. This would probably have to happen first before any major rewrite could occur.
A subtle but significant diffrence between Pyglet and Pygame is the way that they link with c libraries. Their are two ways to hook a c library into python, one is to write a c extension to python, the other is to use a foreign function interface like c-types. Pygame is writen as a python extension, what this means is that for each version of python and each platform a seperate build of Pygame must be made. So for example you would need to do a seperate build for python 2.4, 2.5, 2.6 on Windows, OSX and OpenBSD. Pyglet on the other hand uses c-types to talk to c libraries like Avbin and thus does not need a seperate build for different platforms or python versions.
For me the big take away’s from this interview are that Alex would be open to rewriting parts of Pyglet in c using c-types and that competitions like pyweek have demonstably played an important role in motivating people to write cool new libraries for making games with python. In my view, relaxing Pyglet’s original design goal of being pure python is a good thing and if done correctly could lead to a host of valuable high performance libraries which could be used by other projects apart from Pyglet. Such a rewrite is unlikely to occur anytime soon unless members of the wider Pyglet community step forward to assist Alex in this ambitious endevor.
If you have ever considered making a game with python chances are while researching the options available you came across both the Pygame and Pyglet libraries. The two libraries have taken very different approaches to the challenge of making games with an interpreted language. With Pygame the focus is on abstracting away low level details like how graphics are rendered. Its main assumption is that such things can be completely detached from the game logic. Most of the functionality in Pygame is built on top of its bindings to the c library Simple Direct Media Layer (SDL). In contrast Pyglet is written almost entirely in python and is mainly an OpenGL based software library, which inherently means its focus is on how graphics get drawn to the screen.
The origins of Pyglet can be traced back to 2006 when Alex participated in a google summer of code project the goal of which was to produce a pure python port of pygame using c-types. The project did not receive a good reaction from the community as the pure python rewrite did not have the performance of the c version and hence was abandoned.
Pyglet was originally just going to be a nice library which used OpenGL functions to render sprites and text. Alex had always meant to write this library to help with common features he found himself implementing every pyweek. Prior to starting development Alex thought about the project some more and based on his summer of code experience realized that a lot of the things that Pygame does with SDL does could be done in python without any c library dependencies. So the original idea behind Pyglet was to gets rid of Pygames distribution problems by having a library which you could drop in a folder and just run without compiling anything, also the libraries focus on OpenGL rendering would compensate somewhat for the interpreted slowness of python. Apart from Avbin, which is an optional component used for audio and video, Pyglet is totally written in pure python.
One of the big potential problems of developing games with Pyglet is it’s reliance on OpenGL to render graphics to the screen. Typically a developer using OpenGL needs to be much more aware of resource management and what options/states he has used at any given moment within an OpenGL context. In contrast SDL, which Pygame is based on, has two options for rendering either using OpenGL or SDL surfaces. Pyglets OpenGL focus is a double edged sword as usually it makes simple sprite based games such as puzzle games a lot tricker than they need to be. Conversely this fact also makes things like developing 3D games or impressive graphics a lot easier. Another problem Pyglet faces comes from its design decision to avoid c where ever possible. A consequence of using only an interpreted language like python and no c is that it makes some game related tasks such as writing a real time audio loop practically impossible with any kind of CPU left to spare.
During the course of the interview Alex highlighted both of these problems. A suggested solution was to revaluate one of the core design decision’s behind Pyglet and allow for critical parts of Pyglet to be rewritten in c and tied in to the existing python code base using c-types. However such a rewrite would require a large investment of time and Alex is very busy completing his PHD. Also the current development version of Pyglet available from the subversion repository still requires a large amount of work to be stable and usable. This would probably have to happen first before any major rewrite could occur.
A subtle but significant diffrence between Pyglet and Pygame is the way that they link with c libraries. Their are two ways to hook a c library into python, one is to write a c extension to python, the other is to use a foreign function interface like c-types. Pygame is writen as a python extension, what this means is that for each version of python and each platform a seperate build of Pygame must be made. So for example you would need to do a seperate build for python 2.4, 2.5, 2.6 on Windows, OSX and OpenBSD. Pyglet on the other hand uses c-types to talk to c libraries like Avbin and thus does not need a seperate build for different platforms or python versions.
For me the big take away’s from this interview are that Alex would be open to rewriting parts of Pyglet in c using c-types and that competitions like pyweek have demonstably played an important role in motivating people to write cool new libraries for making games with python. In my view, relaxing Pyglet’s original design goal of being pure python is a good thing and if done correctly could lead to a host of valuable high performance libraries which could be used by other projects apart from Pyglet. Such a rewrite is unlikely to occur anytime soon unless members of the wider Pyglet community step forward to assist Alex in this ambitious endevor.
March 5, 2009
Booking a conference room in the San Francisco public Library
One of the big challenges with running a meetup in San Francisco is finding a venue that can accomidate your group. In the case of PyGamSF our requirements were as follows:
Obviously their are some rules you have to adhere to. Your group has to be non profit and no commercial activity can occur in the rooms. Your group can only make 12 reservations per calander year. The larger auditoriums (read 235 people) can only be booked once per year. All of this is of course perfectly reasonable and a vast improvement on the metreon where we used to host our events. In conclusion the San Francisco public library is a really cool public resource.
- The venue should cost nothing (PyGameSF is not for profit).
- The space should be able to accomidate between 6 and 15 people.
- It should be quite enough to record our talks.
- It should be laptop friendly (read powerstrips and internet for bonus points).
- It should allow for the use of a projector.
- It should be available at hours that suit the schedules of the group.
- It should be in a location thats central and easy for most people to get to (read near bart or muni)
Obviously their are some rules you have to adhere to. Your group has to be non profit and no commercial activity can occur in the rooms. Your group can only make 12 reservations per calander year. The larger auditoriums (read 235 people) can only be booked once per year. All of this is of course perfectly reasonable and a vast improvement on the metreon where we used to host our events. In conclusion the San Francisco public library is a really cool public resource.
March 4, 2009
Random Tech Nugget: Wordpress + svn update the only way to fly.
Maintaining numerous websites can be a real pain: dealing with spam, security vulnerabilities, wierd browser issues, blogging software that’s written in an inherintly flakey a language which makes up about 90% of the exploit traffic to bugtraq (php I am looking at you), the list goes on and on. The key is to where possible pick the right tools and refine your process where possible. However as is oftern the case with life, sometimes you have to comprimise. Wordpress, the software that powers this blog is one of those comprimises. In my experience one of the best ways to install and update is to do so via SVN.
Install:
$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/tags/2.7.1 .
Once you have done the above, simply point your browser at the setup script and follow the standard wordpress install instructions.
Upgrade:
1) make a backup
$ cd blog
$ svn sw http://svn.automattic.com/wordpress/tags/2.7.1/ .
And your done. Tadhg O’higgins also has a great article on working with wordpress which is worth a read if you value making your web life that little bit easier to manage.
Install:
$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/tags/2.7.1 .
Once you have done the above, simply point your browser at the setup script and follow the standard wordpress install instructions.
Upgrade:
1) make a backup
$ cd blog
$ svn sw http://svn.automattic.com/wordpress/tags/2.7.1/ .
And your done. Tadhg O’higgins also has a great article on working with wordpress which is worth a read if you value making your web life that little bit easier to manage.
March 3, 2009
Random Tech Nugget: Tips for Tabs in Vim
One of the omissions from the book on vim I reviewed in my previous post, was that it did not have much information on how to move around with tabs in vim. This article provides a number of cool tips/tricks for moving around with tabs in Vim. One thing missing from both the article and the book is how do you jump to given tab from just a number. I.e if you have say 6 or seven tabs open and you want to jump to the third tab.
I dug the following answer out of the vim docs on tabpages: tabn 3
I dug the following answer out of the vim docs on tabpages: tabn 3