A coworker of mine was complaining the other day that Visual Studio’s autocomplete defaults to using backslashes in #include paths–this is pretty annoying if you’re doing cross-platform development since most platforms only allows forward slashes.
Thankfully, you can fix this!–but the setting is a bit buried. In Visual Studio 2017, from Tools->Options:
Alternately, if (like me), you never use autocomplete for include paths, you can use the setting just above that to disable it.
I recently switched from a home-built desktop PC to a laptop with an external GPU enclosure, and was surprised to discover that bytopia immediately crashed on startup on this system.
It turns out the NVIDIA driver isn’t always too smart about choosing which GPU to assign to a particular app, and was giving me the integrated Intel chip, which lacked the OpenGL 4.5 features that I’m using.1
You can of course solve this locally in the NVIDIA driver settings by forcing it to use the high-performance GPU, but I’d rather not have to ask every user to figure that out. So, after some google searching (resulting in a few false starts), I found this NVIDIA technical note, which explains the very hacky process by which you can force your app to use the high-performance GPU:
I don’t have an AMD card handy so I couldn’t test the AMD version, but I can verify the NVIDIA version worked for me, with one caveat: it doesn’t work with a debugger attached.3 So I still ended up having to force the GPU choice in the driver settings locally, but at least when I distribute the game it will work for other people.
1 I will likely support earlier OpenGL versions eventually, although the performance of the Intel chips I’d need it for is so poor I’m not sure it’s worth the effort–and using direct state access does make the rendering layer easier to read… 2 Via this thread on AMD’s community forums. I don’t have an AMD graphics card to test this with, though, so I’m taking their word for it. 3 Presumably the driver has to inspect the executable to see if it exports the NvOptimusEnablement variable, and having the debugger attached prevents that somehow. (Full disclosure: I don’t know much about how debuggers work. 😛 )
If you’ve worked on a nontrivial game in C++, you’ve probably run into a situation where you’d like to step through some code in the debugger, but the debug build of your game is painfully slow and debugging in release mode is difficult and time-consuming.
Here’s something you probably know (but if you don’t, it will change your life): you can disable optimization selectively per file, and thus have access to good debug information while not crippling your performance by running in debug mode.
In the Microsoft compiler, you do it this way:
#pragma optimize("", off)
This will turn off all optimization in whatever source file you put it in. (The optimize pragma has some options to make the changes more granular, but I’ve never really had a need for that.)
There is, however, a subtle problem here: it is very easy to forget to remove that one innocuous line after adding it–and end up, in the worst case, shipping your game with optimization turned off for some files.1 It would be nice if the compiler would let us know if we forgot to remove this pragma, right?
What I do is create a no_opt.h header and include it in any files I’d like to be able to step through:
#pragma message("no_opt.h included in " __FILE__)
#error no_opt.h included in release final build; remove.
#pragma optimize("", off)
Replace _RELEASE_FINAL with whatever your “final” build configuration you release to end users–i.e. the configuration that’s build by your build system.2
With that, the compiler will spit out a message for every file that has optimizations disabled. Further, if you don’t notice the message, it will fail to compile on your final build, giving you a second chance to remove the header.
(I’ve only really done this in Microsoft’s compiler personally, but clang and gcc appear to have similar pragmas available, so it should be easy to extend this to them.)
1. If you’re thinking to yourself that you’re not that forgetful and have always remembered to remove it, I’m sorry to report that you’ve almost definitely shipped code with optimizations disabled. 2. This practice may sound strange if you’re not familiar with it, but at least in game development it’s not unusual to have a “release” build and a “final release” build, where the former will enable optimizations and the latter might go further by turning off developer tools, removing symbols, etc.
Over the last couple years I’ve been impulsively filming a lot of little things I find interesting, but then never doing anything with the footage. So I’ve started a Youtube channel that will be just those pretty little instants: videos mostly less than a minute long, sometimes silent, sometimes with natural audio, sometimes with my own soundtrack added.
I’m not sure how long I’ll keep this up, but I do have a huge archive of this stuff to draw from, so I can probably keep it going for a while even if I don’t film anything new.
Feel free to subscribe, especially if you’re into shallow focus and brevity…
I’ve felt three of them in my lifetime. First, the 2011 Virginia earthquake: I had just returned from a summer in Korea and was staying with my family in the Maryland suburbs. My grandmother and I were the only ones home when the ground started shaking; it felt just like a passing train, so I didn’t really take note of it at first, until I remembered that there weren’t actually any train tracks nearby. I stumbled down the hall and asked my grandmother (in Croatian)–“is this an earthquake?” She nodded, not the least bit concerned–she’d been through many quakes in her long life and knew when to worry.
And then, last year, I was in Hiroshima on vacation when the 2016 Kyushu Earthquakes struck, waking me up two nights in a row in my hotel: first the largest foreshock, and then the 7.0 main quake, which to my inexperienced self felt massive (much bigger than the Virginia quake), but which still was weak enough where I was, more than a hundred miles away, to not do any damage.
(Nearer the epicenter, it was a different story, of course–damage in the Kumamoto area was fairly extensive, but Hiroshima was as close as I got.)
A few days later, I saw a solitary, elderly European tourist at Haneda Airport, carrying a gift bag from Kumamoto Castle. He must have had an unexpectedly interesting vacation.
The entire experience rendered the rest of my trip–stops in Yokohama and then Taipei–a little surreal; all the lost sleep left me in a near-fugue state. I need to get back to Taipei some day, in a better state of mind: I hardly remember what I did for my three days there.
I don’t have any particular motive for writing about this now, to be honest. I just couldn’t sleep last night, and the occasional rumble of passing trucks brought back memories.
Just thought I’d share this desktop background I made. It started life as a long-exposure photo of the light sculpture in front of the Shaw Library here in DC. Some color manipulation, various blurs, grain, and dust/scratches led to this slightly worn, faded-looking rainbow (click for full size, 3440×1440).
My grandmother passed away yesterday, peacefully in her sleep. She spent the last few days of her life surrounded by her family and friends. A doctor once told her she’d never live past age 45; she lived to 88.
She saw a lot in those 88 years. She grew up on a barge on the Danube–born, by her own account, at a Romani village by the shore because her parents couldn’t make it to a hospital. As a young woman, fearless, she took up skydiving at a time when it was a brand new idea. She survived the horrors of the second world war, worked with the Yugoslav Partisans, and shared her first kiss with a Jewish stowaway her family smuggled to safety. Her beloved older brother fought with the Partisans, and survived the war only to be shot by his best friend in a dispute over a girl.
When her daughter married an American diplomat and moved to the United States, she and her son followed not long after; they were a tight-knit little family and couldn’t bear to be apart. With her lack of English she had trouble finding work here, so instead she helped raise me and my sister. I always told my friends she was more like a third parent to me than a grandparent.
Of all the people in my family, she was the one who always understood me the best–and the amazing thing is that every single one of us can probably say that. She was not only a grandparent to me, but also often a surrogate grandparent to my friends; she was endlessly generous with her patience, her kindness, and her (usually mischievous) sense of humor.
She was always trying to convince me to be healthier (while, in true Slavic grandmother style, also offering me enormous amounts of food at every opportunity). The next-to-last thing she said to me, lying on her deathbed, was: “You’re so beautiful. I love you so much. Have you lost weight?” She repeated it about ten times.
In the last few years, as her health declined, I’d often sit by her bedside showing her the latest pictures from space, and telling her about stars and exoplanets and black holes and distant galaxes. She never had much interest in science fiction, but was utterly fascinated by science fact. The very last time she spoke to me, she asked me–struggling to get each word out–whether their were any new pictures from Ceres. Curious to the very end.
Yesterday, the Supreme Court ruling came down making same-sex marriage the law of the land. My mother and uncle joyously told her. We don’t know if she heard, but if she did it would have made her incredibly happy. Just a couple hours later, she passed, according to my mother with a “not bad” expression on her face. She was wearing my rainbow bracelet from Pride.
She adamantly didn’t believe in God, but she often said she believed in reincarnation–although she always said so with such a mischievous twinkle in her eye that I’m still not sure whether she was just messing with me or not. If there’s a heaven, I’m sure she’s there now; if reincarnation is real, I’m sure she’s being born again as something totally amazing as we speak. Regardless, she lives on with all of us.
She was the best person I’ve ever known. Let’s all try to be a little better in her memory: a little kinder, a little braver, a little more generous and patient.
This passage from Kyung-sook Shin’s novel I’ll Be Right There has got me reflecting on my own life today; I’ve had these thoughts so many times over the past few years. (This paragraph is from near the end of the book, although it doesn’t really spoil anything, in case you care about that sort of thing.)
“I’ll never forget what I saw that day. I think that’s why I never married. The memory has faded, but it never goes away. That’s why I am not going to tell you two to get over the things you have gone through. You should think about them and think about them and think about them some more. Think about them until you can’t think anymore. Don’t stop questioning the unjust and puzzling. Maybe if I had gotten there by the date written in her letter, I could have saved her. But then again, maybe her death was already planned, and all she wanted was for me to find her. Human beings are imperfect. We are complicated, indefinable by any wise saying or moral. The guilt, wondering what I’d done wrong, will follow me my whole life like my own shadow. The more you love someone, the stronger that feeling is. But if we cannot despair over the things we’ve lost, then what does it all mean?”
(Adding to the odd feelings, I and the person this reminded me of had both read Shin’s other novel available in English translation–Please Look After Mom, also wonderful–shortly before her passing.)
Over the past year or so I’ve done several game jams and really enjoyed it; I’ve based each of the games on a simple set of C++ library code I’ve been working on. I’ve kept intending to switch to Unity, but it never ends up happening; truth be told, although I can get a lot more done with Unity, I just have a lot more fun working in plain C++ with my own systems, and each accomplishment just feels so much more earned when I’ve done it more or less from scratch.
To that end, I’ve been working a bit on improving the framework code (‘engine’ is far too generous a word) that I’ve been using for the jams and for other hobby projects, including the GPU Game of Life and Pacman parody projects I’ve posted here, as well as all of my Ludum Dare and Indie Speedrun entries so far.
I’ll post about my progress here occasionally as I work on it. It’s not likely to be hugely interesting–more just a chance to get some thoughts down as I’m working on it. This first post is a summary of what I’ve got so far. Be ye fairly warned: much boring nerdery lies ahead–
My guiding principle in working on this has been to make it as simple and pleasurable as possible for me to write small-to-medium-sized projects; much of what I’ve done has been focused on that goal. There are a lot of things I’ve done that are tremendously inefficient. Some of them I intend to optimize, but others I’ll likely leave as-is for maximum flexibility. After all, the projects I’m creating with this aren’t going to be tremendously complex. Performance is a minimal concern, while ease of development is crucial.
A few of the more notable features:
A resource loader front end inspired by XNA’s that’s designed to make it as easy as possible to load resources. The implementation is internally clunky, but the interface makes loading resources into a handle (including reference counting, avoiding duplicate loads, support for resource load parameters like shader macros, etc.) as simple as this:
auto example_tex = resource::load<texture*>( "textures/example.dds", optional_parameter_blob );
Basic 3D support, including a model loader built on top of the Open Asset Import Library, and a basic forward renderer with ambient, point, and directional lights (currently using Mikkelsen’s Torrance-Sparrow implementation).
A fast sprite renderer, using texture arrays and structured buffer instancing to blast potentially thousands of sprites onto a frame at high framerates. It’s in the early stages and is missing a lot of functionality, but it’s already really fast. (I know I mentioned I don’t care much about performance, but this is a situation where I thought being able to draw truly extreme numbers of sprites at once could be interesting for a jam. Plus, it was just fun to write.)
A basic input wrapper to make reading single keystrokes, held buttons, and mouse movement easy.
A math library wrapping DirectXMath (the XM* functions) in easy-to-use classes (with operating overloading where natural).
A lof of the above still needs some work, and there are some major features on the todo list:
Gamepad support using XInput.
An input mapping system to map raw keyboard/mouse/gamepad input to in-game actions more naturally.
A tiled deferred renderer (ported from another hobby project I did in 2012).
Eventually, hopefully integration with Box2D for 2D physics and PhysX for 3D physics.
Screen space effect chain (at least HDR/tonemapping/bloom, motion blur, depth-of-field, color grading).
Some kind of basic animation support–at least rigid-body animation to start.
My mercurial repository for the engine code is public: http://bitbucket.org/otresnjak/eph-engine. I’ll continue to update it as I add new features. It’s missing the front-end code you need to actually compile/run; I’ll make that repo public as well once it’s a little prettier.