Procedural City, Part 13: “Release” of Program and Source

By Shamus Posted Tuesday May 5, 2009

Filed under: Programming, Projects 191 comments

Screensaver


Link (YouTube)
I hesitate to call this a “release”. The program has been tested on exactly one computer, which can’t even be called a “test” with a straight face. Not only is this not a release version, it’s not even beta-worthy. Even internal alphas have undergone more scrutiny than this program. It is only my boundless hubris that allows me to call this “version 1.0”.

But I don’t have any machines suitable for testing right now, and I don’t have time to run some sort of open beta. Besides, any such effort would quickly fill up with people who were just there for the software and not really into the whole “test unreliable software and then report in detail all the ways in which it failed to work”.

So I’ll preface this release with a stronger version of the usual disclaimers: No warranty is implied, it might not work, use at your own risk.

Sorry to the Mac users. I do not omit you out of malice, but I’ve never developed for Macs before and have no means of doing so.

Download PixelCity v1.0

Take the PixelCity.scr file out of that archive and put it into your /Windows directory and you should be ready to go. There is no configuration dialog, so when you hit the “settings” button in ScreenSaver configuration, nothing will happen. Just hit F1 while the program is running to get a list of things you can do. Be sure to press ‘E’, as it will show off some full-screen effects I haven’t mentioned or showcased before. (I wanted to have some surprises! Although perhaps seeing the message “This program as performed an illegal operation and needs to close” will sate your desire for surprise.)

Please do consider spreading the word on this project on your blogs or wherever you tell people about cool stuff. Reluctant DM was nice enough to put it up on Digg, but Digg has yet to respond to anything I’ve done. Projects, comics, articles. I’ve gotten links from some internet hotspots, but I’ve never earned more than an indifferent shrug from Digg. It’s a very FARK-esque audience and I doubt I’ll get any digs until I write my magnum opus: Procedural Man Getting Hit in Balls with Baseball. (It works on so many levels!)

Source

I’ve put the project on Google Code, although I’m not sure if I will continue with the project or not. I’d love to keep working on it, but further changes will most likely make for dry reading, and that means the project would no longer be feeding this website. We’ll see.

I’m using MS Dev Studio 6, which turns eleven years old this year. Sorry to those of you using development environments forged sometime during this millennium. This is something I cannot change. Although to be fair, migrating from my platform to your is likely much easier than going the other way.

Development

In Win.h there is a #define that lets you disable screensaver mode, which is crucial for development. Setting SCREENSAVER to 0 will change the behavior of different parts of the program and give you access to the primitive and unintuitive development camera.

If you want to test it in screensaver mode, set SCREENSAVER to 1 and invoke the program with the /s command-line option.

Porting

The program is very much tied to Windows at this point. I tried to quarantine all of the Windows-specific code into its own ghetto module (Win.cpp) but that didn’t really work. The stuff for generating a render contex and loading fonts in Render.cpp is also windows-specific, and of course you must #include windows.h everywhere you use Gl.h, which is just about everywhere. And finally, checking the millisecond timer means calling the Windows-specific GetTickCount (). So those items will probably form your to-to list if you’re looking to port.

Optimizations

There is a lot of work that could be done to speed this thing up. Many promising ideas were suggested in the comments during the three optimization posts.

Switching to vertex buffers would likely give a huge boost. (See the comments at the top of Mesh.cpp.) A lot of improvements could be made to the visibility table and how cell visibility is determined. And I suspect there’s a better way to fill the bloom buffer than the one I’m using now.

I didn’t pursue these because there’s just no point in trying to optimize any further on this machine. To be done right, the changes need to be done on an older machine. Profiling can help, but only in cases where old and new hardware encounter the same bottlenecks. The thing runs at 200fps+ on my machine, and it’s entirely possible that I could ratchet that up to 300fps in such a way that provides almost no benefit to the poor guy running the thing on an old laptop. Furthermore, at this speed it’s pretty hard to detect improvements amid the noise, so it’s hard to get a feel for how effective changes are. (Again, profiling doesn’t tell you about those every-ten-frame lurches that are imperceptible at 200fps and nauseating at 20fps. There is simply no substitute for testing on the right hardware, which is why the loss of my old computer was such a terrible blow. I’m currently watching family members to see if any of them are going to upgrade soon. Ideally, I hope to inherit a ~2004 machine.)

Still, I’d start with vertex buffers.

Derivative Work & Collaborations

I am gratified to see that so many people want the source and are eager to do new and cool things with it. I’m not sure how we should go about this. Google Code isn’t up to tracking a dozen forks of the project, and I don’t have time to administrate that sort of activity anyway. Ideally we want someplace where people can swap code, knowledge, and screenshots. Some people will no doubt struggle getting it to compile on their different (from mine) development environment, and a little help from others can go a long way towards saving everyone time & headaches.

This is ideally the job of a forum, but I’m not in a position to provide one of those right now. It would be perfect if such a thing was available along with Google Code, alas.

I’m open to suggestions.

UPDATE: The codebase is now available on GitHub, which has the source file / social functionality we’re looking for:

http://github.com/skeeto/pixelcity/tree/master

Future Work

While I have many features I’d like to add, I don’t have any immediate plans to do so. Right now I’m going to wait and see if there are any egregious problems with the screensaver.

But if pressed, I suppose I’d like to add the following someday:

  1. Port the thing to wxWidgets, which might give me the cross-platform access I’ve always wanted. (Win, Linux, Mac.)
  2. Implement vertex buffers.
  3. Fiddle around with the city-generation parameters. I don’t think I’m getting as much variety out of the existing code as I could. More mid-size (25 story) buildings with a large footprint might do a lot to break up the “bar graph” effect I have going now.
  4. And of course, the street-level detail is a timehole which is happy to consume any effort I’m willing to put into it.

Thanks for reading. It’s been fun.

 


From The Archives:
 

191 thoughts on “Procedural City, Part 13: “Release” of Program and Source

  1. James says:

    Don’t use vertex arrays, use vertex buffer objects! The VBO extension is available on almost all hardware (even on my integrated intel chipset on my netbook) and stores all the geometry data in GPU memory. As its an extension to vertex arrays, the syntax is practically the same, so you can always fall back on vertex arrays if the hardware doesn’t support it. In my project I noticed about 60% increase in performance when I switched from vertex arrays to VBOs!

    Also try using the framebuffer object (FBO) extension to do your render-to-texture routine for your bloom effect. It’s a really simple API and the optimal method for this type of thing.

    Overall a good project! I’ve enjoyed reading through the progress of it! Well done!

  2. S Jones says:

    Thanks for sharing your brilliant series and its fruits, the screensaver and its source. Tagging along with your thought process was an insightful trip.

    Suggestion: It would be great if you implemented a properties page w/ a setting that limited the screensaver to a single monitor in a multi-monitor setup. On dual monitors, not only does it bog down but the focal point is the gap between monitors.

  3. Kellandros says:

    Tried it on my work PC; the little section in the screen-saver tab takes 5+ minutes to load(in the tiny window). I’ve waited a few minutes, but nothing happens yet.

    Pentium 4, 3.0gHz, 1.5gb RAM, Windows XP Pro SP3
    Integrated graphics.

    I don’t expect much on this machine, but giving you feedback. Will test again after lunch.

  4. Ben says:

    It’s really nice to see the whole development process, and then get to play with the result!

    I also took a moment to play with it on an older computer, right around that 2004 vintage you’re looking for (2.2 GHz Athlon 64, GeForce 7600gs). Running at 1024×768, I get 61 FPS. It’s CPU-limited, though, and does jump slightly about once per second.

    Again, very impressive project. Thanks for posting all the results for us to play with!

  5. Simplex says:

    I wrote a comment and sent it, but it evaporated somehow.
    City looks great, esp. considering it’s procedurally generated.

    I noticed some visual glitches on the sky texture. I enhanced gamma to make it more visible on the pictures:
    http://imgshack.info/images/ohbdw4pkc6bkhjfmfs.png
    http://imgshack.info/images/rj3e28iauw9dsv25ovfu.png

  6. Andrew says:

    github.com should give you some features lacking in google code like easy forking.

  7. Fenix says:

    Runs fine. Get 35-70fps. Machine is: 3.2ghz P4 HT, 2gb Ram, 256mb GeForce 8600gts. Loaded in maybe 4 seconds. Love the extra effects.

  8. Jazmeister says:

    This worked really well for me, although the textures looked a little grainy and low-quality on my epic computer. Ultra Graphics Mode?
    It also seems like the street lights are just too big. Like, plainly, they’re just too big, because if you think of the size of a window full of light, and the size of a headlight, you could afford to have the actual bright pixels be very few, I think. Try just doing nothing with the streets, maybe? Then add lights until it’s too much? Grah, you probably did all this anyway. Silly me.

    Still, great work.

  9. Noah Gibbs says:

    What Andrew said — GitHub is perfect for extensive forking, though git is enough of a pain that you should look for web tutorials on how to use it if you’re going to try it. If you already know SVN, this one is pretty good.

  10. jimminyjojo says:

    I’ve been following this post and its great to finally see the end product! I think it works great as a screensaver. I get 61 fps at 1600×1050 resolution with 2GB ram, 2.8ghz cpu and Nvidia 8800. For some reason I can’t see the sky but the buildings look great.

  11. SiliconScout says:

    I can’t get it to load on a multiple monitor machine (3 monitors at 2 different resolutions). However if I don’t extend my desktop (taking back to a single monitor) it works pretty good.

    I didn’t see the skyline either but still looked nice.

    Good work man.

  12. nine says:

    AWESOME! Looks great, and it seamlessly spans over my two monitors (you don’t know how rare this is in 3d screensavers). This is GREAT WORK.
    I’d love a way to see more city though, like making the city 3 times wider and longer so we can see a huge expanse?
    And every 3d app needs a FPS counter :P

    1. Shamus says:

      For those not seeing the sky:

      Hit the “G” key, which turns on fog.

      Fog should be on by default. It apparently isn’t. Bug.

  13. McNutcase says:

    Wow. The bloom really hurts framerate on my rig (P4 2.8, 2GB RAM, XP Pro SP3, nVidia GeForce FX 5200 (not my choice) running at 1024×768).

    Default (looks like Vaseline on the lens), it struggles to beat 7FPS. Without bloom (hit E until one before the default) it happily sits at 25.

    It’s still pretty, and believable. I’m not sure what you could do to make the streetlights look more “right”, but they’ll do.

    1. Shamus says:

      McNutcase: I had that exact same card when I did my Terrain project, and I thought of it often when implementing bloom. Cards from that generation were incredibly sensitive to alpha-blending, and are the reason I made it possible to turn the bloom off. :)

      Now that I think of it, the bloom displacement is a fixed value. Something like 30 pixels or so. This means at lower resolutions it will displace over a larger percent of the screen. That’s not the right way to do things.

  14. Andrew says:

    It worked on my dual monitor setup, although only running at a 5-10fps. I believe that’s because of the 1440×900 and 1280×1024 resolutions though. I’m running it on my Dell laptop from work, 2.5Ghz processor, 2GB of RAM, and Nvidia Quadro NVS 135M chipset for video.

  15. Christopher says:

    Mine was the 100th download! Do I get a prize?

  16. Chris says:

    Have a look at github. It supports a wiki, bug tracking, etc. Barrier to entry is learning a little git, but it’s really not that hard.

  17. Factoid says:

    Waiting for it to load. I have a very strange setup, though so I really didn’t expect it to work:

    I have a macbook pro with Windows XP running in VMWare Fusion. It sits at a black screen for about 5 minutes and then the loading clock appears, loading at a rate of about 1% every 10 seconds. I haven’t gotten it open yet, because I accidentally moved the mouse.

    Any way to make this thing NOT a screensaver? Ideally it would be nice to not have to avoid touching my mouse lest the thing go away

  18. mister k says:

    I just get a black screen….

  19. RichardB says:

    Beautiful work!

    FWIW I get 61 fps on two 1280×1024 monitors, 3GB RAM Core2 Quad CPU @ 2.40 GHz (4 CPUs), GeForce 8800 GT, XP Pro SP3.

  20. Michael says:

    I didn’t see any of the buildings. They are there in wireframe mode, but not in the normal render mode for some reason. I’ll test again on my laptop after work.

  21. nine says:

    at very high resolutions, the bloom displacement (in the second mode) seems to bork too.

    The textures lose quality a little fast when they are almost perfectly side on to the camera too, with the text signs in particular you can see this issue.

    again: AWESOME!

  22. Primogenitor says:

    Works for me on Vista x64.

    “This is ideally the job of a forum, but I'm not in a position to provide one of those right now. It would be perfect if such a thing was available along with Google Code, alas. ”

    Google Groups perhaps? I know its basically the old BBS system with a web front-end, but might work well enough.

  23. Nick says:

    Runs like crap on my work computers here.

    First, a celeron 2.66 Ghz computer with 512 MB ram I lost patience waiting for the black screen.

    I then tried it on another computer, a GX620. This baby is a P4 3.4 Ghz with 3.5 GB of ram. It’s video card is unknown, as it’s using the standard VGA controller. On this computer, I let the black screen load for a few minutes before I saw anything, in which I saw a white circle with .98% in it. I gave up then.

    I can’t understand why these computers fail at the slightest amounts of work. They struggle badly when I run anything. I tried Dwarf Fortress on the second computer, and quit when the intro video was running at 3 seconds per frame. Is it possible because I’m running on Windows server 2003?

    Will try it on my screaming computer at home later today, though.

    1. Shamus says:

      The long black pause before the loading clock appears is a bit confusing. That’s a pretty quick step, and it’s all CPU. It’s less than a second on my machine. Even going down to a machine with one tenth the power shouldn’t be much over ten seconds.

      There is something wrong happening there.

      Oh, and I just noticed: Memory leak. Every time the city is rebuilt it throws some memory away. Nice one. Who is writing this crap, anyway?

  24. John Lopez says:

    The program runs great as a screen saver. Two 1680 x 1050 screens (3360 wide total) run at 45 FPS with the default startup configuration.

  25. Factoid says:

    After I finally got it to load, it’s doing about .3FPS on my XP virtual machine on a macbook pro. Granted 3d performance is one of the things that Fusion VMs are the worst at…but I thought it was supposed to be possible to play games and stuff through fusion.

    I’ll try this on my non-virtual PC at home.

  26. Nico says:

    nine – that looks like one of the effects from when you hit E… are you sure you didn’t accidentally tap it or something?

    I get high 80’s fps at 1650×1050 on my Core 2 Quad Q9450 @ 2.67 GHZ, 4 gb ram, 1 gb 4870, Vista X64. I get a bit over 200 on the same settings with bloom off.

  27. I cloned the Subversion repository, converted the username, tossed the svn metadata, and put it on GitHub. You can get/see it here,

    http://github.com/skeeto/pixelcity/

    If everyone forks off of this then we have a common base to work from so merging will work without trouble.

  28. Nick says:

    Yeah, these computers shouldn’t be performing anything close to an old pentium, so I can’t figure out why things like DF and this have a heart attack doing things that seem CPU related.

  29. Face says:

    Worked on my Vista machine just fine. I’m getting 59-65 FPS and it looks pretty good. I think that if I was getting up to 100 it might look a lot better, but it’s not choppy or anything right now. I do wish there was a way to slow down the panning/movement as it is almost impossible to read the signs at the current speed.

  30. Mike says:

    Alas, though I have been waiting in anticipation for this to come out, it chokes and dies on my machines here at work. Given that they only saw fit to give me an inspiron 1525 (Pentium Dual Core 1.86, 2 GB ram, intel 965 express mobile) this doesn’t surprise me. This thing chokes when I compare text files. But I digress. Cranking my resolution as low as it would go and unplugging the external monitor, unfortunately, got me no further.

    My other work machine, equipped with an AMD 64 3200+, 512 mb of ram, and a radeon xpress 200, actually managed to spit out 20 FPS with the bloom off. Bloom on, it stutters along at 11 FPS or so, at 1280×1024. At this point renewed frustration with the jokes they call the machines they equipped me with at the office overwhelmed my desire to see this in action, so I’ll give it another go when I get home and actually have a proper machine to work with.

    I will say that what I saw makes me grin, and I look forward to having it action at home. This should make for an awesome screensaver on my HTPC in the livingroom.

  31. Graham says:

    One thing about street lights is that they mostly point downwards (to limit light pollution). Perhaps some way to block out a cone of light about the lights with a certain angle would make them look “more real”.

    I also noticed the trying to turn on frame rate with the f1 help displays does nothing, but trying to display the f1 help when the framerate is showing toggles between the two.

    All in all, great job. First thing I’ve seen in ages that made me want to change from the really slick screensavers.

    Worked without any problems on WinXP, 2x 1680×1050 monitors, driven by Radeon x1550, Intel Core2 6600 @ 2.40 GHz, 2GB RAM. Although with bloom on, it’s a little chunky (~10-14 fps). With just the plain city, or the rainbow window effect, I get ~25-30fps

  32. Delta Force Leader says:

    I can’t get the program to run on my laptop.

    Windows XP SP3
    Intel Celeron M 1.3 GHz
    2 GB RAM

    The program runs in the display properties screensaver tab; however, it takes over a minute to load, looks choppy, and is missing most of the lighting.

    When I try to run the full screensaver, it closes down after 30 seconds without ever displaying anything expect for a black screen.

  33. Kellandros says:

    Update: After coming back from lunch(~ 45 minutes), saw it was 85% done with the loading clock screen. A few minutes later, it finished and actually started. Looks awesome!

    Couldn’t get a framerate for some reason, but it was acting like a slide show- popping up different views of the city, but I never saw any animation.

    Again, this computer lacks any 3-D acceleration, so not surprising. Will see what my semi-cheap but newer laptop does at home.

  34. Patrick says:

    On my computer at work I get 7 fps with default setting spanning across 2 monitors (1280×1024) (Duel core 2.4, 3.25 gigs of Ram, Radeon HD 2400 Pro). However, if I turn off bloom the frame rate goes up to 40. Also if I turn off the extended monitor the frame rate doubles (no surprise there I guess).

    This is a really cool little program. Thanks for sharing it and thanks for sharing what went into making it.

  35. perry says:

    well, i was very excited. but i get only a black screen. i managed to open task manager and saw that pixelcity was using 50% cpu and about 12mb memory. by the way i am on a core duo 1.6ghz, 2gb ram and winxp. oh and also the very crappy intel 945gm. maybe someone can figure out a fix?

  36. Trorbes says:

    I have a similar configuration to #12 McNutcase + 1152×864 resolution, with similar results. 20fps with no bloom still looks good, though. The buildings look really nice.

    I can see why you were so dissatisfied with the street view; car lights sometimes flicker between red and white viewing them from head-on, look like slivers from the sides, and the lamps don’t look good any angle. For some reason, the lamps seems to exist inside the streets, so it looks like they just hover over the road while cars pass through them.

  37. Jeremy says:

    Google Code now supports Mercurial, which is distributed like Git, but is easier to use and understand and works better on Windows. Details here.

  38. yd says:

    Latitude D820 Laptop with 2.2Ghz Core Duo, 3.2GB ram, dual-monitors 1920×1200 and 1280×1024 on an NVIDIA Quadro NVS 110M.

    It’s choppy – 4FPS with both monitors. The bloom lags behind the buildings by as much as 200 pixels.

    12FPS with just the 1920×1200 display.

    Both letterbox and textures off each have only a 1-2fps improvement.

    Turning off bloom brings it up to 30fps on just the single display – not amazing but usable. There’s a very obvious stutter every second or so that’s distracting.

    Load time with one monitor vs. two is significantly faster. More than half the load time, it seems.

    Cool project; I’ve enjoyed it.

  39. Jennifer says:

    I tried it out on my machine and had no problems, although the sky looks funny–there are distinct corners where the sky boxes join up that makes it look like there’s an enormous black square hovering over the city. Still, that’s a minor quibble. :)

  40. Mantari says:

    Very nice! I like the eye candy. I just can’t get the boomer or the tank to spawn. Can you help me?

  41. edcalaban says:

    Works fine for me at an average of 20.5 FPS. (edit – switched effects modes and it jumps to 60 fps, so I’m leaving the shiny lights off).

    Couple of things I’d appreciate:
    1) a way to slow it down! It pans a little too quickly for me to be able to read most of the signs. (edit – when I switch effects modes this goes away. Probably a framerate issue).
    2) In wireframe mode (awesome), why are some of the radio towers purple or other random colors? I’m so confused!
    3) Occasionally the skybox has weird texture effects going on. I think it might be the corner, but it’s something to look into.
    4) Can you reduce the amount of awesome? I need to get back to work and the having to wait to see the screensaver prevents that.
    5) Cars crossing left to right and vice versus look really weird while traveling down the street.

    Just a warning: leaving the windows screensaver selector thing on in the background while mozilla is open will slow mozilla down like crazy. Found that out trying to edit this!

  42. Mari says:

    I’m getting 75-80 FPS on my AMD Athlon 64 X2 2.3gHz with only 1 GB of RAM and a GeForce 8800 GS. But nothing in the settings is changing the frame rate by more than a frame or two per second for me. On my machine I would certainly call it a success. And it’s entrancing, not just for me but for everybody who’s walked by me since I started playing with it. Thanks so much, Shamus, for sharing the process and the results.

  43. K says:

    I also have trouble with multiple monitors. Also, it is really choppy, except when I go into “City of Lights” mode, then it becomes totally fluent. What does that tell me about my hardware?

    Also: No fog or working skybox on this Radeon x1600

  44. Steve says:

    Sadly doesn’t run on my little Lenovo laptop… It’s a core 2 duo 2.1ghz, butdoesn’t have much of anything in the way of 3d horsepower, though. I imagine that’s why it won’t run.

  45. Nick says:

    Ran it on a fellow’s laptop here at work, hooked up to a separate monitor for two displays. Loads MUCH faster than on my GX620, but runs really badly until I disable most effects. The bloom really does lag a few frames behind everything until I do so, though.

    Nice, but I can’t get an F1 menu. Only “E” does something.

  46. Doug Brown says:

    Cool. With everything on, I get 5-7 FPS. With everything off, I get a turbo boost to as many as 17 FPS.

    P4 3 GHz
    896 Mb RAM
    ATI Radeon Express 200 Series Integrated Video
    Running at 1280x1024px
    XP Pro SP3

    So there’s an idea of what your 2004 computer can do.

  47. Reluctant DM says:

    Thanks for releasing this Shamus! I can’t wait to try it! The funny thing about Digg is that there is a huge group of people there who would love to hear about this sort of thing but you really need some oomph behind your submissions to get them to stick. I keep being optimistic that even though I don’t have the time to build a gigantic social network centred on Digg that my submissions will get noticed amongst all the lolcats and pron. :) Well, you gained this loyal reader from Digg back in the DMotR days so at least it did something for you! :)

  48. Ranu says:

    It works nicely in linux with Wine :)

    “wine PixelCity.scr /S”

    No hiccups or anything. Loading takes about 4s.

    Specs: C2D 2,8GHz, GT8800, 4GB, Gentoo Linux

  49. “I'm using MS Dev Studio 6…This is something I cannot change.”
    Why can’t you change that? MS VC++ 2008 Express (http://www.microsoft.com/express/vc/) is freely available and is vastly improved.

    Also, 1680×1050 at 61 fps regardless of effects and render mode. I smell a vsync somewhere…

    1. Shamus says:

      Tino Didriksen: Day job. Our software is 15+ years old and has a VERY particular development environment. Any change that I made would have to be adopted by the rest of the team.

  50. Zukhramm says:

    It runs at around 30 FPS, sometimes up to 60 depending on the effects I’ve got turned on. Only problem is… I don’t get any textures. All buildings are completley black.

    http://img239.imageshack.us/img239/5555/pixelc.jpg

  51. Superkp says:

    Looks awesome! Good Job, Shamus!

    I am getting between 15 and 30 fps, and if i fiddle with the different settings I can make it drop down to 5-7, and around 10 is where it actually gets annoying to watch. at some points, it jumped to 70fps, but i don’t know why.

    stats: 1.9 GHz on an AMD Athlon 64 X2 dual core TK-57
    2.0 GB of memory, ATI Radeon X1200 graphics card. 1280×800 resolution.

    I am no code-junky, so I will let it sit the way it is until someone gives me a step-by-step instructions for how to change it.

    (edit: I have also gotten very good praise from a code-junky or two [who appreciate the coding involved] AND from the computer illiterate [who only care about the shiny result])

  52. gebiv says:

    Where do we find the 3-d glasses for that one setting?

  53. vdgmprgrmr says:

    So, it’s pretty nice.

    But there’s some issues.

    1) The way the camera moves causes the image to look jerky, so the business names and such are very hard to read unless they’re really big and you’re going really slow. This might have something to do with the framerate I’m getting. I only have about 15 FPS consistently.

    2) Bloom is just plain horrible for my machine. Firstly, I seem to be displaying the bloom from the frame that came before the current frame, making an annoying ghosting effect, and the bloom takes my framerate from survivable-but-somewhat-disappointing (about 15) to just bad (5).

    3) The billboard thingies will always appear in front of those really thin towers you’ve made, which is odd.

    4) The cars on the road seem awfully scattered. When they first generate, it looks almost like these roads don’t have lanes at all. And the cars’ lights going sideways when they’re sideways to you looks weird. I thought about this, and I wondered if maybe having the car lights rotate to to be the average of the camera angle compared to the car’s orientation and the car’s angle. So a car going directly across the screen will have lights that are rotated to be pointing only 45-degrees away from the camera, instead of a full 90.

    Using… 1.24 GHz AMD Athlon, 512 MB memory, nVidia 5200 FX video card. 1440×900 monitor.

    Also: “… probably form your to-to list.”

  54. Rick says:

    Works great on dual monitors at 1680×1050 each running off a GeForce 8800 GT, Quad Core 2.66GHz, 3.25GB RAM… 60-61 FPS.

    Thanks again for releasing this for us to enjoy.

  55. retrogamer says:

    Don’t fret about not doing good on digg, you are on the front page of reddit.com with 658 upvotes (and climbing!).

  56. Volatar says:

    I just saw a LLC company :D glad you put that in.

    Though, I just checked the source and didn’t find it in the list for names. Is there a mismatch between the source and the release?

  57. milw770 says:

    Ok, I’m not your target demographic. I’m running a newer machine than anyone here is reporting, and I’m getting a very high framerate: 180-190 fps. (Vista 64, Quad Core, 6 GB ram, ATI 4850 video card). It runs really well on higher end machines. Obviously it’s great! Thanks for releasing this.

    My old machine running XP SP3 with Athalon 3200 and 2 GB ram with a NVidia 7600 GT gets about 20 fps, across 2 monitors.

  58. James Block says:

    Looks like I’m the only person who has attempted to compile this with the free VS2008 Express Edition and lived to tell the tale; here’s what I had to do to get it to kind-of work, on what I think is my bog-standard VC++2008 Express installation (no SDKs or extra libraries are installed, as far as I can remember):

    0. Get the source, by hook or by crook. I neither have nor want svn installed on this computer, so grabbing the zip from the GitHub mirror someone provided above was easiest for me.

    1. Import the VC6 project (double-click it, and tell VS2008 you really do want to convert it).

    2. Set SCREENSAVER to 0. Some library complains if it’s set to 1; I haven’t figured out how to fix that yet. The actual error is

    1>scrnsave.lib(scrnsave.obj) : error LNK2019: unresolved external symbol __imp__InitCommonControlsEx@4 referenced in function _WinMainN@16

    I can’t figure out where that one’s coming from, but it doesn’t appear with SCREENSAVER set to 0. Also, Shamus, your “development camera” is truly awful.

    3. Nuke all references to glaux.{h, lib}. There are a bunch in header files and one pragma in Win.cpp. Google tells me this file is obsolete; given that I can remember using it during my own last foray into OpenGL years ago, that’s probably true. The project seems to compile fine without it.

    4. Math.cpp, line 110, fmod call should have an “f” tacked on, to read
    result = (float)fmod (a1 - a2, 360.0f);
    and not confuse the poor compiler.

    Those changes get it to build just fine for me in VC++2008 Express.

  59. slutzinc says:

    Long time reader, first time poster.

    Excellent work, Shamus. I got it running on my 1st gen MacBook via my Parallels Desktop (v4.0) Windows XP. Runs at ~30 FPS in 800×600. Drops down to ~11 FPS when bloom is enabled. Runs normally at 20-25 FPS in 1280×800. (Haven’t tried enabling bloom in this resolution as I fear it will have a massive drop in performance.)

  60. mookers says:

    This is about Twenty Thousand kinds of awesome. Runs pretty well on WinXP on my laptop (Core2 T7200 @2.0GHz, ATI Mobility Radeon X1400). I get on average about 70 fps with bloom turned off (at least I think that’s what setting it is).

    Is there any way to get the source code as a single archive file? I’ve never used any of the tools mentioned for online code sharing.

    1. Shamus says:

      Github is excellent. I’ve joined, but I’m wondering if there is some (automated) way it can pick up the changes I’ve made in Google Code.

  61. Tuck says:

    I was quite surprised to receive a lower framerate in this than I got in Crysis. Oh Shamus, the irony!

    Core Duo 2 2.66ghz
    4GB RAM (or rather 3.25 thanks to XP)
    Win XP Pro SP3
    Nvidia GeForce 8600GT
    Running at 1920 x 1200

    The camera also stuttered every second or so, regardless of which settings I was using.

    Bloom is very weird — it seems to lag behind the scene when the camera’s moving, causing all the glows to appear separate from their lights.

    But…very pretty!

  62. Volatar says:

    With bloom I got 45-50 fps
    with bloom and letterbox mode I got 70-75

    Athlon X2 5600+ (dual 2.8)
    2GB DDR2
    XP Pro x64
    GeForce 8600 GTS
    1280×1024

    This is the best screensaver ever :D

  63. Neko says:

    wxWidgets? nuuuuu

    Use Qt. Qt is awesome. It has everything but the kitchen sink, and makes multiplatform stuff a breeze.

    1. Shamus says:

      Qt subclasses OpenGL. I HATE porting to interfaces like that. Every #@%ing time I want to make an OpenGL call I have to get a pointer to the (whatever) context, and then use that:

      glEnable (GL_BLEND);

      becomes:

      thing=GimmieThatThing ();
      if (thing) {
      thing->glEnable (GL_BLEND);
      }

      Yuck.

      It would add a tremendous amount of work to the porting process, as it would require extensive and all-encompassing changes to every single module. It would also contribute to some unwanted line number bloat.

      Having said that, feel free. If Qt does what you need it to, then I’m sure someone else will appreciate the port as well. I’m not a member of the “There can be only one” school of thought. :)

      1. Shamus says:

        Counter-point: It seems Qt supports screensaver functionality, and wxWidgets doesn’t. Boo.

  64. Ross says:

    I’ve given it a whirl- VERY cool stuff. My only complaint is that the sky is very odd/nonfunctional- there are no stars, and the fog looks pretty bad. Could be just drivers, I suppose.

  65. Ermel says:

    Okay, people may yell at me to go away, but I just tried this on my pathetic little Samsung NC10 netbook, which is my fastest computer by far. After seven minutes of blank screen and 45 minutes of loading screen, I did actually get to see Pixel City. At about 4 fpm (yes, minute!).

    But preeetty!

    Bloom does look weird for me too; couldn’t turn it off because I got no reaction to either F1 or E keys, and soon inadvertently touched the touchpad causing the thing to go off.

    But I could live with the few fpm I’m getting, if it weren’t for the thick end of an hour of loading (or rather, generating) time. So, Shamus or anyone: any way to save all that stuff it’s generating in that time to disk, and loading it again on startup? That’s got to be faster, seeing as my whole WinXP session can be loaded from disk in a couple of seconds.

    Also, I’d like it for there to be a config file where I can turn off bloom and other eye candy permanently and without the need to press keys at runtime, since that doesn’t seem to be working. Or maybe a real screen saver options dialog?

    I know that I’m not the target audience with this pathetic hardware I’ve got, but still, I real<y like this thing and think it looks quite awesome. I don’t know how much work it’d be to make this usable to me, but I’d really appreciate it if someone went to the trouble of doing so, and I think that even those with less pathetic hardware might appreciate the effort.

    Thank you.

    But nevertheless: Shamus, this thing is drop dead beautiful, and if nothing else it has been an intriguing thing to read about. Thanks for sharing!

  66. Silfir says:

    With effects (doesn’t matter which): 31 fps
    Without: 61 fps
    Resolution was 1200×800. I don’t get higher on this laptop.

    I also get a very slight stutter every few milliseconds. Possibly a bottleneck that just won’t show on your hyper-fast machine?

    Machine is an Intel P8600 DualCore (I think), equipped with an Nvidia Geforce 9650M GT with 4 GB RAM in total. Vista 32x. Which is not too bad of a setup, I think.

  67. Shamus: I am following along with git-svn at the moment. This sort of thing could be done with a cron job.

    [… pause …]

    Ok, I just set up a cron job. The GitHub version I put up should sync up every half hour, on the half hour. It seems to be working fine right now.

  68. Gary says:

    On my laptop (XP, Celeron 1.6 Ghz, 1G RAM Radeon9000) I get between 9 and 12 fps before it just dies. It dies at completely random points too. Sometimes in the loading part, sometimes in the city flyby. Sometimes before it even reaches the loading part. But it ALWAYS dies. I’ve not gotten more than 2 minutes out of it.

    It looks gorgeous! But the crashing is inexplicable… I don’t know what the issue is there. The laptop works on games like Quake, and WoW, and guildwars….

    On my desktop (XP, AMD 2.6 Ghz dual core, 2G RAM, Radeon X1650) it took about 30 minutes to load. Once running it hit 1 fps. It would show one image of the city, then about 3 seconds later show a completely different static image of the city. (this is with the bloom disabled)

    Still great stuff though.

    1. Shamus says:

      To anyone else investigating the “stuttering” issue:

      It’s not really stuttering. The FPS remains unchanged. You can see this by setting it to only use the “orbit” camera modes. The camera spins round and round with no lurching.

      No, the real problem is in the flycam_position () code. There is some defect in the way the camera position is being calculated which is only visible at lower FPS.

      EDIT: No. I was wrong. I have no idea what’s causing this. If you want to test it yourself, set the effects mode to EFFECT_DEBUG_OVERBLOOM. That will give you all the slowdown you could wish for. :)

  69. Ermel says:

    Update to my own post at #73.

    Something very weird is going on here. I renamed the .scr file to .exe and invoked it from command line with “pixelcity /S”, and lo and behold, it loads in a couple of seconds and runs at 6..11 fps. Several orders of magnitude faster, in other words, and perfectly acceptable …

    … if it weren’t for two little glitches: 1) buildings in the middle distance have issues with the textures, making it look like different windows are lit from frame to frame, especially when panning; and 2) after an arbitrary time, but at the latest after fading out and rebuilding, the program quits on me.

    Also, the cam seems to repeat the same pattern of travel each time.

    But I’m still quite happy now. Shamus: again, awesome work.

    1. Shamus says:

      Ermel: Thanks!

      I’m not sure what windows is doing differently, but I think that gives me enough info to fix these extreme slowdowns people are reporting.

  70. Brian Ballsun-Stanton says:

    Some fun little magic. To run this screensaver as a desktop background in windows:

    Go to a command prompt and type:
    PixelCity.scr /p65552

    I don’t know why that magic string does what it does, but it seems to work on any arbitrary screensaver. But only that number.

    Oh, and killing it is a pain. You have to either alt-tab to the window (using the mouse is no good) and hit alt-f4. *or* kill it through the task manager.

    Fun!

    In other news, this is a fantastically computationally expensive black screen on my Lenovo X61. (Uber CPU/ram. itty bitty graphics card.)

  71. James Block says:

    Sounds like whatever’s going on involves scrnsave.lib, which does the parsing of command-line flags, and which my research has indicated is broken in VS2008; I wouldn’t be surprised if it’s odd in other VC++ versions. I posted a question to Stack Overflow about it, which I’ve heard is good at solving these sorts of problems. We’ll see what they come up with.

  72. Volatar says:

    Finally got a pic to prove my point.

    Observe LLC on a sign in the release:

    http://img8.imageshack.us/img8/3492/94615386.png

    However, LLC is not contained in the code.

    http://github.com/skeeto/pixelcity/blob/0997f49311b29138ad278dd567ec36b6c0b3d2c8/foo.h

    1. Shamus says:

      Sigh. I explicitly told svn to DELETE foo.h. But no matter what I do, I can’t get rid of it.

      Foo.h was a temp file – I copy & pasted the real code into that file for the purposes of writing post #12. The REAL code is at the top of Texture.cpp.

      Foo.h is a useless temp file, now forever married to the codebase by inscrutable rules.

  73. Jakswa says:

    Reddit led me here. Very interesting stuff! I’m on linux with a 3ghz intel wolfdale and nvidia 8800gt. This runs great and looks sweet for such a tiny download (and a relatively quick slap together, from what I read)!

    I can run your .scr file with wine using the “wine PixelCity.scr /S” (thanks the some guy above for this!).

    However, I want to view FPS info to see what I’m getting, and everytime I move mouse, or press a key (I think F1 displays this info?), the screensaver goes off.

    Anyone in a similar situation?

  74. John Stumpo says:

    Thank you very much for releasing this code. I think I’m going to try to port it to SDL. (I currently work on quite a few SDL/OpenGL projects, including a quite popular free/open-source game, so I have a fair idea as to what I’m doing.)

    I have long been a fan of this blog, but I have never felt strongly enough to comment on one of its posts before.

    I was led here by Reddit, but I would have found this anyway as this blog is one of the sites that I regularly read.

  75. Mike Trpcic says:

    Just informing you that it works perfectly on my Windows Vista Business x86_64 machine.

  76. Rick says:

    Brian Ballsun-Stanton: That’s the window handle for your desktop. From what I remember, screensavers are drawn to elements via their handle, that’s how they can do the preview thing.

  77. B.J. says:

    My specs:
    3.0 ghz core 2 duo
    8800 GTS
    4gb RAM
    Windows Vista

    Runs great, around 100 fps (200 with bloom off)
    The fog effect is a little muddy, and I can’t see the sky shown in earlier screenshots. Was there a change there I missed? I like the camera effects but the street level view is rather low res and looks a bit ugly (which is probably not news to you).

    Still all in all I am quite impressed, very neat little program.

  78. ClearWater says:

    Awesome!

    I get about 70FPS in the default mode. This is on a fairly recent (as in less than a year old) Core(TM)2 Quad CPU but I’m running Vista so who knows. It goes down to 7FPS in some modes. Also what might be contributing is the fact that my screen resolution is 1680×1050. I dunno.

    If I have time I’ll see if I can’t port this to Java with jME. I’ve been looking at that recently but I have no real experience with it or with 3d programming so I’m not making any promises.

  79. mightygoose says:

    hey, i put into windows folder and preview in the desktop properties works fine in the menu window but any fullscreen effort dumps back to desktop at about 70% loading any ideas…

    running athlon AMD TL-52 dual core 1.6Ghz
    1GB ram
    at 1280×800 resolution…

  80. mark says:

    I now have a new screensaver!

    30 FPS on my dual screen 2x1152x864 system. I love it! :D

  81. HeroOfHyla says:

    Working great on my machine!
    ~80 FPS with bloom on,~110 with bloom off. Managed to get it up to 150 by turning everything off.
    Occasionally the FPS dropped to around 60, no matter what settings I had it on.
    1600×1200 resolution.
    Camera movement seems a bit jerky, but very nice over all.

  82. Joe Blow says:

    Very nice. I’m glad it works for multiple monitors; many screen savers don’t.

  83. Bryan says:

    Wait, wait, WHAT?

    > , and of course you must #include windows.h everywhere you use Gl.h, which is just about everywhere.

    WTF?

    What kind of totally BROKEN header *is* this, that it *requires* a Windows-specific header?

    To anyone trying this with a newer environment: is this actually still true? Was it just a horrific breakage around the time of VC6, or is it still broken?

    (<GL/gl.h> should not require a platform-specific include. That’s what <GL/glx.h> is for on Linux (glXCreateContext and friends), and <wingdi.h> is for on Windows (wglMakeContext and friends). If the main gl.h header requires a platform-specific include, then it’s doing the wrong stuff.)

    Anyway, hopefully I can do some porting this weekend…

    1. Shamus says:

      Bryan: My reaction exactly.

      Microsoft issues this OpenGL with their dev environment. Worse, they haven’t updated it in years, so the headers are stuck with OGL 1.1 functionality. Some Google searching can take you to the heart of the problem, which probably rhymes with “Girect X”. For a long time, nobody else was inclined to make a set of LIBs / headers for Windows since “Microsoft already did it.” (Poorly.)

      For example, line 1152 for the Gl.h file:

      WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);

      Both WINGDIAPI and APIENTRY are #defined via Windows.h.

      So, yeah. Bleh.

  84. Viktor says:

    Runs well on my good comp. However, does not display either the framecount or the sky(toggling fog does not help). And, as said above, bloom fails. Far too large blur, coupled with massive slowdown. Running:
    AMD Athlon 64 X2 dual-core processor 3800+
    1 gig ram
    NVidia GEforce 6100
    And unfortunately Vista. :(

    Edit: On my parent’s 2004 first-wave XP(no clue about more than that) 1 FPS, but at least I was able to see the framecounter. ;) Still looked really good, but no speed. Of course, the 75% mem used already might have something to do with that.

  85. FuguTabetai says:

    This project has been immense fun to follow. I even busted out my Windows machine (ThinkPad T60p 3GB RAM, ATI Mobility FireGL V5200 512MB RAM, 2.16 GHz T6200 dual core proc) to test this out. Works great in all modes, but I only get like 7-12 FPS in the default bloom modes. In order, the modes get ~12 FPS, 26, 54, 40, 100 or so.

    Thank you for documenting this fun project in full public view – that can’t be easy! Releasing the code to the community is also really great. I’ve blogged about this blog on my blog at fugutabetai.com (I heard you like blogs in your blog so I put a … oh forget it.)

  86. Bryan says:

    Wait, WTF again?

    glAccum just takes a couple of…

    Oh. I see. I still don’t *like* it, but I see.

    They’re using Windows-specific calling convention specifiers — WINGDIAPI / APIENTRY are used to specify “this function comes from a DLL, so please make the linker do the right thing” (snide comment: decent shared-library formats are able handle this properly already, so the tag for the linker isn’t needed), “this function should use the Pascal calling convention” IIRC (snide comment: it’s much simpler when your OS only *has* one calling convention, which matches C’s), etc.

    That being said, the *RIGHT* way to do this is for GL/gl.h itself to include for you (which will do nothing if the header’s already there), instead of forcing the programmer to do it. That way they can still use their own special defines for all this calling convention stuff that shouldn’t even be required, and it won’t break code that’s trying to be portable.

    Grr.

    *Anyway*, between this, the case-insensitivity of Windows, and the vs. / directory separator, the first bunch of porting changes are all fairly well confined to surface details; I’m most of the way to getting Building.cpp into an object, at least. (Now, whether that links into the executable or not is a different issue…) :-)

    Though I am getting lots of “class X has virtual functions but non-virtual destructor” warnings; generally that’s prone to failure later, if you try to delete a pointer to the base type (it’ll call the wrong destructor). g++ warns if you do this, even if you don’t ever delete a pointer to the base type. (Later edit: Oh, I see. There is no destructor. Declaring an empty inline one that’s virtual in CEntity fixes it.)

    I’m also getting this:

    Building.cpp: In member function ‘void CBuilding::CreateModern()’:
    Building.cpp:746: error: name lookup of ‘i’ changed for new ISO ‘for’ scoping
    Building.cpp:741: error: using obsolete binding at ‘i’

    ISO C++ scoping rules prevent re-use of the “i” from the previous loop. To get this to work, I’ll need to either re-declare it (add another “int”), or, if your compiler barfs on that, move the “int i” out to function scope.

    I ought to figure out where on the github site this purported forum functionality is. Maybe I have to sign up?

  87. Bryan says:

    Tried to add this to the previous post, but it just timed out:

    Re: the non-virtual destructor, it looks like there is no destructor for CEntity (or many of the derived classes), so it’s enough to just add an empty inline virtual destructor in Entity.h: a fairly simple change. :-)

    (I really need to just fork the repository and start submitting these changes to the fork…)

  88. Jack says:

    Hi Shamus,

    This is very awesome, just saw the YouTube video. You ask if this stuff is any use. I know that at my university in Switzerland a start-up was recently founded in the procedural city generation scene, they are pretty successful.

    See here: http://www.procedural.com/

    Best of luck to you. Keep up the great work.
    Jack

    PS: Repeating this comment, not sure if you’ll see it where I had posted it first.

  89. froogger says:

    Fantastic stuff! Dripping with awesome, thanks for sharing. Runs at about 14 fps on my office-approved laptop, 60 without bloom. And I do like the extras :)

    Oh, btw, I did get the company: “ePetroleum”, huzzah!

  90. vdgmprgrmr says:

    Suggestion: Clock-towers. Some cities would have a big biilboard with a digital clock display, others would have a giant stereotypical clock tower. And the clocks should synchronize with the computer clock.

    That would just be awesome, and it would allow people to watch the pretties and still be able to tell the time.

  91. Ian says:

    I ran it up on mine and after watching teh ever growing cheese I was treated to a veiw of the city in the middle of the night during a power cut.

    I’m guessing it’s the three monitor dual graphics cards breaking it.

  92. davidad says:

    Hey, I can verify that this works under Wine 1.0.1 under Ubuntu 9.04. 7 FPS at 1680×1080, but that goes up to 70 FPS without bloom lighting. I also see the fog texture overlap weirdness, and the bloom lighting lag issue (where the extra light comes from is updated less frequently than the camera position).

    Otherwise, looks amazing!

  93. Melf_Himself says:

    Another data point on your beta test:

    60 fps @ 1680 x 1050 on:

    3.16 GHz Dual core
    3.25 GB RAM (due to 32 bit OS with 2 x 2 GB sticks)
    GTX 260 GPU

    I seem to be getting less FPS than some others have noted (not subjectively noted, just with the fps counter enabled). Could be either due to win XP or I’m using a higher resolution than they?

    Shrug.

    Great job.

  94. Melf_Himself says:

    Ooh ooh, just saw the comment about clock towers. Seconded :)

  95. Charmless says:

    Hi Shamus,

    I’m halfway through porting this to Mac OS X (just some font and effect weirdness left to fix), and it looks like others are doing similar ports.

    Do you have a plan for gathering these ports/changes? At the very least, it requires separating all the OS/window-system specific stuff out from the actual working code.

    I’ve tried to change the original files as little as possible, but I can’t check what’s changed since I (foolishly) decided to try git – which doesn’t (by default) handle the differences between windows and unix newlines. So as far as git is concerned, I’ve frobbed every line in the project.

    Anyhoo, it’s not worth my time to fix that unless there’s interest in gathering updated sources together eventually. Let us know.

  96. Patrik says:

    Works on Windows 7. The sky box seems to be missing though.

  97. Tom H. says:

    Memory leak?

    I left it running overnight as the screensaver, came in to work this morning to find a half-gig RAM image and a Visual Studio debugger prompt.

  98. scope.creep says:

    I grabbed it last night, and I’m having the same/similar problems as reported in #55 above — no textures. I can see the blinkenlights, cars, and streetlights, but the buildings are black boxes discernable only when they occlude light sources. There was no sky. Pressing F1 showed no text. Pressing E (because the article specifically mentioned it) made the lights do some interesting things, but didn’t affect any of the rest of it.

    I’m running a homegrown box with an AMD dual-core something-or-other, XP Pro, GeForce9800 GT, plenty of memory, and dual monitors (and UltraMon to help with window management).

    Thanks for an awesome read, though.

  99. Blue Painted says:

    I’m getting 9/10fps but that’s running it by double-click so it might get different priority when running as a screen-saver.

    Presumably you’re using a PRNG? In which case you could “save” the whole city by saving the seed? That would be a fun thing to play with :-)

  100. Dean W says:

    This is not the bottleneck you’re looking for:
    Pentium Core Duo Quad, 2.8Ghz, 4GB RAM, Vista, GeForce 9400GT driving TWO 1680×1050 monitors; 35-40fps.

    Laptop- Celeron 1.6Ghz XPsp3, 512MB, whatever crappy on board video it came with- laptop goes into sleep mode before the display comes up. Takes about 10 minutes to get to the 50% mark.

  101. Rob says:

    I had trouble with the building textures not appearing when I ran it on an extended desktop over two monitors, but after disabling one of the screens, it ran with the building textures appearing just fine. Still no sky-box, but pretty slick looking. Very impressive work and results from such a small program.

  102. Abnaxis says:

    Alright, I am substantially confused now. My computer is old (4-5 years, with upgrades in there), and yet I cannot get this screensaver to run at less than 60FPS, even with my resolution maxed and bloom on.

    I’m wondering though–perhaps since so much of the work is done by the CPU, and not the graphics card, perhaps the bottleneck is in the CPU bus? When I bought this computer, I was planning on it lasting a very long time and therefore spent a king’s ransom on the motherboard and populated it with cheap components. Perhaps implementing vertex buffers would greatly enhance the performance issues, even more than Shamus led us to believe?

  103. Leonardo Herrera says:

    Wheee! Pretty! with code!

    Runs ~7 fps – Dell laptop, 2GHz, 2 GB ram, NVidia Quadro NVS 110M; jumps to 20+ fps with bloom turned off.

  104. Factoid says:

    Any chance of a new build for those of us without the correct compilers?

  105. Ben says:

    I already commented with my results on a slow computer, but I’ve now had a chance to try things out on my good computer, and I have a strange issue that nobody else has reported:

    When I run with dual monitors activated, I get cars and streetlights, and nothing else – all the textures are invisible, and I get roughly 30 FPS. If I deactivate my second monitor, it runs at 61 FPS (vsync) and everything works correctly.

    This is on Windows XP with an e6550 and 9600gt. It’s plenty fast, but for some reason it doesn’t like my dual monitor setup.

  106. moswald says:

    I almost love it, but it currently does not work 100% correctly on my machine. See this image. That weird poly with what looks like the streetlights texture gets in the way of the camera a LOT, to the point where that’s mostly all you see.

  107. NakedSnake says:

    This is awesome! I’ve been looking for a good screensaver to put on my new rig, and this runs perfectly in Windows 7 Beta 7068. 60+ fps. I’ve got an e7400, HD 4670 513mb, 2gb of ram, for those who care to know.

  108. Joe says:

    Shamus, thank you VERY much for sharing both the process and the result with us all. I’m not a coder or a graphics person so seeing behind the scenes is a treat I seldom get.

    It runs very well on my machine but unless you really want to know, I won’t bother you with the specs.

    My personal notes and opinions:
    1) when bloom is turned on, the close-up bloom is too much. The distance bloom is much better. Then again, I’ve never really like bloom and normally turn it off if I can.
    2) There is a mode where the buildings become transparent and the windows stay. But as the camera pans around the windows run horizontally around the building shapes. Sort of a horizontal Matrix effect. Cool.
    3) Personally I prefer the fog effect turned off. I can’t see the sky, but I can see further into the distance of the city.

    Again, Shamus thanks for sharing. I read daily but have never posted before. Keep up the great work.

  109. Zel says:

    Compiling the project on Windows with Visual Studio 2005 required some little tweaks : one variable could be used without initialization (addon), one or two undeclared ‘i’ in ‘for’ loops (made them ‘short’), and an added link to comctl32.lib to solve James Block’s error (comment #64). I guess your environment parameters already link to it by default.

    It runs quite good on my laptop (Core Duo 1.6Ghz, 2Go Ram Radeon X1400), bloom is very expensive though and I can’t get the framerate counter to show up.

    EDIT : nevermind about the counter, I’ve figured out I needed to disable the help messages.

    Also : setting SCREENSAVER to 0 doesn’t generate anything other than the background. The dev camera works but isn’t very handy with a touchpad. And I’ve yet to find how you’re supposed to move forward/backward.

    1. Shamus says:

      Zel: Dev camera moves with the right mouse button, which is probably a useless interface if you’re using a touchpad. There are a couple of functions in Camera.cpp that can be used to move the camera around, and it might be worth simply binding those to keyboard inputs.

  110. vdgmprgrmr says:

    Yes, I believe there’s some sort of memory leak.

    It came on last night for about three hours (three hours of sleep… tired), and it took a good couple minutes for my computer to exit, I had to ctr-alt-del it, and it showed some insane amount of memory usage. Then just now, after school for about eight hours, I come back and it’s just outright crashed.

    1. Shamus says:

      Yes. Memory leak was reported and fixed yesterday. My bad. Check the updates on Google code – there are two small changes that should fix the problem. I’ll be releasing a new executable once I get a few of these other problems sorted. The no sky and black city issues are baffling me right now.

  111. Anachronist says:

    It takes less than 4 seconds to load here; I think that’s even quicker than .kkrieger.

    The screensaver looks gorgeous on my computer here at work, a dual-core 3 GHz Intel E8500, with an NVIDIA Quadro FX 3700 graphics card and two 1280×1024 monitors. I think it’s on the performance edge; the animation is mostly smooth but has moments where it gets slow and jittery.

    I never bothered with screensavers before (preferring just to let the power settings turn off the monitor) but I’m keeping this one. It would be nice if the screensaver had adjustable settings, but that’s just a quibble. Thanks.

    -Alex

  112. vdgmprgrmr says:

    Business name “Petroleum Unlimited” appears one character too big for the billboards. At least, for the one I just saw anyway. “Petroleum Unlimite” just doesn’t seem right.

  113. Kirin says:

    I’m a big fan of the screensaver. The whole city looks much nicer when its in motion, you were right! This might replace even polarclock.

  114. Rick says:

    I like your quirky notes for the number of comments, but hadn’t seen “27” before… it’s cute :)

  115. SatansBestBuddy says:

    Pretty cool.

    Maybe for the settings tab you could add options like how long it takes before a new city is built, how many cars there are, how far/close the fog goes, what kind of sky to use, how fast the camera goes, how high the buildings can be, and so on and so forth.

    Also, the fact that you can so much as admit that your program isn’t flawless shows that your hubris is far from boundless.

  116. Rick says:

    Err… I meant 2 to the power of 7… oops.

    I’m looking forward to the next binary release, I tried compiling myself but get a bunch of errors when compiling as a screensaver. Am looking forward to the slower camera :)

  117. ringrose says:

    At work, on my old dual monitor box, it only uses the left monitor and the background textures for the sky look like someone took a texture and blew it up until each texture pixel was about a tenth of the screen (I didn’t try turning off the various special effects, but I will later). At home, on a more recent machine, it works quite well until it has generated a few cities. Then something overflows and I get flashing junk onscreen.

    Not a terribly useful bug report; once you release the next version I’ll see if you’ve fixed it.

  118. Brandon says:

    I’m using an ancient machine (think 2003 or 2004). Barely 1GB of DDR RAM across three sticks, I don’t even want to know what my processor is like, and the best thing in here is a 512mb AGP graphics card. But the screensaver runs relatively smoothly, provided I have absolutely nothing else running on my computer. With about four other applications open I average 15-20fps and managed to get up to 50fps when the camera swooped low and followed a street

    Well done! =D

  119. vdgmprgrmr says:

    Hehe… “Data Mfg.”

    It seems so realistic!

  120. Jachra says:

    Very pretty.

    Say, now, a few more ‘steps’ that would be pretty solid…
    A) Districts and neighborhoods. Cities are as much defined by these as anything, and they can make a huge difference in look and feel.
    B) Topography. Can be a huge determinant. Look at some cities in Brazil, or San Francisco.
    C) Artificial limits that mimic city architectural codes.
    D) Option for rivers/bays/coast. Goes under topography?
    E) Landmarks. Parks, museums, massive art-like architecture, government buildings, so on.

    Also, you might wanna bone up the classical style a bit. It doesn’t look quite right.

  121. RichardB says:

    Had to remove the lovely screensaver. It was causing my machine to draw so much power that my UPS started beeping, and everyone in the office complained. :-(

  122. Gunner says:

    Hey Shamus. Long time reader, first time commenter. Anyway, just wanted to thank you for this awesome screensaver and the fascinating write-up of the process.

  123. Jon says:

    Shamus. This is simply awesome. Frankly, I’m more excited about this screen saver than any game that has come down the pike in a fortnight.

    Ideas for you programmers out there:
    Moon (w/correct phase).
    Clock tower.
    Bats to fly around the clocktower and annoy the undead zombies.

  124. DaddyHoggy says:

    Shamus – fantastic work.

    I’m a shiny new Lecturer at a university (before that I was a *real* rocket scientist) – I teach on a modelling and simulation Masters degree course and I’m going to recommend your blog and your app to my students – brilliant.

    Well done.

  125. Gabe says:

    Works Perfect on these specs :

    MS Vista Ultimate 64
    3.0 dual core Athlon
    4gig ram
    Asus ATi4870
    1.4tb HDD

    This will definitly replace ks_Matrix screensaver that Ive been using for so long.
    Thanks

  126. Volatile says:

    The Spelling & Grammar Police Strikes Back-
    (subst/”Spelling & Grammar Police”/”Empire”)

    Paragraph after Download: “program as performed an illegal operation and needs to close” … as should be has.
    SOURCE: “migrating from my platform to your is likely much easier” … your should be yours.
    PORTING: “those items will probably form your to-to list if you” … to-to should be to-do. Also, I’m not sure about a word earlier in the paragraph either: contex could be a mispelling of context, or it could be a word I’m unfamiliar with, because the stuff you’re talking about in relation to porting is not an area of expertise for myself.

  127. Graham says:

    Crashed after a very long time (I wasn’t in the office for 2 days, and came back to this crash)

    Instruction 0x690cf11a referenced memory at location 0x00000000. The memory could not be written.

    WinXP, 2x 1680à—1050 monitors, driven by Radeon x1550, Intel Core2 6600 @ 2.40 GHz, 2GB RAM.

    Any other info you need?

    Oh and a request.. could we get a cfg file or remember which effects settings were last used?

    Great work.

  128. Excellent series of posts explaining every step of the project.

    Thanks for sharing. :)

  129. james says:

    My dual monitor Core2Duo PC gives me a wonderful black screen with random red dots on it.

    If I turn the wireframe mode on I get a wonderful city that runs at around 30fps which is evidently enough to fool my brain. I sat and watched it in the dark for a few minutes wondering where my joypad was and where the things to shoot at had gone to :)

    Oh, it gets 64FPS inside the screensaver preview window and the textures sort of work… ish.

  130. doug m says:

    what library files do i need to compile the source code? i’m using a work computer so i don’t have things like GLEW or SDL on this machine.

    i’ve created a new empty project in dev c++ and when i compile i get the following error
    “…Car.cpp:23:22: gl\glaux.h: No such file or directory”

  131. Patrick says:

    Runs at about 19fps via CrossOver Games under OSX. Stuff the .scr into ~/Library/Application Support/CrossOver Games/Bottles/[whichever bottle]/drive_c/windows/ and use Programs->Run Command… to find it, and tack a /S after the quoted path that ends up in the Command field. I have my cxGames set to use a virtual 1024×768 desktop, so I don’t know if it would work without a root window to draw in or not.

  132. slagg says:

    Runs at a constant 60fps @ 1280×1024. Loads in a few seconds.
    Win7 RC1 x64
    Athlon 64 X2 3800+ 2GHz
    2GB DDR
    Geforce 8800 Ultra

  133. Zorink says:

    Awesome! I’m getting 60-61 fps, very fast startup, and about 1-3 second builds on a 1680×1050 running an NVIDIA GeForce 8600M GT. The rainbow gradient and scrolling alpha look really cool – I could totally see them as a menu screen beackground for a game.

  134. Questioner says:

    i know im going to osund like a idiot now, but… what Windows folder.. can you be more precise??

  135. Questioner says:

    No matter, i found out… and now i feel even more like an idiot :)

  136. CTrees says:

    I’m late to the party, of course, but anyway!

    On my computer (2yo gaming computer), it loads almost instantaneously (fractions of a second), but then the framerate REFUSES to move from 60fps, regardless of effects, resolution, or anything else. Force disabling VSync via drivers moves it to 64fps, which it also won’t budge from. Now obviously this is perfectly fine, but it’s just strange that it picks those numbers and sticks with them.

    Awesome stuff, though!

  137. ender says:

    I can’t get the screensaver to work on my desktop – just displays a blank screen. Not sure if this is because I have 30″+24″ monitors on a 9600GT, or because of something else. Works on my laptop though (12FPS with bloom, 30 without), which is RadeOn X1400 Mobile and Intel T7200 CPU (this was on battery though, it’d probably work faster on mains). I also tried it on my Alix board (500MHz AMD Geode, 256MB RAM with 8MB shared graphics), and it worked at about 9SPF letterboxed without bloom :)

  138. Uri says:

    Thanks a lot for sharing all the design process and your code! It’s been a very nice read.

    Cheers,

  139. Freakyk says:

    Found the project though digg. Must say it really makes one hell of a screen saver heh.

  140. josh says:

    I’m kind of an idiot, but can you actually build your own pixel city and fly around in it with this program?
    or is it something else? I was thinking about downloading it, but I don’t know what it does.

  141. Brutos says:

    While trying to compile the latest version on git on vs 2008, I get an exception in Texture.cpp line 594.
    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, _size, _size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

    =>
    Unhandled exception at 0x697f5fa7 in PixelCity.exe: 0xC0000005: Access violation reading location 0x00000000.

    I have no opengl experience at all and not much c++ experience either. I suspect that NULL got passed instead of a GLVoid*. but I don’t really have an idea.

  142. Drew Noakes says:

    Really enjoyed this series, Shamus.

    Unfortunately the app didn’t work on the multi-monitor setup I tried it on: Win XP SP2. Pentium D 3GHz (Hyperthreaded). 4GB RAM. Matrox QID LP PCIe.

  143. Michael says:

    Hi, really interesting article and I thought I would have a stab at compiling this with VC++ 2008.

    However, I keep getting an “Expression: vector subscript out of range” error everytime I try to run it (it compiles fine btw). Does anybody get this? I cannot find for the life of me where this error is occuring. I see James got it working with VC++ 2008 Express, so I’m not sure what I’m doing wrong.

    Again, nice project and I look forward to seeing your future work!

  144. russm says:

    well I’ve not read all the comments, but searching the pages for “bresenham” gets no results so I’m guessing this is a new suggestion.

    in part 9 you talk about all the fp math and trig required to cull polys outside the visible area. surely something nice and simple like bresenham’s algorithm would let you cull on a finer grid using only integer add/subtract and bitshift.

  145. Sheff says:

    I can’t get it to compile on VS2005.

    bombs with …

    Unhandled exception at 0x69836694 in PixelCity.exe: 0xC0000005: Access violation reading location 0x00000000.

    at …

    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, _size, _size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

    in Texture.cpp

    anyone got any ideas / fixed this?

  146. Paul says:

    Thanks for sharing Shamus…it was awesome to see in action :)

    It worked beautifully on my machine without any issues or problems at all…and it had only maybe 5 seconds? delay at the beginning when building the city!

    I had on average 30 FPS, but it sometimes went as high as 50, and as low as 16, but was usually around 30.

    You can find my system specs below. PS. my system is over 6 years old and still kicking LOL

    Computer
    ——–
    AMD Anthon(tm) 64 Processor 3000+ (1081 MHz)
    1.00 GB RAM
    Physical Address Extension.
    Microsoft XP SP2

    Graphics
    ——–
    nVidia GeForce 6600
    256 MB RAM
    AGP 8X

    I have now installed it as my screenshaver ;)

    cheers

  147. Heron says:

    Thanks, Shamus, you’ve given me this unquenchable desire to do something just as cool, but unique. How am I going to satisfy that? :(

    *Ahem*. I ran it on two computers. On my work-issued laptop (Core 2 Duo 2.0GHz, 2GB RAM, Intel GMA 945, 1440×900), it took around 15 seconds to load; I got maybe 1/3 of a frame per second. I can’t say I expected more. It looked fantastic, though.

    On my personal desktop, I ran it through Wine on Gentoo Linux (Core i7 920, 12GB RAM, GeForce GTX 285, 1920×1080). It loaded in under 2 seconds, and runs quite smoothly, but it didn’t really look as nice… I’d guess my monitor’s resolution is too high, and the clouds don’t work very well for some reason. Maybe it’s wine. (I’ve got two monitors, but running it with “wine PixelCity.scr /S” only used one monitor.)

    Just more data points :)

    I’ll probably get bored in the next week or so, and port it to run natively in Linux. I’ll post another comment here if I do.

  148. Madster says:

    Found this through google, looking for random generation of cities. Loved the hard work explaining how you arrived to this, I’m sure I’ll find it useful someday.

    As people have commented: there are ways to avoid sending geometry each frame and they are avaiable on most hardware.

    Also, for bloom: do not render the scene twice!
    Render to a screen-sized buffer, then downsample that, then blur that, then render the original to the framebuffer with the blurred version on top.

    Last and least lame suggestion, for the street “issue”

    1-sprite for headlight-lit pavement, paralell to pavement
    2-sprite for backlight-lit pavement, paralell to pavement
    3-sprite for dark car outline, front or rear facing (same)
    4-sprite for dark car outline, side facing
    5-sprite for dark car outline, top view
    6-headlight and backlight sprites should fade when not facing the camera
    7-bonus: fix light fallof rate in streetlight texture!
    this will make the cars and street look very decent :D

    congrats, this is my screensaver now, first one since good old Skyrocket, its city was a flat plane :P

  149. echoback says:

    tl;dr all comments, but it runs at 8-20 FPS on my Acer Aspire One ZG5 (1GB RAM) through Wine on Ubuntu 9.10 (Karmic). No missing textures, but I do get the occasional artifact where it looks like two faces have overlapped and keep drawing over each other.

    Excellent work.

  150. phantomcranefly says:

    Just downloaded this (finally- I had to wait to get my shiny college laptop, and then I was so busy I forgot about it until recently) and it’s lovely. I don’t really have anything constructive to add, but this is definitely going to be my permanent screensaver. I really enjoyed reading about how you made it, too.

    Edit: Aww, my little face looks sad. Or sick. Still cute, though.

  151. Okay, the program worked fine last night, but today I get at most a second of city (and often just a split second of blackness or the loading clock) and then it goes back to my desktop. Anyone else having this problem?

    Edit: I’m on Windows XP, using the file from Google Code.

  152. Anon says:

    Runs flawlessly on my 8800gt, that said it would be nice if you could increase the draw distance and have the camera at double or triple it’s current height.

  153. Harry says:

    Unbelievable!!! Superb…

  154. Max says:

    Certainly a bit late, but I have just tested the program on my laptop and I got 62 fps all the time (exactly the refresh time of my monitor – 62 Hz). So I’d say OpenGL/Direct X runs with VSync on as a default chez moi.

    My specs shouldn’t be the problem:
    Core2Duo 2.3 GHZ
    Geforce 8800M GTX
    4 GB RAM

    Seems like the screensaver-mode does automatically activate VSync…

  155. nocturnal YL says:

    At 3072*1152 (Two monitors, 2048*1152 and 1024*768, tiled horizontally) this screensaver goes very laggy. And I don’t think my video card is that bad.

    Radeon HD 3650 with 512MB of memory; computer itself is an Athlon64 5200+ with 2GB of DDR2 RAM

  156. Arzar says:

    Shamus, you should check out the winner of the 64k Assembly 2010 party : “X Marks The Spot”

    http://pouet.net/prod.php?which=55546

    There is a very nice procedural skyscraper city right there.

  157. Mike says:

    Well, on my system (Core2Duo 2.6 GHz, 4 GB RAM, GeForce 9800 GTX, Win7) it clocks at roughly 60 fps (varies from 60 to 64).

  158. Kogut says:

    Really great thing!

  159. Draco18s says:

    I don’t know if you’ve seen or read Introversion’s attempts at procedurally generated cities. Parts 3 6, and 7 focus a lot on figuring out roads and building plots.

    As their project will plans on making a game where the player runs around on street level a lot, they didn’t want to use a strict grid for their roads, as well as allow for other areas of randomness.

  160. Anon says:

    I feel like I’m stepping into a ghost town here…
    But on my PC it generates the same city each time, Which I can see from the building names.
    I get ~70 fps though, and it looks pretty nice.

    Windows 7
    Intel Core 2 Quad
    Nvidia graphics (Can’t recall which.)

  161. Tim Callahan says:

    Screensaver runs great on my older desktop — Core 2 duo with GeForce 7100 — but hangs, just frame shots every five seconds or so, on my laptop (Core i7) and media center box (Core i3), both of which have the Intel HD graphics, which must be the problem. Has anyone run into the same issue? Thanks.

  162. someone says:

    Still great in 2012.

  163. David Nash says:

    Thanks for sharing the source, I thought the article was very interesting, I found the site from the youtube video.

    I always intended to make a procedural city however I always ran into the problem of how to accurately get the work done with minimal effort. I think your progress was amazing for 50 hours work, the hard stuff like building generation and city street lights is very interesting to read about.

    I have some ideas about how to progress from this point. 1) perhaps making the grid for the city streets more irregular, filling in some squares (tiles?) that would be roads otherwise. 2) road materials, these could be procedural textures with simple white lines bordering the edges and dashed white lines in the center, then the texture could be rotated depending on the direction of the road, also the center where roads intersect could be procedural too. 3) the street lamps and other repeated objects could use “instancing”, a technique that has been around in graphics cards for almost 10 years now, for displaying lots of objects of the same data type in a shader. 4) I’m sure that some of the randomization effects on the buildings could be computed on the GPU, however I am not sure exactly how.

  164. ChristopherWebster says:

    While I know this is four years late, I just wanted to say that I just downloaded the screensaver and it’s the coolest/most fun thing I’ve seen for some time. It’s even cooler when spread across dual monitors.

  165. sofawall says:

    Since I know Shamus still reads these comments on nearly 4 year old posts, I don’t feel silly posting.

    This screensaver still runs fine 4 years on, on my Windows 7 machine. Only oddity is despite having many, many times the power of the poor peasants in the land of 2009, I’m still stuck at 65 FPS. No changing of settings will go higher or lower, so something is locking it there.

  166. John Galt says:

    Pixel City is one of the most awesome screen savers I have ever seen. But it has stopped working on Mac OSX 10.8.5.

    Please, is there any chance you would consider updating???

  167. WJS says:

    Well, that’s somewhat disappointing. Seeing people reporting getting up to 200 fps, I thought I’d try it and see what a gaming system from today could do to it. But it won’t render above 61-65 for me. I’m not sure what the deal is, since I’m pretty sure that I’m more powerful than pretty much anything that you could get in 2009, however even forcing Vsync off in my graphics card settings, it won’t go higher. Very annoying. (Also, the low-res window textures are really obvious on a 32″ screen)

  168. Mr. Wolf says:

    Of all the parts of this that would stop working, I didn’t expect it to be the skybox.

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply

Your email address will not be published.