<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Freya.no &#187; c++</title>
	<atom:link href="http://wp.freya.no/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://wp.freya.no</link>
	<description>Knowledge is power</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:56:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building Boost 1.47.0 with Visual Studio</title>
		<link>http://wp.freya.no/2011/09/building-boost-1-47-0-with-visual-studio/</link>
		<comments>http://wp.freya.no/2011/09/building-boost-1-47-0-with-visual-studio/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 09:55:21 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=1085</guid>
		<description><![CDATA[Extract the sources to some folder, open the command prompt and go to that directory. Then enter following commands&#8230; No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Extract the sources to some folder, open the command prompt and go to that directory.</p>
<p>Then enter following commands&#8230;</p>
<pre class="brush: plain; title: ; notranslate">&gt; bootstrap.sh
&gt; bjam.exe --toolset=msvc --link=static --runtime-link=static --build-type=complete stage</pre>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1085" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2011%2F09%2Fbuilding-boost-1-47-0-with-visual-studio%2F&amp;title=Building%20Boost%201.47.0%20with%20Visual%20Studio" id="wpa2a_6"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2011/09/building-boost-1-47-0-with-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A small note regarding boost::format</title>
		<link>http://wp.freya.no/2011/03/a-small-note-regarding-boostformat/</link>
		<comments>http://wp.freya.no/2011/03/a-small-note-regarding-boostformat/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 22:50:25 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[format]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=1011</guid>
		<description><![CDATA[Boost::format&#8217;s performance sucks. I used boost::format in an inner loop in my project, and the optimized runtime was 20 seconds for 1 small case. I optimized away boost::format by replacing it with stream manipulators and i got the runtime down to 2 seconds for the same case. I&#8217;ll publish an article later on the details [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Boost::format&#8217;s performance <em>sucks</em>.</p>
<p>I used boost::format in an inner loop in my project, and the optimized runtime was 20 seconds for 1 small case.</p>
<p>I optimized away boost::format by replacing it with stream manipulators and i got the runtime down to 2 seconds for the same case.</p>
<p>I&#8217;ll publish an article later on the details on how to do this.</p>
<p>&nbsp;</p>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1011" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2011%2F03%2Fa-small-note-regarding-boostformat%2F&amp;title=A%20small%20note%20regarding%20boost%3A%3Aformat" id="wpa2a_14"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2011/03/a-small-note-regarding-boostformat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few boost::format examples</title>
		<link>http://wp.freya.no/2011/03/a-few-boostformat-examples/</link>
		<comments>http://wp.freya.no/2011/03/a-few-boostformat-examples/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 22:03:12 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[sample]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=970</guid>
		<description><![CDATA[I always forget how to use boost::format when I need it. So, here are a few samples from when I did remember. Only need is to include the proper boost header. No compile of any of the boost libraries is necessary. The source is also available in subversion (webclient) (subversion checkout). The output should be: [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I always forget how to use boost::format when I need it. So, here are a few samples from when I did remember.</p>
<p>Only need is to include the proper boost header. No compile of any of the boost libraries is necessary.</p>
<p>The source is also available in subversion (<a href="http://wp.freya.no/websvn/listing.php?repname=Public&amp;path=%2Fsamples%2Fboost-format%2F" target="_blank">webclient</a>) (<a href="http://wp.freya.no/svn/samples/boost-format/" target="_blank">subversion checkout</a>).</p>
<pre class="brush: cpp; title: ; notranslate">

// build with make or:
//
// g++ -I../../boost_1_46_0 fmt.cpp
//

#include &lt;iostream&gt;
#include &lt;sstream&gt;
#include &lt;boost/format.hpp&gt;

using namespace std;
using namespace boost;

int main()
{
    stringstream ss;

    int year    = 2011;
    int month   = 3;
    int day     = 11;
    int hour    = 12;
    int minute  = 1;
    double seconds= 23.35;
    double epoch  = 1231234567890.35;

    // Fill with whitespace, right align
    ss &lt;&lt; format(&quot;#1.0 %4i %4i %4i\n&quot;) % year % month % day;
    // Output: #1.0 2011    3   11

    // Fill with whitespace, left align
    ss &lt;&lt; format(&quot;#1.1 %-4i %-4i %-4i\n&quot;) % year % month % day;
    // Output: #1.1 2011 3    11

    // Fill with zero (pad)
    ss &lt;&lt; format(&quot;#2.0 %04i %04i %04i\n&quot;) % year % month % day;
    // Output: #2.0 2011 0003 0011

    // Floating point precision
    ss &lt;&lt; format(&quot;#3.0 %11.2f\n&quot;) % seconds;
    // Output: #3.0       23.35

    // Floating point precision with zero-fill (zero pad)
    ss &lt;&lt; format(&quot;#4.0 %011.2f\n&quot;) % seconds;
    // Output: #4.0 00000023.35

    // Left aligned string literal with 30+20 columns
    ss &lt;&lt; format(&quot;#5.0 %-30s%-20s\n&quot;) % &quot;LEFT ALIGNED 1&quot; % &quot;LEFT ALIGNED 2&quot;;
    // Output: #5.0 LEFT ALIGNED 1                LEFT ALIGNED 2

    // Right aligned string literal
    ss &lt;&lt; format(&quot;#6.0 %30s%20s\n&quot;) % &quot;RIGHT ALIGNED 1&quot; % &quot;RIGHT ALIGNED 2&quot;;
    // Output: #6.0                RIGHT ALIGNED 1     RIGHT ALIGNED 2

    cout &lt;&lt; ss.str();

    return 0;
}
</pre>
<p>The output should be:</p>
<pre class="brush: plain; title: ; notranslate">
#1.0 2011    3   11
#1.1 2011 3    11
#2.0 2011 0003 0011
#3.0       23.35
#4.0 00000023.35
#5.0 LEFT ALIGNED 1                LEFT ALIGNED 2
#6.0                RIGHT ALIGNED 1     RIGHT ALIGNED 2
</pre>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=970" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2011%2F03%2Fa-few-boostformat-examples%2F&amp;title=A%20few%20boost%3A%3Aformat%20examples" id="wpa2a_22"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2011/03/a-few-boostformat-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open and select file or folder with Explorer in C#</title>
		<link>http://wp.freya.no/2011/01/open-and-select-file-or-folder-with-explorer-in-c/</link>
		<comments>http://wp.freya.no/2011/01/open-and-select-file-or-folder-with-explorer-in-c/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 13:27:23 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[folder]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=964</guid>
		<description><![CDATA[This code will open Explorer and select the file or folder given. No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>This code will open Explorer and select the file or folder given.</p>
<pre class="brush: csharp; title: ; notranslate">
static void openInExplorer(string path)
{
    string cmd = &quot;explorer.exe&quot;;
    string arg = &quot;/select &quot; + path;
    Process.Start(cmd, arg);
}
</pre>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=964" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2011%2F01%2Fopen-and-select-file-or-folder-with-explorer-in-c%2F&amp;title=Open%20and%20select%20file%20or%20folder%20with%20Explorer%20in%20C%23" id="wpa2a_30"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2011/01/open-and-select-file-or-folder-with-explorer-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ and where predicate</title>
		<link>http://wp.freya.no/2011/01/linq-and-where-predicate/</link>
		<comments>http://wp.freya.no/2011/01/linq-and-where-predicate/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 15:42:26 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[predicate]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[where]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=939</guid>
		<description><![CDATA[This returns a strongly typed List of type foldersRow. No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<pre class="brush: csharp; title: ; notranslate">
static public List&lt;foldersRow&gt; getParentFolders(foldersRow parent)
{
    return (from p in m_Fildb.folders.Where( _p =&gt; _p.parent_folder_id == parent.folder_id) select p).ToList();
}
</pre>
<p>This returns a strongly typed List of type foldersRow.</p>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=939" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2011%2F01%2Flinq-and-where-predicate%2F&amp;title=LINQ%20and%20where%20predicate" id="wpa2a_38"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2011/01/linq-and-where-predicate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>STL container sort predicate with templates</title>
		<link>http://wp.freya.no/2010/10/stl-container-sort-predicate-with-templates/</link>
		<comments>http://wp.freya.no/2010/10/stl-container-sort-predicate-with-templates/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 14:16:18 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[container]]></category>
		<category><![CDATA[predicate]]></category>
		<category><![CDATA[std]]></category>
		<category><![CDATA[STL]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=873</guid>
		<description><![CDATA[This is a reminder to myself. To sort a collection of non-POD types (not Plain Old Data) with STL we need to tell it how to sort these objects. To the std::sort method we simply supply a predicate! It&#8217;s just a method taking 2 arguments of that type and apply our logic to tell if [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>This is a reminder to myself.</p>
<p>To sort a collection of non-POD types (not Plain Old Data) with STL we need to tell it how to sort these objects.</p>
<p>To the std::sort method we simply supply a predicate! It&#8217;s just a method taking 2 arguments of that type and apply our logic to tell if the first argument is lesser than the last argument. With templates it becomes a little more complex, but still it&#8217;s very simple when you know how it works.</p>
<p>Here is some sample code:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;iostream&gt;     // Provides cout
#include &lt;vector&gt;       // Provides our basic container
#include &lt;algorithm&gt;    // Provides std::sort

using namespace std;

// Structures I'll sort with 1 template function
//
//
struct A
{
    A(size_t i, size_t t) : id(i), time(t), other_data(false){}
    size_t  id;
    size_t  time;
    bool    other_data;
};

struct B
{
    B(size_t i, size_t t) : id(i), time(t), other_data(&quot;string data&quot;){}
    size_t  id;
    size_t  time;
    string  other_data;
};

struct C
{
    C(size_t i, size_t t) : id(i), time(t), other_data(&quot;character array data&quot;){}
    size_t  id;
    size_t  time;
    char*   other_data;
};

// Our predicate
//
template&lt;typename CLASS&gt;
bool timeSortPredicate( const CLASS &amp;a, const CLASS &amp;b )
{
    return a.time &lt; b.time;
}

template&lt;typename CLASS&gt;
bool idSortPredicate( const CLASS &amp;a, const CLASS &amp;b )
{
    return a.id &lt; b.id;
}

// Our collection printer
//
template&lt;typename CLASS&gt;
void print( const CLASS &amp;c )
{
    typedef typename CLASS::const_iterator cit;

    for ( cit it = c.begin(); it != c.end(); ++it )
    {
        cout &lt;&lt; it-&gt;id &lt;&lt; &quot; &quot; &lt;&lt; it-&gt;time &lt;&lt; endl;
    }
}

int main()
{
    // Construct the objects ... tedious I know
    A a1(1,15), a2(2,20),   a3(3,14);
    B b1(3,4),  b2(2,10),   b3(1,12);
    C c1(11,0), c2(12,0),   c3(13,0);

    // Construct collections
    vector&lt;A&gt; alist;
    alist.push_back(a1);
    alist.push_back(a2);
    alist.push_back(a3);

    vector&lt;B&gt; blist;
    blist.push_back(b1);
    blist.push_back(b2);
    blist.push_back(b3);

    vector&lt;C&gt; clist;
    clist.push_back(c1);
    clist.push_back(c2);
    clist.push_back(c3);

    // Print stuff
    cout &lt;&lt; &quot;Collection A&quot; &lt;&lt; endl;
    print(alist);

    cout &lt;&lt; &quot;Collection B&quot; &lt;&lt; endl;
    print(blist);

    cout &lt;&lt; &quot;Collection C&quot; &lt;&lt; endl;
    print(clist);

    cout &lt;&lt; &quot;Sorting collections by time&quot; &lt;&lt; endl;

    sort(alist.begin(), alist.end(), timeSortPredicate&lt;A&gt; );
    sort(blist.begin(), blist.end(), timeSortPredicate&lt;B&gt; );
    sort(clist.begin(), clist.end(), timeSortPredicate&lt;C&gt; );

    // Print stuff
    cout &lt;&lt; &quot;Collection A&quot; &lt;&lt; endl;
    print(alist);

    cout &lt;&lt; &quot;Collection B&quot; &lt;&lt; endl;
    print(blist);

    cout &lt;&lt; &quot;Collection C&quot; &lt;&lt; endl;
    print(clist);

    cout &lt;&lt; &quot;Sorting collections by id&quot; &lt;&lt; endl;

    sort(alist.begin(), alist.end(), idSortPredicate&lt;A&gt; );
    sort(blist.begin(), blist.end(), idSortPredicate&lt;B&gt; );
    sort(clist.begin(), clist.end(), idSortPredicate&lt;C&gt; );

    // Print stuff
    cout &lt;&lt; &quot;Collection A&quot; &lt;&lt; endl;
    print(alist);

    cout &lt;&lt; &quot;Collection B&quot; &lt;&lt; endl;
    print(blist);

    cout &lt;&lt; &quot;Collection C&quot; &lt;&lt; endl;
    print(clist);

    return 0;
}
</pre>
<p>Compile with:</p>
<pre class="brush: plain; title: ; notranslate">g++ sortpredicate.cpp -o sortpredicate</pre>
<p>The output should be:</p>
<pre class="brush: plain; title: ; notranslate">Collection A
1 15
2 20
3 14
Collection B
3 4
2 10
1 12
Collection C
11 0
12 0
13 0
Sorting collections by time
Collection A
3 14
1 15
2 20
Collection B
3 4
2 10
1 12
Collection C
11 0
12 0
13 0
Sorting collections by id
Collection A
1 15
2 20
3 14
Collection B
1 12
2 10
3 4
Collection C
11 0
12 0
13 0
</pre>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=873" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2010%2F10%2Fstl-container-sort-predicate-with-templates%2F&amp;title=STL%20container%20sort%20predicate%20with%20templates" id="wpa2a_46"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2010/10/stl-container-sort-predicate-with-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a game</title>
		<link>http://wp.freya.no/2010/08/making-a-game/</link>
		<comments>http://wp.freya.no/2010/08/making-a-game/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 11:11:41 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[making a game]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=814</guid>
		<description><![CDATA[Okay. This is going to be somewhat personal. I&#8217;m a professional software developer for a medium sized company, which is really not a software company. It&#8217;s only internal software I write. I&#8217;ve also wanted to make a game since I started playing games. That&#8217;s probably why I&#8217;m a software developer today. I&#8217;ve been doing more [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Okay. This is going to be somewhat personal.</p>
<p>I&#8217;m a professional software developer for a medium sized company, which is really not a software company. It&#8217;s only internal software I write.</p>
<p>I&#8217;ve also wanted to make a game since I started playing games. That&#8217;s probably why I&#8217;m a software developer today. I&#8217;ve been doing more or less C++ since I was 14, doing (at least trying to) 3D-graphics since I was 18. Without knowledge of the particular mathematics involved with 3D-graphics it proved to be difficult.</p>
<p>I&#8217;ve started numerous projects with OpenGL, and some are more advanced than others, but I didn&#8217;t continue working on a project for more than 2-3 days before I got tired.</p>
<p>I&#8217;ve started an other project now. I don&#8217;t know what I&#8217;ll make, or whether <em>if</em> I&#8217;ll make anything. But I&#8217;ve started an other project. The only real difference from previous projects is that I know the value of libraries and there is no point in re-inventing the wheel for every project.</p>
<p>Standard template library is there, Boost is there and some other libraries. I know how to use them. And I know they exist!</p>
<p>For this project I know I&#8217;m going to use</p>
<ul>
<li>STL</li>
<li>The boost libraries</li>
<li>Ogre3D for graphics</li>
</ul>
<p>I&#8217;m not so sure about the sound and physics part, but for now I think I&#8217;ll stick with</p>
<ul>
<li>Bullet for physics</li>
<li>FMOD for sound</li>
</ul>
<p>I must also review the licenses  for the libraries to make sure they are allowed to be used in commercial projects or not. I&#8217;m not saying my project is going to be commercial, but I won&#8217;t exclude it. I&#8217;ll also aim for Windows and Linux support. And probably Mac if it&#8217;s going to be commercial.</p>
<p>So far I have an empty scene with a blue background.</p>
<p><a href="http://wp.freya.no/files/2010/08/moz-screenshot.png"><img class="size-medium wp-image-817 alignnone" title="An empty scene" src="http://wp.freya.no/files/2010/08/moz-screenshot-300x232.png" alt="" width="300" height="232" /></a></p>
<p>It&#8217;s a start! &#8230; again</p>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=814" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2010%2F08%2Fmaking-a-game%2F&amp;title=Making%20a%20game" id="wpa2a_54"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2010/08/making-a-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio: fatal error LNK1201: error writing to program database &#8216;&#8230;&#8217; check for insufficient disk space, invalid path, or insufficient privilege</title>
		<link>http://wp.freya.no/2010/08/visual-studio-fatal-error-lnk1201-error-writing-to-program-database-check-for-insufficient-disk-space-invalid-path-or-insufficient-privilege/</link>
		<comments>http://wp.freya.no/2010/08/visual-studio-fatal-error-lnk1201-error-writing-to-program-database-check-for-insufficient-disk-space-invalid-path-or-insufficient-privilege/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 12:15:04 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=810</guid>
		<description><![CDATA[When I get this error, it&#8217;s always because I&#8217;ve opened the debugging process in Process Explorer. Close the handle in Process Explorer or restart Process Explorer. No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>When I get this error, it&#8217;s always because I&#8217;ve opened the debugging process in Process Explorer.</p>
<pre class="brush: plain; title: ; notranslate">Error    1    fatal error LNK1201: error writing to program database 'e:\blergh\blergh\bin\blergh_d.pdb'; check for insufficient disk space, invalid path, or insufficient privilege</pre>
<p>Close the handle in Process Explorer or restart Process Explorer.</p>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=810" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2010%2F08%2Fvisual-studio-fatal-error-lnk1201-error-writing-to-program-database-check-for-insufficient-disk-space-invalid-path-or-insufficient-privilege%2F&amp;title=Visual%20Studio%3A%20fatal%20error%20LNK1201%3A%20error%20writing%20to%20program%20database%20%26%238216%3B%26%238230%3B%26%238217%3B%20check%20for%20insufficient%20disk%20space%2C%20invalid%20path%2C%20or%20insufficient%20privilege" id="wpa2a_62"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2010/08/visual-studio-fatal-error-lnk1201-error-writing-to-program-database-check-for-insufficient-disk-space-invalid-path-or-insufficient-privilege/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>User warnings for MS Visual Studio</title>
		<link>http://wp.freya.no/2010/04/user-warnings-for-ms-visual-studio/</link>
		<comments>http://wp.freya.no/2010/04/user-warnings-for-ms-visual-studio/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 09:43:39 +0000</pubDate>
		<dc:creator>kent</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://wp.freya.no/?p=639</guid>
		<description><![CDATA[This little macro prints out user warnings to the output window in a format the &#8220;Error List&#8221; within Visual Studio will understand and parse. Taken from Stack Overflow and modified a little. It will produce output like this: When this line is present in the source file. No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>This little macro prints out user warnings to the output window in a format the &#8220;Error List&#8221; within Visual Studio will understand and parse. <a href="http://stackoverflow.com/questions/471935/user-warnings-on-msvc-and-gcc" target="_blank">Taken from Stack Overflow and modified a little</a>.</p>
<pre class="brush: cpp; title: ; notranslate">
#define STRINGISE_IMPL(x) #x
#define STRINGISE(x) STRINGISE_IMPL(x)

	// Use: #pragma message WARN(&quot;My message&quot;)
#if _MSC_VER
#   define FILE_LINE_LINK __FILE__ &quot;(&quot; STRINGISE(__LINE__) &quot;) : &quot;
#   define WARN(exp) (FILE_LINE_LINK &quot;warning: &quot; exp)
#else//__GNUC__ - may need other defines for different compilers
#   define WARN(exp) (&quot;WARNING: &quot; exp)
#endif
</pre>
<p>It will produce output like this:</p>
<pre class="brush: plain; title: ; notranslate">
1&gt;.\src\bug.cpp(82) : warning: check me
</pre>
<p>When this line is present in the source file.</p>
<pre class="brush: cpp; title: ; notranslate">
#pragma message WARN(&quot;check me&quot;)
</pre>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=639" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2F2010%2F04%2Fuser-warnings-for-ms-visual-studio%2F&amp;title=User%20warnings%20for%20MS%20Visual%20Studio" id="wpa2a_70"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/2010/04/user-warnings-for-ms-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Class templates in C++</title>
		<link>http://wp.freya.no/c/class-templates-in-c/</link>
		<comments>http://wp.freya.no/c/class-templates-in-c/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 21:58:18 +0000</pubDate>
		<dc:creator>Tatyana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[point]]></category>
		<category><![CDATA[point3d]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://wp.freya.no/</guid>
		<description><![CDATA[Templates in C++ are the way functions and classes operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one [wiki]. Note that there is a difference between class template and a template class: class template is a template used to generate template [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Templates in  C++ are the way functions and classes operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one [<a href="http://en.wikipedia.org/wiki/Template_%28programming%29">wiki</a>].</p>
<p>Note that there is a difference between class template and a template class: class template is a template used to generate template classes. You cannot declare an object of a class template. Template class is an instance of a class template<a href="http://scv.bu.edu/computation/bluegene/IBMdocs/compiler/xlc-8.0/html/language/ref/class_templates.htm">.</a></p>
<p>Here we are going to look at 3 main clas templates that are very useful in game and 3D design: Point, Vector and Matrix class templates.</p>
<h3>Point and Point3D:</h3>
<p>Here is how a simple Point template will look like in C++. This template is constructed to support multiple dimensions like Point2D, 3D and so on:</p>
<pre class="brush: cpp; title: ; notranslate">
template &lt;class T, int n&gt; class Point {
protected:
	T mat[n];
	 void cp(const Point&lt;T,n&gt; &amp;p)
    {
		memcpy(mat, p.mat, n*sizeof(T) );
	 }

    void cp(const T p[n])
    {
		memcpy(mat, p, n*sizeof(T) );
	}

    void cp(const T &amp;val)
    {
		for (int i=0; i&lt;n; i++)
			mat[i] = val;
    }

public:
	// new constructor
	Point(const T pt[n])
	{
		cp(pt);
	}

	// copy constructor
	Point(const Point&lt;T,n&gt; &amp;cp)
	{
		this-&gt;cp(cp);
	}

	// default constructor
	Point()
	{
		for (int i=0; i&lt;n; i++)
			mat[i] = 0;
	}
	virtual ~Point(void) {};
};
</pre>
<p>Templates are of great utility to programmers in C++, especially when combined with multiple inheritance and operator overloading. Here vi can add multiple operator overloading functions to our Point class template, for example addition:</p>
<pre class="brush: cpp; title: ; notranslate">
        //Point + some value
	Point&lt;T,n&gt; &amp;operator+=(const T &amp;val)
    {
		for (int i=0; i&lt;n; i++)
			mat[i] += val;

		return (*this);
    }

    //sum of two Points
    Point&lt;T,n&gt; &amp;operator+=(Point&lt;T,n&gt; &amp;pt)
    {
		for (int i=0; i&lt;n; i++)
			mat[i] += pt[i];

		return (*this);
    }
</pre>
<p>A Point3D class template will look like this:</p>
<pre class="brush: cpp; title: ; notranslate">
template &lt;class T&gt; class Point3D : public Point&lt;T,3&gt; {
public:
	Point3D() : Point&lt;T,3&gt;() {};

	Point3D(const Point3D&lt;T&gt; &amp;p) : Point&lt;T,3&gt;(p) {
		for (int i=0; i&lt;3; i++)
		mat[i] = p.mat[i];
	}
	Point3D( const T px, const T py, const T pz)
	{
		mat[0]=px; mat[1]=py; mat[2]=pz;
	}
};
</pre>
<p>An example of how we can use it is a motion programming:</p>
<pre class="brush: cpp; title: ; notranslate">
	Point3D&lt;float&gt; EulerAngle(float sensitivity, double x, double y, double z) {
		return Point3D&lt;float&gt; (
				sensitivity*cos(z),
				sensitivity*sin(z),
				0
		);
	}
</pre>
 <img src="http://wp.freya.no/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=598" width="1" height="1" style="display: none;" /><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwp.freya.no%2Fc%2Fclass-templates-in-c%2F&amp;title=Class%20templates%20in%20C%2B%2B" id="wpa2a_78"><img src="http://wp.freya.no/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://wp.freya.no/c/class-templates-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

