01
Sep
08

In order to put sprites on screen, you must first compile the universe

I’ve just spent my weekend attempting to get pyglet or pygame going on Python for Windows AMD64 (2.6b2).

The process uncovered bugs in pygame and python, including one which is fixed in 2.6b3, although there’s no Windows builds of that version yet. Also, you can’t currently rebuild Python under mingw. Still some patches to go: pygame tries to build a safe version number for bdist_msi however it gets it wrong in release, I suspect the rules have shifted slightly in 2.6…; and whatever else I’ve modified in my build trees that needs to be sent upstream.

Mingw64 was able to build stuff now (thanks to @NightStrike on the #mingw-w64 IRC channel) but Python’s pretty insistent that I build against msvcr90 and mingw64 doesn’t have an import library for that yet (mingw32 does, but mingw64’s runtime collection is only up to 3.11 or so). @NightStrike informed me that pexports has been ported to amd64 on the mailing list, but I haven’t dug it up yet, but that should allow me to link to msvcr90 from mingw.

Either way, I now have a modified win32/Makefile.gcc for zlib which doesn’t use dllwrap (deprecated since 2002) and works with mingw64 nicely.

After mingw64 worked but I hit the requirement of msvcr90, I grabbed the Windows SDK and the DirectX SDK. Once you know to run dx_setenv.cmd in the Windows SDK cmd window and to use vcbuild /useenv (otherwise it’ll ignore the results of dx_setenv.cmd) things seem to just work. You need to set DISTUTILS_USE_SDK in your environment for Python to trust your compiler version choice, too.

Converting SDL‘s Visual C projects and solutions was easy. Change platform from win32 to x64, change any /MACHINE: entries from I386 to AMD64. I should submit that change to SDL, once I convert and test the examples as well. SDL also builds with mingw64, but I suspect it doesn’t produce a DLL at the end right now.

The Windows SDK 6.1 includes msvcr90 and the Visual Studio 2008 beta 2 toolchain, so that works for Python extensions.

However, after building everything fine, initialising pygame fails:

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\root>python
Python 2.6b2 (r26b2:65106, Jul 18 2008, 18:24:10) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.init()
(3, 1)
>>> pygame.get_error()
'DirectInputDevice::SetDataFormat: Invalid parameters'
>>>

The Internet knows nothing about that particular error in reference to pygame. Since I had to install the DirectX SDK to get this far anyway, I’ll see what that produces in terms of debugging output, when I get back to it.

As for pyglet, which started me on this whole mess? Upstream says it’s not supported under x64, don’t bother submitting bugs. Before I found that, I tried to work through their hello_world.py but pyglet.window.Window() came back from OpenGL with “invalid operation” calling glGetString(GL_VENDOR). The whole exercise with pygame came about from me trying to find a way to test if PyOpenGL was having similar problems as both PyOpenGL and pyglet use opengl via ctypes.

OpenGL on windows is hard. There’s a huge amount of setup needed to get a context to be able to call openGL commands, and PyOpenGL doesn’t provide that code. PyOpenGL’s sample code relies on pygame to do this… -_-

And to think this all started because I wanted to prototype a game idea I had rather than just telling my work colleagues about it and hoping for the best. Oh well, maybe next weekend.

It does warm my heart to know that despite being a professional video games programmer I can still come home and spend a weekend doodling around programming.

I started watching Cheap Love, only two episodes in but I’m pleased to see that already the main love pairing have already met and realised they’ve feelings for each other. Most J-dramas I watch make us wait until half way through the season to let the characters know what’s been painfully obvious to the audience since the opening titles rolled.

And in further good news, I’m down below 136kg. ^_^

My task for this week is to turn my barcode scans of my book collection into something I can access while I’m in Melbourne next weekend so I don’t have to call home from Melbourne book stores again to get Mick to look at my shelves for me. I’ve also given my mother the book-barcode-scanning bug, but I imagine she’ll buy some software off the Internet to manage the collection. Recommendations appreciated. ^_^ (Obviously, if you want to recommend such software for me, go ahead as well. But my requirements are somewhat pathological)

Oh, and I’m in Melbourne next weekend for Medleys. Taking younger sister (they’re both younger, I’m talking about younger younger. Elder younger will be on stage) and hopefully catching up with Phil.

Been eating “Instant Stew” this week. Finally refined recipe down to:

  • ~1.2kg of mixed heart-smart meat, diced
  • 1kg bag of Home Brand mixed frozen vegetables
  • 1 tin (400g) diced tomatoes
  • Random spices as I find them in the cupboard

Combine all ingredients in crock pot. Put on before work, arrive home after work. Makes 6 lunch servings or 3 dinner servings, ~350 calories per lunch serving. I blame recent weight-loss success on this stuff.

Turns out that making stew, unlike Python games under Windows x64, doesn’t involve first creating the universe.

About these ads

4 Responses to “In order to put sprites on screen, you must first compile the universe”


  1. 2009年 5月 23日 at 10:31 pm

    Have you built a working amd64 build of pygame for 2.6 yet? I have a bunch of other amd64 modules built if you wanna do some sort of trade for these rare commodities :D

  2. 2009年 5月 24日 at 12:39 am

    To be honest, I completely forgot about this particular side-trip. Around this time we had some shifts at work that completely distracted me from my side-projects, and soon after that I got stuck into Wine development instead.

    Rather than trying to program fitfully in Windows between Warhammer Online sessions, I was playing Warhammer Online under Wine fitfully (and now basically never >_<) between programming sessions.

    So I've uninstalled most of the Windows python development stuff since then, for disk-space reasons. On the plus side, I've learnt a lot more about DirectX, so if I ever get back to it and hit the same error, I'll have more of an idea what to do about it.

  3. 2009年 5月 24日 at 12:40 am

    I also never got any further in Cheap Love. I’d forgotten where I was up to, now I know so I can finish it. ^_^


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: