Archive for wtf

Using gl_VertexID without any VBOs.

Posted in How To, Programming with tags , , , on 2013/02/03 by Adam Griffiths

Normally, gl_VertexID is the index of the currently rendered vertex element.

When you provide indices (GL_ELEMENT_ARRAY_BUFFER), gl_VertexID should match the value provided. Ie, the gl_VertexID value can repeat if you render the same element multiple times.


I say “should”, because this is NOT correct when you haven’t provided any VBO data.

This means, that if you are rendering using nothing but a shader and a GL_ELEMENT_ARRAY_BUFFER, the gl_VertexID will NOT match the indices you provide, and will instead be a sequence from 0 -> N.

The solution is to use a single VBO and use glDrawArrays.


Personally, I consider this a bug.

Adobe Air hanging when using SDK but not when packaged

Posted in How To with tags , , , , , on 2013/01/30 by Adam Griffiths

I just had an issue during the development of an Adobe AIR Application.
When using Flash Pro CS 6, the application hang in certain situations for 5 odd seconds.

I found a few peculiar quirks:

  • Packaged builds didn’t have the problem.
  • Moving the project to a different directory fixed the problem.
  • Clean checkouts of the source didn’t have the problem
  • Re-creating the project in Flash Pro CS 6 didn’t fix the problem.

The console was printing the following messages

Breakpoint not set; No executable code at line ###

It turns out the problem was old breakpoints that don’t exist anymore.
There’s not trivial way to remove all the breakpoints (the button was greyed out!).
The easiest way I found (on OS-X) was to do the following:

vi ~/Library/Application\ Support/Adobe/Flash\ CS6/en_US/Configuration/Debugger/AsBreakpoints.xml

Remove all the breakpoint entries in the XML.
The file should look similar to this:

<?xml version="1.0"?>
<flash_breakpoints version="1.0">

This resolved the issue.

Adventures in Kivy

Posted in How To, Programming, Rant with tags , , , , , , on 2012/03/22 by Adam Griffiths

So here is a semi-live blog as I delve into Kivy.

Mission #1: Attempt to resize the default window

Ok let’s start at the start.

We first create an object that inherits from App. Done.

Ok, and the examples all return a widget from the App’s build() method. So we don’t over-ride __init__… ok… thats… unique.

Perhaps the widget is the window if it is returned from the build() method?

Widget is not the window. Widget returned from build() is added to the window. So… where is the window created?

Window docs state the window has a constructor that lets you set the window size. Ok, cool. But we don’t create the window… so.. we can’t use the constructor… sigh.

Ok, Window has a static accessor.

kivy.core.window.Window = None

No comment on what is stored here but I assume it’s the instantiated window. It doesn’t mention when it is set… handy!

Only 1 window allowed. Ok… weird. Well… let’s try that.

import kivy.core.window.Window
AttributeError: 'module' object has no attribute 'window'


Let’s scour the code.

Screen capture of Kivy window module

No file……… how far does this rabbit hole go.

Ok, let’s check out the file in the window module.

class WindowBase(EventDispatcher):
 '''WindowBase is a abstract window widget, for any window implementation.

So… window base is in there. Feel free to scream now.

So we can get this by importing kivy.core.window and just leaving the class off the end.

import kivy.core.window
def build(self):
    print kivy.core.window.Window.size
    return None
(800, 600)

Ok sweet, thats our window.

So let’s change its size.

def build(self):
    print kivy.core.window.Window.size
    kivy.core.window.Window.size = (1024, 768)
    print kivy.core.window.Window.size
    return None
File "/Users/adamgriffiths/Workspace/VirtualEnvs/progress_quest/lib/python2.7/site-packages/kivy/core/window/", line 243, in _set_size
 if super(WindowBase, self)._set_size(size):
 AttributeError: 'super' object has no attribute '_set_size'


Ok, so after some googling we find this post about the relationship between the App and Window classes.

His solution is to pass the size as a command line parameter……….. LAME. That kinda throws the whole configuration settings thing out the window.

Looking through the Kivy code we find this block inside their base window class’ __init__ method.

if 'fullscreen' not in kwargs:
    fullscreen = Config.get('graphics', 'fullscreen')
        if fullscreen not in ('auto', 'fake'):
        fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup')
    kwargs['fullscreen'] = fullscreen
if 'width' not in kwargs:
    kwargs['width'] = Config.getint('graphics', 'width')
if 'height' not in kwargs:
    kwargs['height'] = Config.getint('graphics', 'height')

Ok, so we can try and set it via the global config object.

So let’s add that to our App class.

def build_config(self, config):
    config.setdefault('graphics', 'width', 1024)
    config.setdefault('graphics', 'height', 768)
    config.set('graphics', 'height', 1024)
    config.set('graphics', 'width', 768)

Run the code and……

(800, 600)

……. sigh

So let’s put some debug INSIDE kivy and see what is happening. We’ll also force it to pull the ‘graphics’ setting and ignore kwargs.

if True: #'width' not in kwargs:
    kwargs['width'] = Config.getint('graphics', 'width')
print kwargs['width']
if True: #'height' not in kwargs:
    kwargs['height'] = Config.getint('graphics', 'height')
print kwargs['height']

And the output…


…. calm blue ocean…. calm blue ocean….

Ok… google…

Hmm.. ok, this post on the kivy-users forum (because documentation is for lusers) shows a similar method.

They use the Config module directly instead of the config object passed to App….. because….. they’re not the same? Well.. let’s try it anyway.

from kivy.config import Config
Config.set('graphics', 'width', 1024)
Config.set('graphics', 'height', 768)

And our output

(800, 600)

Ok, weird because the window HAS ACTUALLY CHANGED SIZE.

Whatever. We’re all living in crazy-ville atm so let’s just pretend everything is normal.

So let’s move that inside our build_config() method.

def build_config(self, config):
    Config.set('graphics', 'height', 1024)
    Config.set('graphics', 'width', 768)

And the output

[INFO ] Kivy v1.1.1
[INFO ] [Logger ] Record log in /Users/adamgriffiths/.kivy/logs/kivy_12-03-22_40.txt
[INFO ] [Factory ] 102 symbols loaded
[INFO ] [Text ] using <pygame> as text provider
[INFO ] [Loader ] using <pygame> as thread loader
[INFO ] [Window ] using <pygame> as window provider
[WARNING] [Window ] Unable to use <pygame> as windowprovider
[CRITICAL] [Window ] Unable to find any valuable Window provider at all!
Fatal Python error: (pygame parachute) Segmentation Fault
Abort trap: 6

(╯°□°)╯︵ ┻━┻

Installing Pyglet in Mac OS X

Posted in Development, Platforms, Programming with tags , , , , , on 2012/02/21 by Adam Griffiths

Pyglet is a common requirement for many Python applications, a major one being Cocos2D.

But it doesn’t work out of the box. Running a Pyglet application will result in the following error:

OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/QuickTime, 6): no suitable image found.  Did find:

/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture

/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture

The following are the steps to take to get Pyglet and PyObjc installed on OS-X (tested with 10.7 Lion).

Pyglet 1.1 uses the Carbon framework, but this is not compatible with 64-bit Python installs. The Pyglet 1.2 branch has been modified to use Quartz, but no releases of this branch have seen the light of day (sigh). We must instead install Pyglet from the Mercurial repository.

The Quartz bindings require the use of PyObjc but the latest versions do not work with Pip. The patches to PyObjc’s that I’ve seen on the internet do not work for me. The following is the only method I’ve had work.

Remove any existing Pyglet install

pip uninstall pyglet

Install Pyglet from the repository

pip install hg+

Edit: The following is no longer needed

We need to install PyObjc for the new Pyglet Quartz API. But PyObjc is horribly broken and the latest version does not install with Pip or easy_install.

We must instead install an older version.

pip install pyobjc==2.2

You should now have a working Pyglet installation.

Registering Event Handlers in Pyglet

Posted in Development, How To, Programming with tags , , , , , on 2011/06/25 by Adam Griffiths

The Problem and Pyglet’s own solutions

Pyglet’s documentation suggests a number of methods to receive events.

The recommended method of using @ decorators works for global methods where the event object is known. But if its for a class method or the event object is passed in later, this will not work.

The alternative is to simply over-write the existing handler with something like

window.on_resize = self.on_resize

Unfortunately most of them end up with the following error:

window.set_handler( window.on_key_release, self.on_key_release )
AttributeError: 'Win32Window' object has no attribute 'on_key_release'

This discussion on the developer list explains it. This method only works when the platform’s window class has an existing method to handle the event. And not all events are handled by default, so when you come across this, BOOM!

Even then, when it works this is also a double edged sword. The existing handlers are there for a reason! For example, if you over-write the on_resize method of Window your application will no longer draw (took me a while to figure this out).

So yes, Pyglet’s documentation is really, REALLY, asking for trouble.

The Proper Solution?

Use the “push_handlers” method.

Pyglet automatically detects a method with the event’s name and dispatches the event.
So we can just add methods to our class and we’ll automatically receive the events.

class Test:
  def attachToWindow( self, window ):
    window.push_handlers( self )

  def on_key_press( self, symbol, modifiers ):
    # method name matches the 'on_key_press' event!
    print "Keypress"

Or we can manually specify which events we care about.
If we do this, we must specify the actual function that receives the event.

class Test:
  def attachToWindow( self, window ):
    window.push_handlers( on_key_press = self.on_key_press )

  def on_key_press( self, symbol, modifiers ):
    # method name matches the 'on_key_press' event!
    print "Keypress"

Amnesia… really

Posted in Uncategorized with tags , on 2011/05/28 by Adam Griffiths

Amnesia is a game I can’t play.

I’m not ashamed to admit that. There are a number of games I can’t play. System Shock 2, Doom 3, Blair Witch, the list goes on.

Anyway… Amnesia… I bought it because Thomas Grip is a friend of a friend of mine and I wanted to support him. But I’ve never even installed it.

I was telling a few friends about Amnesia last night. They were pretty excited by what I said.

I wake up this morning, Amnesia is in my Steam Favorites list……….. but how? It wasn’t in there before! My computer was off when I got home so I can’t have done it myself.

But there it is, between Alien Swarm and ArmA 2… seriously… wtf…

A good case for mandatory castration

Posted in Rant, Uncategorized with tags , , , on 2011/04/20 by Adam Griffiths

Murtle76 not only hates a game he didn’t bother to play, but insists that he isn’t insulting or annoying anyone…

Steam region pricing is getting rediculous

Posted in Games Industry, Rant, Uncategorized with tags , , , , on 2011/04/14 by Adam Griffiths

This discussion regarding Borderlands pricing differences, although not a big deal this time, is the latest in a long line of regional pricing FUBARs.

I saw that Borderlands standalone (US$7.49) and Borderlands GOTY edition (US$7.50) were both on the “Top Sellers” list.

I thought perhaps people were boycotting the DRM encumbered DLC for the game (included in the GOTY edition), which made me happy!

Then I checked the forums and realised I was wrong. Different regions, again, have vastly different prices:

US pricing:
Borderlands GOTY = $7.50

Borderlands = $4.99

DLC = $7.49

Borderlands + DLC = $12.48 (greater than GOTY by $4.98)


Borderlands GOTY = $7.50

Borderlands = $7.49

DLC = $7.49

Borderlands + DLC = $14.98 (greater than GOTY by $7.48)


Borderlands GOTY = £7.50

Borderlands = £4.99

DLC = £4.74

Borderlands + DLC = £9.73 (greater than GOTY by £2.23)


Borderlands GOTY = €12.50

Borderlands = €4.99

DLC = €5.99

Borderlands + DLC = €10.98 (less than GOTY by €1.52)

As you can see, this pricing is literally schizophenic.

I don’t believe this is Valve (although their Steamworks page does say that they will suggest pricing for games), I think this is the publishers stepping up pressure on Valve to fall into line. And unfortunately it’s working.

I made a comment that perhaps we should all band together to make a “Steam Gifting Co-operative”. Thing is, I was serious.

Many deals in Europe or the AU are far inferior to the US pricing. The region banning is stupid. This usually isn’t Steam but government ratings forcing publishers to offer modified versions (eg. L4D2 with fading out corpses instead of normal version). Grand Theft Auto: Vice City is still NOT on steam in Australia (thanks guys, you forced me to pirate it) although GTA3 and GTA:SA finally are.

Gifting gets us around this. It can also get us around the price issues. The only problem I can see is something like this happening if the “giftor”s bank account goes into the negative. Which is pretty horrific.

People would be re-imbursed for gifts (this isn’t a charity!). The only problem is ensuring that the “giftee” pays the “giftor”. Most bank transfers take a day and by then most deals would be over. I believe PayPal transactions are instantaneous, but I’m not sure. If it is, this would negate this issue.

I think a gifting co-operative is a very realistic and simple way of negating some of the publisher’s influence on Steam.

There are a few forum threads doing exactly this (NeoGafAwkward Zombie), but we need to make it more formal and easier to use.

There needs to be a way to:

  • Request a gift from a specified region (“giftee”).
  • Notify of our intention to fulfill a request (“giftor”).
  • Select a “giftor”.
  • Notify of payment sent, gift sent, gift received.
  • Comment and add to user’s reputation (ala Amazon) for both “giftee” and “giftor”.
  • Cancel a gift request.
  • Quickly view current gift requests with filters for region, age and user rating.

How many times do we have to say it?

Posted in Games Industry, Rant, Uncategorized with tags , , , , , , on 2011/04/13 by Adam Griffiths

DRM doesn’t fucking work!

The truth of DRM

Posted in Games Industry, Rant with tags , , , , , , on 2011/04/01 by Adam Griffiths

I just posted this on Steam, it’s a rant but I think it expressed my feelings on DRM quite well.

Content protection system

Post below in-case you’re scared of the Steam forums (don’t blame you).

Continue reading

Shuffling deckchairs on the Titanic

Posted in Rant with tags , , on 2011/02/04 by Adam Griffiths

The company I work for just fired half of our engineers. I resigned a few weeks ago and was content to work out the remainder of my contract, but this has really angered me.

Continue reading

TSA… Meet World.

Posted in Rant, Uncategorized with tags , , , on 2010/11/23 by Adam Griffiths

And here I was thinking I was the only one who thought this whole thing was crazy. The TSA have posted to their blog regarding their “enhanced pat-down procedures” and the comments are brilliant.

Rob Schneier has written about the TSA and their security theatre charade many times. His arguments are the most sane and logical I’ve found and totally slaughter the TSA’s.

In response to the security theatre, people have started the “National Opt-Out Day”.

This is why we can’t have nice things…

Posted in Platforms, Rant with tags , , , , , , on 2010/11/15 by Adam Griffiths

So my Ubuntu Netbook Remix 10.10 install lasted me less than a single day, and now I have the choice of trying again and hoping, or trying out the other netbook distros.

But wait… let me re-wind there.

Continue reading

Windows Vista without SP1 == Bad

Posted in Platforms with tags , , , on 2009/04/22 by Adam Griffiths

For the last month I’ve been having issues writing a basic ping program that would always trigger a Blue Screen of Death (BSoD) when used in a multi-threaded way.

What I discovered was an abhorent oversight by Microsoft that should never have left a developers desk, let alone made it to release.

Continue reading

%d bloggers like this: