There are not a lot of books on portable code, but Write Portable Code: An Introduction to Developing Software for Multiple Platforms by Brian Hook does a good job handling many of the topics.
There are a number of rules for portability:
- Never assume anything (memory, size of built in types (int, float etc.)).
- The code will likely have to have non-portable elements to run efficiently.
- Establish a reasonable baseline of platforms, (not both PS3 and Commodore 64).
- Never read or write structures from memory or cast raw bytes to a structure.
- Always convert to or from a canonical format when moving data in or out of memory.
- Develop good habits and use tools and platforms that cooperate to strong practices.
- Avoid new langages or library features.
- Integrate testing.
- Use compile time assertions and strict compilations (avoid excessive conditional compilations).
- Write straightforward code.
- Understand anything can change between compilers (floating point can work different).
- Leverage portable third party libraries, but be careful.
- Performance and resource usage must be as portable as your features.
- Portability also means supportin other cultures, regions and languages.
- Consider using a language more suited to the task (python, C#, etc. are easier than C++).
- Systems are becoming more secure (folders, ports etc.).
Brian Hook also has a POSH (Portable Open Source Harness) at http://hookatooka.com/poshlib/ that demonstrates some examples of portability and a good stepping stone for those looking at porting C++.
I think the book was useful it demonstrates a number of source code examples for his Simple Audio Library (SAL). Brian Hook also goes through a number of examples of the different standards including the IEEE 754, C8 and C99 standards, which are interesting to look at from a portability focus, and it would great if more books looked at the standards in their work.
Bye for now,
Michael Hubbard
http://michaelhubbard.ca
Sunday, August 28, 2011
Thursday, August 18, 2011
Indie multi-platform game development
Often indie developers get caught up in following the "big boys" and trying to do as they do. With a large company, there is a lot of focus on releasing on multiple platforms, in multiple languages, on their first release, and to create a big splash. My advice is: don't do it.
Focus on one platform, make the best possible game and go from there. If you are using a third party engine that already does that for you fine, but if you have to pay extra licenses, and do a lot of extra development, you could very well be wasting your time. If you do not make enough money on your (first) target platform to support moving your game onto another platform, your game will not likely be a success anyway.
Look at Angry Birds and Plants vs Zombies, two of the most successful smart phone games of all time. Both originally only coming out for limited platforms first (just iOS for Angry Birds, PC/Mac for PvZ). Neither of these companies tackled all the platforms that they are now running on, and are likely only ported to those platforms because of the success of the original.
It is worthwhile to focus on trying to write customizable code, and wrapper classes and functions for things that you know will could be or will be swapped out. Obvious things include the graphics API wrapper classes are essential if you need to support both OpenGL and DirectX or some other graphics API. It is also worth having a default functionality for things that could be a problem (like if a platform does not support pixel shading or a limited number of textures on the gpu, make sure your game does not rely on this too heavily).
If you really want your code to be portable, port early and port often. In a larger team I have seen it work where different developers run different operating systems and graphics cards in an attempt to guarantee that most of the functionality will work with a daily build. It is often easier to catch issues as they crop up, then to hunt for hours, days or weeks for all the differences that is not making it run on the other platforms. This introduces other workflow issues, and will sometimes require those developers that broke the build to access to other machines so they can fix it. This does help guarantee that the code written is more portable, and if it works for two very different architecture chance are more likely it will run on those inbetween. The problem for indie developers is they do not usually have this luxury of multiple machines, dedicated developers and perhaps this time.
If you believe that the market has shifted and you really should be focused on another device or platform, that is different, but chances are, your first assumptions about developing for that platform or device were well founded. If your game was not a real success on your ideal device or platform, chances are not very good you will see a huge difference in success if you spend the time to port to the other platforms. This can be frustrating, but instead, focus on improving your original game first, or making your next game even better. If you want to take a lesson from the console developers, consider this: if your game is really that good, people may even buy the platform to run it :P.
Best of luck,
Michael Hubbard
http://michaelhubbard.ca
Focus on one platform, make the best possible game and go from there. If you are using a third party engine that already does that for you fine, but if you have to pay extra licenses, and do a lot of extra development, you could very well be wasting your time. If you do not make enough money on your (first) target platform to support moving your game onto another platform, your game will not likely be a success anyway.
Look at Angry Birds and Plants vs Zombies, two of the most successful smart phone games of all time. Both originally only coming out for limited platforms first (just iOS for Angry Birds, PC/Mac for PvZ). Neither of these companies tackled all the platforms that they are now running on, and are likely only ported to those platforms because of the success of the original.
It is worthwhile to focus on trying to write customizable code, and wrapper classes and functions for things that you know will could be or will be swapped out. Obvious things include the graphics API wrapper classes are essential if you need to support both OpenGL and DirectX or some other graphics API. It is also worth having a default functionality for things that could be a problem (like if a platform does not support pixel shading or a limited number of textures on the gpu, make sure your game does not rely on this too heavily).
If you really want your code to be portable, port early and port often. In a larger team I have seen it work where different developers run different operating systems and graphics cards in an attempt to guarantee that most of the functionality will work with a daily build. It is often easier to catch issues as they crop up, then to hunt for hours, days or weeks for all the differences that is not making it run on the other platforms. This introduces other workflow issues, and will sometimes require those developers that broke the build to access to other machines so they can fix it. This does help guarantee that the code written is more portable, and if it works for two very different architecture chance are more likely it will run on those inbetween. The problem for indie developers is they do not usually have this luxury of multiple machines, dedicated developers and perhaps this time.
If you believe that the market has shifted and you really should be focused on another device or platform, that is different, but chances are, your first assumptions about developing for that platform or device were well founded. If your game was not a real success on your ideal device or platform, chances are not very good you will see a huge difference in success if you spend the time to port to the other platforms. This can be frustrating, but instead, focus on improving your original game first, or making your next game even better. If you want to take a lesson from the console developers, consider this: if your game is really that good, people may even buy the platform to run it :P.
Best of luck,
Michael Hubbard
http://michaelhubbard.ca
Thursday, August 11, 2011
Siggraph 2011 Part 3
It is over! I thought I would add some closing thoughts.
I managed to check out the Blender display (back in the far corner) and they had some cool stuff going, but could not help thinking that the Autodesk slogan "Don't blend in, stand out" may have some additional marketing subtext. I like Blender, and with their latest updates they are the best open source 3D modeling package out there, and while they are a few steps behind all Maya can offer, free is hard to beat when you are selling something. It was just a though, I still prefer Maya and really like Autodesk in general, but it was just a curious thought that passed my mind.
Otherwise, I think that Siggraph is a great pool of knowledge, but next time I go, I think I will try and spend the majority of my time in the talks, rather than the exhibition and galleries. I learned quite a bit, but I wouldn't say my mind was blown or anything like that. I felt like the exhibition and gallery were focused more on beginner to intermediate information, which is great when showing off a new technology, feature or process, but there is only so much detail you can go into in those kinds of demonstrations before you start losing people. The more formal presentations would likely not be as interested in attracting a crowd as exploring the depth of the ideas, and this, I think, would be very appealing.
Overall, I am very happy to have attended, and saw some neat things, learned some new technologies, and generally made me excited to work in this industry.
Can't really ask for more than that,
Michael Hubbard
http://michaelhubbard.ca
I managed to check out the Blender display (back in the far corner) and they had some cool stuff going, but could not help thinking that the Autodesk slogan "Don't blend in, stand out" may have some additional marketing subtext. I like Blender, and with their latest updates they are the best open source 3D modeling package out there, and while they are a few steps behind all Maya can offer, free is hard to beat when you are selling something. It was just a though, I still prefer Maya and really like Autodesk in general, but it was just a curious thought that passed my mind.
Otherwise, I think that Siggraph is a great pool of knowledge, but next time I go, I think I will try and spend the majority of my time in the talks, rather than the exhibition and galleries. I learned quite a bit, but I wouldn't say my mind was blown or anything like that. I felt like the exhibition and gallery were focused more on beginner to intermediate information, which is great when showing off a new technology, feature or process, but there is only so much detail you can go into in those kinds of demonstrations before you start losing people. The more formal presentations would likely not be as interested in attracting a crowd as exploring the depth of the ideas, and this, I think, would be very appealing.
Overall, I am very happy to have attended, and saw some neat things, learned some new technologies, and generally made me excited to work in this industry.
Can't really ask for more than that,
Michael Hubbard
http://michaelhubbard.ca
Wednesday, August 10, 2011
Siggraph 2011 Vancouver Part 2
So, I went to the exhibition and some of the galleries and ballrooms today. Losts of neat stuff. If I was to sum it all up, it would be Motion Capture, 3D printers, Autodesk, Maya and NVIDIA. Those seemed to be the major players, although not surprising since they are also some of the more expensive technologies, so would do well to advertise.
Some of the talks I went to include:
World Creation in CryEngine: I am awaiting for the release of the free version of CryEngine 3 SDK which will likely be this month (I checked and no mention of it on their webpage yet). The demo was ok, a bit simplistic in talking about the interface, but looks impressive nevertheless.
Photoshop 3D texture map integration: This was interesting talking about how 3D height maps can be created (and tested in 3D) in Adobe Photoshop CS 5.5. an intersting talk, with some good examples and neat features I will have to try out.
Real World Camera Rig Creation: The focus of this talk was to improve the use of a camera in Maya. This was a little different, the basic concepts here was to try and build a crane, dolly or curve path rig and attach a camera to it, to mimic real life cameras. By setting up and constraining the camera in this way, it allowed for more traditional movements alongside the free flowing camera that is so easy to misuse in a 3D animation or game.
Zbrush: Creation of Venom and Carnage from Spiderman. This was just very impressive to see how talented the artists were in creating these characters from a simple head (sculpted and painted in less than an hour) and with amazing results. Just seeing how some of the artists work give ideas for how to improve your own workflow, but really nothing but lots of practice can get you to that skill level.
Adobe Premiere Pro Integration: Shows how Premiere Pro can integrate with After Effects and Encore by sharing the same project information can allow all the programs to interact and update in sequence automatically. This will allow things like a project to be open in After Effects and have an effect added to it (like rain or snow) which will automatically update the same project in Premiere so it can be viewed and editted as necessary. This encourages experimentation, and allows for quick results to be seen immediately.
ILM Transformers 3 Colossus: The stats on the Colossus Transformers (the giant worm robot) in Transformers 3 were very impressive. Over 16 million polygons, 13 separate pieces and was the equivalent to 2 and a half Devestators (from the previous movie). It took a machine with 12 cores and 48 gigs of RAM over 40 minutes to load the shot where Colossus is tearing apart the building, which has multiple layers of complexity and physics (with skin based building model) to get the shot of the building falling over.
Nvidia Parallel NSight: http://developer.nvidia.com/nvidia-parallel-nsight is a very impressive tool integration for Visual Studio, that breaks apart the scene into different draw calls and gives a lot of previously difficult information about the rendering process back to the developer. A tool that allows a developer to select a pixel onscreen and not only track it, but see what draw calls have gone into its creation is amazing. I will definitely be spending some time further investigating this tool, and since it is free, I recommend everyone interested in 3D graphics programming to check it out, it looks like it will be a new favorite to many developers.
Siggraph Dailies: This was a one-minute segment of many different studios, backgrounds and styles. It was nice to see only a brief but intersting clip and a short (sometimes only a few sentences) of the challenges in getting that shot, techniques used, or ideas behind the shot. Ovearll, there are (as expected) a lot of cheats that go into a shot to get the desired effect. One interesting technique used in Tangled (from Disney) was running simulations on the hair in reverse than running the frames backward.
Lots of fun, the exhibition was pretty neat, the art was interesting, the technology was cool and I learned some neat stuff.
Hope you also made it there,
Michael Hubbard
http://michaelhubbard.ca
http://www.3dtotal.com/siggraph_diaries/exhibitor_golaem.html
Some of the talks I went to include:
World Creation in CryEngine: I am awaiting for the release of the free version of CryEngine 3 SDK which will likely be this month (I checked and no mention of it on their webpage yet). The demo was ok, a bit simplistic in talking about the interface, but looks impressive nevertheless.
Photoshop 3D texture map integration: This was interesting talking about how 3D height maps can be created (and tested in 3D) in Adobe Photoshop CS 5.5. an intersting talk, with some good examples and neat features I will have to try out.
Real World Camera Rig Creation: The focus of this talk was to improve the use of a camera in Maya. This was a little different, the basic concepts here was to try and build a crane, dolly or curve path rig and attach a camera to it, to mimic real life cameras. By setting up and constraining the camera in this way, it allowed for more traditional movements alongside the free flowing camera that is so easy to misuse in a 3D animation or game.
Zbrush: Creation of Venom and Carnage from Spiderman. This was just very impressive to see how talented the artists were in creating these characters from a simple head (sculpted and painted in less than an hour) and with amazing results. Just seeing how some of the artists work give ideas for how to improve your own workflow, but really nothing but lots of practice can get you to that skill level.
Adobe Premiere Pro Integration: Shows how Premiere Pro can integrate with After Effects and Encore by sharing the same project information can allow all the programs to interact and update in sequence automatically. This will allow things like a project to be open in After Effects and have an effect added to it (like rain or snow) which will automatically update the same project in Premiere so it can be viewed and editted as necessary. This encourages experimentation, and allows for quick results to be seen immediately.
ILM Transformers 3 Colossus: The stats on the Colossus Transformers (the giant worm robot) in Transformers 3 were very impressive. Over 16 million polygons, 13 separate pieces and was the equivalent to 2 and a half Devestators (from the previous movie). It took a machine with 12 cores and 48 gigs of RAM over 40 minutes to load the shot where Colossus is tearing apart the building, which has multiple layers of complexity and physics (with skin based building model) to get the shot of the building falling over.
Nvidia Parallel NSight: http://developer.nvidia.com/nvidia-parallel-nsight is a very impressive tool integration for Visual Studio, that breaks apart the scene into different draw calls and gives a lot of previously difficult information about the rendering process back to the developer. A tool that allows a developer to select a pixel onscreen and not only track it, but see what draw calls have gone into its creation is amazing. I will definitely be spending some time further investigating this tool, and since it is free, I recommend everyone interested in 3D graphics programming to check it out, it looks like it will be a new favorite to many developers.
Siggraph Dailies: This was a one-minute segment of many different studios, backgrounds and styles. It was nice to see only a brief but intersting clip and a short (sometimes only a few sentences) of the challenges in getting that shot, techniques used, or ideas behind the shot. Ovearll, there are (as expected) a lot of cheats that go into a shot to get the desired effect. One interesting technique used in Tangled (from Disney) was running simulations on the hair in reverse than running the frames backward.
Lots of fun, the exhibition was pretty neat, the art was interesting, the technology was cool and I learned some neat stuff.
Hope you also made it there,
Michael Hubbard
http://michaelhubbard.ca
http://www.3dtotal.com/siggraph_diaries/exhibitor_golaem.html
Monday, August 8, 2011
Siggraph 2011 Vancouver
Siggraph is in Vancouver. It is pretty neat to be hosting the 3D animation festival, and there are lots of people excited to go. Some of the Animation Film Festival is today.
Some of the standouts include:
Le Royaume: http://www.youtube.com/watch?v=y6ZmMjMdrqs
Coca Cola Siege: http://www.youtube.com/watch?v=Shvwd7VYpE0
Spots vs Stripes: http://www.youtube.com/user/spotsvstripes#p/search/0/Zh-s3auYdKo
Dreamgiver: http://tycarter.blogspot.com/
Hezarfen: http://www.youtube.com/user/Supinfocomgroup#p/a/u/2/5YzT_RdBUvs
Kia Soul this or that: http://www.youtube.com/watch?v=jWJ4jHZwUPo
Meet Buck: http://www.youtube.com/watch?v=9vt4fBtxWYY
New Digs: http://martinsenart.blogspot.com/
Rubika: http://blog.autourdeminuit.com/distribution/rubika/
There were of course the big boys, Transformers 3 is amazing visually, I watched it twice in theaters (once in 2D, once in 3D) because it was just so visually impressive, and of course some of the games, movies and animations that are more mainstream (or are part of movies) are awesome too. Check out the animation festival list here: http://www.siggraph.org/s2011/for_attendees/computer-animation-festival for all the details.
Cheers,
Michael Hubbard
http://michaelhubbard.ca
Some of the standouts include:
Le Royaume: http://www.youtube.com/watch?v=y6ZmMjMdrqs
Coca Cola Siege: http://www.youtube.com/watch?v=Shvwd7VYpE0
Spots vs Stripes: http://www.youtube.com/user/spotsvstripes#p/search/0/Zh-s3auYdKo
Dreamgiver: http://tycarter.blogspot.com/
Hezarfen: http://www.youtube.com/user/Supinfocomgroup#p/a/u/2/5YzT_RdBUvs
Kia Soul this or that: http://www.youtube.com/watch?v=jWJ4jHZwUPo
Meet Buck: http://www.youtube.com/watch?v=9vt4fBtxWYY
New Digs: http://martinsenart.blogspot.com/
Rubika: http://blog.autourdeminuit.com/distribution/rubika/
There were of course the big boys, Transformers 3 is amazing visually, I watched it twice in theaters (once in 2D, once in 3D) because it was just so visually impressive, and of course some of the games, movies and animations that are more mainstream (or are part of movies) are awesome too. Check out the animation festival list here: http://www.siggraph.org/s2011/for_attendees/computer-animation-festival for all the details.
Cheers,
Michael Hubbard
http://michaelhubbard.ca
Tuesday, August 2, 2011
Book Review: Godel, Escher, Bach: An Eternal Golden Braid
Godel, Escher, Bach: An Eternal Golden Braid by Douglas Hofstadter, is not really a programming book, but is a worthwhile book for those interested in math, logic, intelligence, patterns and recursion. The book is one worthy of reflecting on, and is thick with examples and clever insights, thought provoking questions and enough content and puzzles to make it worthy of a re-read later in life.
The book is broken up by dialogues between chapters, of conversations between the Tortoise and Achilles (a homage to the philosopher Zeno) , in which the Tortoise is usually teaching Achilles some paradox or life lesson, and allows the reader to both enjoy the wit and wordplay that goes on between the characters, and also learn the lesson alongside Achilles. There are other characters introduced as the chapters go on, each one bringing something new, or introducing a new topic or idea (just wait for the Crab).
Those who get stuck on the title, the book is not about a comparison of math, art and music, but rather examines the strange loops, patterns and paradoxes that exist in the universe. You may have heard of one of the most famous quotes when estimating deadlines, "Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law". The self-referencing nature, and recursive elements play a large theme of the book, and lead towards one of the main themes of the book, that of consciousness and self-awareness, existing from complex neurological mechanisms. The idea of some form of complexity built upon different forms of complexity, suggests the building blocks of conciousness stem from the underlying mechanics.
The main example of the theme of consciousnessis is Hofstadter's example of the ant hill. The ants themselves exist as individuals but are also part of a much larger network, were each individual ant becomes part of a larger collective "consciousness". The ant hill as a whole is able to adapt to conditions in ways that an individual ant could not, and allows for better survival of the entire group. The ant hill, in essence is a consciousness made up of a collection of other consciousness, in some ways similar to the human brain is made up of neurons which have simpler functionality than the brain as a whole.
Do not let the book size be too daunting, I think those who start reading the first couple chapters will likely want to see it through, it will take some time, as the book is large and thick with examples and thought provoking content, if you don't think you will like it now, come back to it in ten years and try it than.
Recursion is a wonderful thing,
Michael Hubbard
http://michaelhubbard.ca
The book is broken up by dialogues between chapters, of conversations between the Tortoise and Achilles (a homage to the philosopher Zeno) , in which the Tortoise is usually teaching Achilles some paradox or life lesson, and allows the reader to both enjoy the wit and wordplay that goes on between the characters, and also learn the lesson alongside Achilles. There are other characters introduced as the chapters go on, each one bringing something new, or introducing a new topic or idea (just wait for the Crab).
Those who get stuck on the title, the book is not about a comparison of math, art and music, but rather examines the strange loops, patterns and paradoxes that exist in the universe. You may have heard of one of the most famous quotes when estimating deadlines, "Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law". The self-referencing nature, and recursive elements play a large theme of the book, and lead towards one of the main themes of the book, that of consciousness and self-awareness, existing from complex neurological mechanisms. The idea of some form of complexity built upon different forms of complexity, suggests the building blocks of conciousness stem from the underlying mechanics.
The main example of the theme of consciousnessis is Hofstadter's example of the ant hill. The ants themselves exist as individuals but are also part of a much larger network, were each individual ant becomes part of a larger collective "consciousness". The ant hill as a whole is able to adapt to conditions in ways that an individual ant could not, and allows for better survival of the entire group. The ant hill, in essence is a consciousness made up of a collection of other consciousness, in some ways similar to the human brain is made up of neurons which have simpler functionality than the brain as a whole.
Do not let the book size be too daunting, I think those who start reading the first couple chapters will likely want to see it through, it will take some time, as the book is large and thick with examples and thought provoking content, if you don't think you will like it now, come back to it in ten years and try it than.
Recursion is a wonderful thing,
Michael Hubbard
http://michaelhubbard.ca
Subscribe to:
Posts (Atom)