All blog entries, ordered from most recent. Entry count: 1198.
# Syntax of C++ Templates - Comparison
Wed
16
Sep 2015
I noticed recently how C++ syntax differs when you define a class template, template instantiation, specialization or partial specialization. Here is an example:
// Template class definition.
template<typename T>
class Class1
{
public:
void Print() { printf("Class1 template\n"); }
};
// Template class instantiation.
template
class Class1<int>;
// Template class specialization.
template<>
class Class1<double>
{
public:
void Print() { printf("Class1 specialization for double\n"); }
};
// Template class partial specialization.
template<typename T>
class Class1<T*>
{
public:
void Print() { printf("Class1 partial specialization for pointers\n"); }
};
Having these classes defined, following code fragment:
Class1<int> objInt;
objInt.Print();
Class1<double> objDouble;
objDouble.Print();
Class1<int*> objPointer;
objPointer.Print();
Produces following output:
Class1 template
Class1 specialization for double
Class1 partial specialization for pointers
Here is how the syntax can be compared:

# Unicode w Visual C++ - My Old Article
Tue
15
Sep 2015
I just noticed that my old article "Unicode w Visual C++" (in Polish) was a dead link and restored it back online:
It may not be "politically correct" if you believe in what they say in UTF-8 Everywhere manifesto, but I think the information that I have put there are still relevant and useful despite being 7 years old.
Comments | #c++ #visual studio Share
# Music Visualizations - Plans for the Future
Mon
14
Sep 2015
Last weekend I was showing my music visualizations on two parties. First one was in a club, projected on flat screen, while the second one was an open-air party (my 7th and last one in this summer season :) with the image projected on trees. For this one I had to prepare something different - simple, contrast shapes and single color only, so it could be clearly visible. Here is a small video:
It doesn't look like this because I wanted it exactly this way or because that was my "artistic vision", but just because showing some rotating images downloaded from the Internet and blending transformed feedback from previous frame was the easiest way to start with something interestingly looking.
Now I have tons of ideas to improve this program as soon as I find some free time. Next to some small technical tasks like refactoring code or simply adding new graphical effects, I plan following big TODO-s (with no particular order decided yet):
Comments | #events #music #psytrance #vj Share
# Adventures with Porting Code to Visual Studio 2015 and No DirectX SDK
Sat
08
Aug 2015
I just installed new Visual Studio 2015 Community Edition and ported my personal project to it. At the same time, I uninstalled old DirectX SDK Jun 2010 and started using new DirectX headers bundled with Windows SDK, which is installed together with Visual Studio. These two transitions are not connected - I could already switch to new DX headers years ago, but I decided to do it now. While transition to VS 2015 was smooth, abandoning DirectX SDK caused some problems, because new DirectX doesn't contain D3DX library. Here is a dump of the problems and solutions that I encountered during this effort:
1. I uninstalled DirectX SDK Jun 2010, Visual Studio 2013 Community Edition and all other components that seemed related to it, like Microsoft SQL. I left all "Microsoft Visual C++ XX Redistributable" though, because these are required by many applications and intended to be installed on target machine, not necessarily as a part of development environment.
Next, I downloaded and installed new Visual Studio 2015 Community Edition. During this long process, I was thinking what should I expect from the new IDE... Whether Microsoft did a good job this time? On one hand, it is suprising that C++ is now an optional installation component, so it seems like native code is in shadow comparing to all these new and trendy cloud/web/mobile/managed technologies. On the other hand, table: C++11/14/17 Features In VS 2015 RTM shows that the new C++ compiler caught up with many features of new C++11/14/17 language, which gives hope that authors still treat native code development seriously.
2. The looks of new IDE is so similar to the previous version it is hard to notice any differences. After launching it, I had to first recompile static libraries that my project depends on. That was zlib 1.2.8 and my CommonLib. Converting project to new version, as well as the build itself went smoothly, without any problems - which is unusual with C/C++ libraries :) Just as in previous version, headers and libs of standard C library, standard C++ library (STL) and WinAPI are already bundled with the Visual Studio, so there is no need to install or configure anything additional before you can use them.
Comments | #visual studio #directx #c++ Share
# How to check size of structure during development in Visual C++?
Wed
08
Jul 2015
Today I wanted to know what is sizeof(SomeStructure) during my coding in C++ in Visual Studio, without compiling and running my program. I needed that to put it into an assertion. Sure I could run the program and then break into debugger and evaluate the sizeof(SomeStructure) e.g. in Watches window, but the project is big and takes long time to build.
It turns out there is no such feature in Visual Studio to check size of structure, but it can be easily hacked using IntelliSense. In just few seconds, from this Google query, through its first result - this StackOverflow page, I have found following solution:
1. Put this line somewhere into your code:
template<size_t S> class Sizer { }; Sizer<sizeof(MY_STRUCTURE)> foo;
2. Replace "MY_STRUCTURE" with the name of your structure, other type or a variable.
3. Hover mouse cursor over "foo" and observe evaluated expression, for example: "Sizer<1296U> foo". 1296 is the size of your structure, in bytes - same as operator sizeof would return in runtime, when your program is compiled in currently selected configuration. "U" is for "unsigned".
By the way, maybe it would be a good feature request to add printing size of a type to the information available in design-time in Visual Studio, e.g. to Properties window, where there already are information about the type like IsTemplate, IsValue etc.?
Comments | #c++ #visual studio Share
# DeepDream aka Inceptionism - Graphical Effect from Neural Networks
Fri
03
Jul 2015
Convolutional neural networks are artificial intelligence algorithms used in image recognition. Two weeks ago engineers from Google showed how it can be used to generate or modify images in a novel style. They called it "inceptionism". Since then lots of people and websites posted about it.
I would like to play around with this technology myself, but I don't have much knowledge about artificial intelligence algorithms and I don't have much free time right now, so at least I hope to follow developments in this new graphics technique and update this list of related links.
Update 2015-07-06:
I came back after the weekend and I can see that the algorithm keeps spreading across the Internet like crazy. After Google shared their code on Github, people start using it. It is not easy though. It is a Python code and has many dependencies. Some libraries must be installed. So even if using it does not require in-depth knowledge about programming or neural networks, this is not just an application that we could download and launch.
I've spent today evening trying to set this up on my Windows, but I didn't succeed. I can see that people on reddit try to run this code as they discuss in Deepdream for non-programmers thread. It seems that at the moment noone found a simple solution to do it on Windows.
Someone managed to set it up as a web service at psychic-vr-lab.com/deepdream, but uploading images is no longer available. I guess the server was overloaded.
Some videos started appearing on YouTube - #deepdream.
It seems that "Deep Deam" with become the official name for this effect. Other candidate names were "Inceptionism" (proposed by Google engineers in their original blog post) and "Large Scale Deep Neural Net" (proposed by the studends form Ghent University, probably because of its acronym ;)
I'd like to be able to experiment with this algorithm to teach it recognizing (and generating) some other patterns. So far it usually just draws dog faces. I can imagine it would look cool if it draws some plants, leaves etc. or some abstract, geometrical patterns, like fractals.
Update 2015-07-07:
reddit.com/r/deepdream/ is the ultimate go-to page to stay up-to-date with the subject. See especially the first, pinned post for an introductory FAQ and a collection of important links.
Ryan Kennedy prepared a self-contained, virtual environment to run this software using Docker, but it's still not that easy to set it up.
Update 2015-07-09:
I finally managed to run the program, thanks to the Newbie Guide for Windows, based on VirtualBox and Vagrant. Still not without problems though.
Understanding Neural Networks Through Deep Visualization - an article offering nice overview of this algorithm.
Update 2015-07-14:
The pinned post on /r/deepdream lists more and more online services that offer processing of images into this specific style, full of dogs :) There is even a successful Indiegogo campaign to setup such server - DreamDeeply.
Its "Tips & Tools" section also links to some description and illustration of specific layers, as well as deepdreamer - a tool for configuring the dreaming script.
DeepDream Group has been created on Facebook and it is very active.
I think that the ultimate solution would be to create a standalone application or a Photoshop/GIMP plugin that would apply this effect to images, but it seems that speeding up these calculations to anything less than minutes or training own neural network with something else than dogs won't be easy. Here is some discussion on the latter.
Comments | #rendering #google #ai Share
# Lower-Level Graphics API - What Does It Mean?
Sat
06
Jun 2015
They say that the new, upcoming generation of graphics API-s (like DirectX 12 and Vulkan) will be lower-level, closer to the GPU. You may wonder what does it exactly mean or what is the purpose of it? Let me explain that with a picture that I have made few months ago and already shown on my two presentations.

Row 1: Back in the early days of computer graphics (like on Atari, Commodore 64), there were only applications (green rectangle), communicating directly with graphics hardware (e.g. by setting hardware registers).
Row 2: Hardware and software became more complicated. Operating systems started to separate applications from direct access to hardware. To make applications working on variety of devices available on the market, some standards had to be defined. Device drivers appeared as a separate layer (red rectangle).
Graphics API (Application Programming Interface), like every interface, is just the means of communication - standardized, documented definition of functions and other stuff that is used on the application's side and implemented by the driver. Driver translates these calls to commands specific to particular hardware.
Row 3: As games became more complex, it was no longer convenient to call graphics API directly from game logic code. Another layer appeared, called game engine (yellow rectangle). It is essentially a comprehensive library that provides some higher-level objects (like an entity, asset, material, camera, light) and implements them (in its graphical part) using lower-level commands of graphics API (like mesh, texture, shader).
Row 4: This is where we are now. Games, as well as game engines constantly become more complex and expensive to make. Less and less game development studios make their own engine technology, more prefer to use existing, universal engines (like Unity, Unreal Engine) and just focus on gameplay. These engines recently became available for free and on very attractive licenses, so this trend affects both AAA, as well as indie and amateur game developers.
Graphics drivers became incredibly complex programs as well. You may not see it directly, but just take a look at the size of their installers. They are not games - they don't contain tons of graphics and music assets. So guess what is inside? That is a lot of code! They have to implement all API-s (DirectX 9, 10, 11, OpenGL). In addition to that, these API-s have to backward compatible and not necessarily reflect how modern GPU-s work, so additional logic needed for that can introduce some performance overhead or contain some bugs.
Row 5: The future, with new generation of graphics API-s. Note that the sum width of the bars is not smaller than in the previous row. (Maybe it should be a bit smaller - see comment below.) That is because according to the concept of accidental complexity and essential complexity from famous book No Silver Bullet, stuff that is really necessary has to be done somewhere anyway. So lower-level API means just that driver could be smaller and simpler, while upper layers will have more responsibility of manually managing stuff instead of automatic facilities provided by the driver (for example, there is no more DISCARD or NOOVERWRITE flag when mapping a resource in DirectX 12). It also means API is again closer to the actual hardware. Thanks to all that, the usage of GPU can be optimized better by knowing all higher-level details about specific application on the engine level.
Question is: Will that make graphics programming more difficult? Yes, it will, but these days it will affect mostly a small group of programmers working directly on game engines or just passionate about this stuff (like myself) and not the rest of game developers. Similarly, there may be a concern about potential fragmentation. Time will show which API-s will be more successful than the others, but in case none of them will become standard across all platforms (Vulkan is a good candidate) and GPU/OS vendors succeed in convincing developers to use their platform-specific ones, it will also complicate life only for these engine developers. Successful games have to be multiplatform anyway and modern game engines do good job in hiding many of differences between platforms, so they can do the same with graphics.
Comments | #gpu #rendering #directx Share
# DirectX 12: What We Already Know?
Wed
03
Jun 2015
I am very excited about the upcoming DirectX 12. I have always been standing on the side of PC, Windows and DirectX. Currently I code in DirectX 11 on Windows 7 at home. Upcoming Windows 10 with free upgrade from version 7 and 8 (and the Start menu back on its place) looks like a good system. Together with it, a new version of DirectX will be released. Let us summarize general information about this new graphics API that are publicly available at the moment.
Here are some interesting links:
First and foremost: Direct3D 12 Graphics @ msdn.microsoft.com. Microsoft says "these information relate to pre-released product and may be substantially modified before it's commercially released", but you can already find there all Direct3D 12 Programming Guide and Reference, so basically the whole API is already public and you can start learning it.
Social Media:
General information:
Slides and videos from conferences:
Videos and screenshots from some working applications already shown: