cinera_handmade.network/cmuratori/hero/code/code007_template.html

44 lines
3.1 KiB
HTML
Raw Permalink Normal View History

<html>
<head>
<!-- __CINERA_INCLUDES__ -->
</head>
<body>
<div>
<!-- __CINERA_MENUS__ -->
<!-- __CINERA_PLAYER__ -->
</div>
<!-- __CINERA_SCRIPT__ -->
<article id="video-notes">
<h1><!-- __CINERA_TITLE__ --></h1>
<h3 id="input-cleanup-and-fixes">Input Cleanup and Fixes</h3>
<p>This episode starts with some cleanup and fixes to the input handling code from yesterday.</p>
<ul>
<li>Windows API often uses a <code>0</code> return value to indicate success. Our stubs probably shouldn&#39;t return <code>0</code>.</li>
<li>Windows 8 ships with <code>xinput1_4.dll</code> only. So we need to try each version in turn</li>
<li>When you handle WM_SYSKEY* messages, you lose built in Alt-F4 functionality, and have to reimplement it.</li>
</ul>
<h3 id="sound-programming-for-games">Sound Programming for Games</h3>
<p>Casey starts with a high level overview of sound programing for games. The key ideas here are that we are allocating
a <a href="http://en.wikipedia.org/wiki/Circular_buffer">circular buffer</a> for sound, and the system will play it continually
on a loop. If you haven&#39;t worked with circular buffers (or ring buffers) before, much of this code will be confusing.
It&#39;s worth taking some time to familiarize yourself with them.</p>
<p>Resources:</p>
<ul>
<li><a href="http://c.learncodethehardway.org/book/ex44.html">Ring Buffers</a> on &quot;Learn C The Hard Way&quot;</li>
</ul>
<h3 id="working-with-directsound">Working with DirectSound</h3>
<p>The basic process for initializing DirectSound is as follows:</p>
<ol>
<li>Load the Library - <a href="http://msdn.microsoft.com/en-us/library/ms684175.aspx"><code>LoadLibrary</code></a><code>(&quot;dsound.dll&quot;)</code></li>
<li>Create a DirectSound object - <a href="http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.reference.directsoundcreate8.aspx"><code>DirectSoundCreate()</code></a></li>
<li>Set the Cooperative Level - <a href="http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectsound8.idirectsound8.setcooperativelevel.aspx"><code>IDirectSound8::SetCooperativeLevel()</code></a></li>
<li>&quot;Create&quot; a primary buffer - <a href="http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectsound8.idirectsound8.createsoundbuffer.aspx"><code>IDirectSound8::CreateSoundBuffer()</code></a></li>
<li>Create a secondary buffer</li>
<li>Tell DirectSound to start playing the secondary buffer - <a href="http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectsoundbuffer8.idirectsoundbuffer8.play.aspx"><code>IDirectSoundBuffer8::Play()</code></a></li>
</ol>
<p>In the next episode we will look closely at how to fill this buffer and implement it in the game loop.</p>
</article>
</body>
</html>