Code Search for Developers
 
 
  

documentation_openal_04.php from Lightweight Java Game Library at Krugle


Show documentation_openal_04.php syntax highlighted

<? require('_include/header.php'); ?>

<div style="margin: 0px 0px 10px 10px; width: 240px; float: right; border: 1px solid #000000;">
	<table border="0" cellpadding="3" cellspacing="0">
    	<tr>
      		<td width="100%" style="text-align: center; background-color: #cccccc; font-weight: bold; border-bottom: 1px solid #000000;" colspan="2">Other Articles in the Series</td>
    	</tr>
    	<tr>
    	    <td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_01.php">Lesson 1: Single Static Source</a></td>
        </tr>
    	<tr>
    	    <td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_02.php">Lesson 2: Looping and Fade-away</a></td>
        </tr>
    	<tr>
    	    <td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_03.php">Lesson 3: Multiple Sources</a></td>
        </tr>
    	<tr>
    	    <td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_04.php">Lesson 4: A Closer Look at ALC</a></td>
        </tr>
    	<tr>
        	<td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_05.php">Lesson 5: Sources Sharing Buffers</a></td>
        </tr>
    	<tr>
    	    <td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_06.php">Lesson 6: Advanced Loading and Error Handles</a></td>
        </tr>
    	<tr>
    	    <td valign="top">&middot;</td>
    	    <td width="100%" style="text-align: left;"><a href="documentation_openal_07.php">Lesson 7: The Doppler Effect</a></td>
        </tr>
    </table>
</div>

<h1>A Closer Look at ALC: Lesson 4</h1>
<p>
    <i>
		Author: <a href="mailto:lightonthewater@hotmail.com">Jesse Maurais</a> | From: <a href="http://www.devmaster.net/articles.php?catID=6" target="_blank">devmaster.net</a><br/>
    	Modified for LWJGL by: <a href="mailto:brian@matzon.dk">Brian Matzon</a>
	</i>
</p>

<p>
	<i><b>Note:</b>This article originally deals with ALC Context management,
	and especially using multiple contexts. The LWJGL binding does <b>not</b>
	expose multiple contexts, nor do we have any plans to do so. It is an
	advanced feature, not used in games. This article has also been edited
	heavily to make sense in an LWJGL environment which doesn't expose ALC
	directly.</i>
</p>

<p>
	Up until now we have been letting <code>AL.create()</code> do all the real
	tricky stuff for us. For example handling the audio devices. It's really
	nice that the <code>AL.create()</code> method is there to provide this
	functionality, but any smart coder will want to know exactly what their
	doing. We may want to, at some point, use the verbose
	<code>AL.create(String deviceArguments, <span class="codeKeyword">int</span>
	contextFrequency, <span class="codeKeyword">int</span> contextRefresh,
	<span class="codeKeyword">boolean</span> contextSynchronized)</code> method.
	In this tutorial we will expose the Alc layer and take a look at how to
	handle the devices on our own.</p>
</p>

<p>
	When using either of the two create methods of <code>AL</code>, a default
	context and device is created for you. You cannot create multiple contexts
	nor can you access multiple devices. Thus a lot of the ALC methods are not
	available, since they simply don't make any sense. Methods that are
	available also no longer take a device or context parameter since they are
	managed internally.
</p>

<pre class="code" style="clear: right;">
    <span class="codeComment">// Initialize OpenAL and clear the error bit.</span>
    <span class="codeKeyword">try</span>{
    	AL.create();
    } <span class="codeKeyword">catch</span> (LWJGLException le) {
    	le.printStackTrace();
      <span class="codeKeyword">return</span>;
    }
    AL10.alGetError();
</pre>

<p>
	Using the default create method is the simplest way to create a context and
	access a device. Default values are used, and once called OpenAL is
	initialized and ready to go.
</p>

<pre class="code">
    <span class="codeComment">// Initialize OpenAL and clear the error bit.</span>
    <span class="codeKeyword">try</span>{
    	AL.create("DirectSound3D", 44100, 15, <span class="codeKeyword">false</span>);
    } <span class="codeKeyword">catch</span> (LWJGLException le) {
    	le.printStackTrace();
      <span class="codeKeyword">return</span>;
    }
    AL10.alGetError();
</pre>

<p>
	Here we initialize OpenAL using arguments for ALC. The first argument tells
	ALC which device to access. Passing null is a perfectly valid argument. It
	forces the ALC to use a default device.<br/>
	The second argument tells ALC the frequency for mixing output buffer, in
	units of Hz. Third argument tells ALC how often it should update it's
	internal state and buffers. The final argument determines whether the ALC
	should run in synchronous mode.
</p>

<pre class="code">
    <span class="codeKeyword">public static int</span> alcGetError();
    <span class="codeKeyword">public static boolean</span> alcIsExtensionPresent(String extName);
    <span class="codeKeyword">public static int</span> alcGetEnumValue(String enumName);
    <span class="codeKeyword">public static </span>String alcGetString(<span class="codeKeyword">int</span> pname);
    <span class="codeKeyword">public static void</span> alcGetInteger(<span class="codeKeyword">int</span> pname, IntBuffer integerdata);
</pre>

<p>
	It may be pretty obvious to you what these do, but lets humour ourselves and
	have a closer look. First we have 'alcGetError' which is just like
	'alGetError' but will return Alc errors. The next two functions are for
	querying Alc extensions. This was just the creators planning ahead, as there
	are no Alc extensions either. The last function, 'alcGetInteger', will
	return the Alc version when passed 'ALC_MAJOR_VERSION' or 'ALC_MINOR_VERSION'.<br/><br/>
	The function 'alcGetString' is pretty cool. It can take any of the following
	three parameters to 'token':<br/><br/>
	&nbsp;&nbsp;&nbsp;* ALC_DEFAULT_DEVICE_SPECIFIER<br/>
	&nbsp;&nbsp;&nbsp;* ALC_DEVICE_SPECIFIER<br/>
	&nbsp;&nbsp;&nbsp;* ALC_EXTENSIONS<br/><br/>
	The first will return the device string which your OpenAL implementation
	will prefer you to use. In current OpenAL this should be "DirectSound3D",
	like we used above. The second token will return a list of specifiers, but
	in current OpenAL will only return "DirectSound" (without the "3D" for some
	reason). The last will return a list of Alc extensions, of which none exist
	yet.<br/><br/>
	Well that's most of Alc for you. I hope it gave you a better understanding
	of how OpenAL interacts with the operation system.
</p>

<? require('_include/footer.php'); ?>




See more files for this project here

Lightweight Java Game Library

A Java Game Library extension: 1. Handles the graphics, sound, and input simply 2. Wraps OpenGL, OpenAL, fmod3 and DevIL 3. Hires timers LWJGL currently supports Linux, Mac OS X (10.2 and above) and Windows (98 and above).

Project homepage: http://sourceforge.net/projects/java-game-lib
Programming language(s): C,Java
License: other

  _files/
    tutorials/
      openal_devmaster_lesson1.zip
      openal_devmaster_lesson2.zip
      openal_devmaster_lesson3.zip
      openal_devmaster_lesson5.zip
  _gfx/
    installation/
      eclipse-1.png
      eclipse-2.png
      eclipse-3.png
      eclipse-4.png
      jcreator-1.jpg
      jcreator-2.jpg
      jcreator-3.jpg
      netbeans-1.png
      netbeans-2.png
      netbeans-3.png
    projects/
      alienflux_1.jpg
      alienflux_2.jpg
      alienflux_3.jpg
      alienflux_small_1.jpg
      alienflux_small_2.jpg
      alienflux_small_3.jpg
      cultris_1.jpg
      cultris_2.jpg
      cultris_3.jpg
      cultris_small_1.jpg
      cultris_small_2.jpg
      cultris_small_3.jpg
      diamond_crush_1.jpg
      diamond_crush_2.jpg
      diamond_crush_3.jpg
      diamond_crush_small_1.jpg
      diamond_crush_small_2.jpg
      diamond_crush_small_3.jpg
      dragon_forever_1.png
      dragon_forever_2.png
      dragon_forever_3.png
      dragon_forever_small_1.png
      dragon_forever_small_2.png
      dragon_forever_small_3.png
      drommi_small_1.jpg
      drommi_small_2.jpg
      drommi_small_3.jpg
      extorris_1.jpg
      extorris_2.jpg
      extorris_3.jpg
      extorris_small_1.jpg
      extorris_small_2.jpg
      extorris_small_3.jpg
      hz_1.jpg
      hz_2.jpg
      hz_3.jpg
      hz_small_1.jpg
      hz_small_2.jpg
      hz_small_3.jpg
      illuminati_1.jpg
      illuminati_2.jpg
      illuminati_3.jpg
      illuminati_small_1.jpg
      illuminati_small_2.jpg
      illuminati_small_3.jpg
      jglmark_1.jpg
      jglmark_2.jpg
      jglmark_3.jpg
      jglmark_small_1.jpg
      jglmark_small_2.jpg
      jglmark_small_3.jpg
      keith_goes_painting_1.jpg
      keith_goes_painting_2.jpg
      keith_goes_painting_3.jpg
      keith_goes_painting_small_1.jpg
      keith_goes_painting_small_2.jpg
      keith_goes_painting_small_3.jpg
      monstrumo_1.jpg
      monstrumo_2.jpg
      monstrumo_3.jpg
      monstrumo_small_1.jpg
      monstrumo_small_2.jpg
      monstrumo_small_4.jpg
      puppytron_1.jpg
      puppytron_2.jpg
      puppytron_3.jpg
      puppytron_small_1.jpg
      puppytron_small_2.jpg
      puppytron_small_3.jpg
      slam_soccer_2006_1.jpg
      slam_soccer_2006_2.jpg
      slam_soccer_2006_3.jpg
      slam_soccer_2006_small_1.jpg
      slam_soccer_2006_small_2.jpg
      slam_soccer_2006_small_3.jpg
      starship2d_1.jpg
      starship2d_2.jpg
      starship2d_3.jpg
      starship2d_small_1.jpg
      starship2d_small_2.jpg
      starship2d_small_3.jpg
      strategic_tetris_1.jpg
      strategic_tetris_2.jpg
      strategic_tetris_3.jpg
      strategic_tetris_small_1.jpg
      strategic_tetris_small_2.jpg
      strategic_tetris_small_3.jpg
      subhunt_1.jpg
      subhunt_2.jpg
      subhunt_3.jpg
      subhunt_small_1.jpg
      subhunt_small_2.jpg
      subhunt_small_3.jpg
      superdudester_1.jpg
      superdudester_2.jpg
      superdudester_3.jpg
      superdudester_small_1.jpg
      superdudester_small_2.jpg
      superdudester_small_3.jpg
      technopolies_1.jpg
      technopolies_2.jpg
      technopolies_3.jpg
      technopolies_small_1.jpg
      technopolies_small_2.jpg
      technopolies_small_3.jpg
      titan_attacks_1.jpg
      titan_attacks_2.jpg
      titan_attacks_3.jpg
      titan_attacks_small_1.jpg
      titan_attacks_small_2.jpg
      titan_attacks_small_3.jpg
      tribaltrouble_1.jpg
      tribaltrouble_2.jpg
      tribaltrouble_3.jpg
      tribaltrouble_small_1.jpg
      tribaltrouble_small_2.jpg
      tribaltrouble_small_3.jpg
      typhoon_1.png
      typhoon_2.png
      typhoon_3.png
      typhoon_small_1.png
      typhoon_small_2.png
      typhoon_small_3.png
      ultratron_1.jpg
      ultratron_2.jpg
      ultratron_3.jpg
      ultratron_small_1.jpg
      ultratron_small_2.jpg
      ultratron_small_3.jpg
      vermins_1.jpg
      vermins_2.jpg
      vermins_small_1.jpg
      vermins_small_2.jpg
    tutorials/
      openal/
    background.png
    borderBottom.png
    borderLeft.png
    borderRight.png
    borderTop.png
    button_backwards.png
    button_forwards.png
    button_javanet.png
    button_openal.png
    button_opengl.png
    button_sourceforge.png
    cornerBL.png
    cornerBR.png
    cornerTL.png
    cornerTR.png
    logo.png
    mesh.png
    paypal.png
    seperator.png
  _include/
    footer.php
    header.php
  changelogs/
    0.10-changelog.txt
    0.20-changelog.txt
    0.30-changelog.txt
    0.40-changelog.txt
    0.50-changelog.txt
    0.60-changelog.txt
    0.70-changelog.txt
    0.80-changelog.txt
    0.89-changelog.txt
    0.90-changelog.txt
    0.92-changelog.txt
    0.93-changelog.txt
    0.94-changelog.txt
    0.95-changelog.txt
    0.96-changelog.txt
    0.97-changelog.txt
    0.98-changelog.txt
    0.99-changelog.txt
    1.0-changelog.txt
    1.0-rc1-changelog.txt
    1.0beta-changelog.txt
    1.0beta2-changelog.txt
    1.0beta3-changelog.txt
    1.0beta4-changelog.txt
    1.1-changelog.txt
    1.1.1-changelog.txt
    full-changelog.txt
  jnlp/
    logo.png
    lwjgl-demo.php
    lwjgl.jar
    lwjgl_fmod3.jar
    lwjgl_linux.jar
    lwjgl_media.jar
    lwjgl_test.jar
    lwjgl_util.jar
    lwjgl_win32.jar
    source.php
  about.php
  changelog.php
  contact.php
  credits.php
  demos.php
  documentation.php
  documentation_openal_01.php
  documentation_openal_02.php
  documentation_openal_03.php
  documentation_openal_04.php
  documentation_openal_05.php
  documentation_openal_06.php
  documentation_openal_07.php
  donations.php
  download.php
  faq.php
  favicon.ico
  index.php
  installation.php
  irclog_browse.php
  license.php
  links.php
  picpopup.php
  projects.php
  shop.php
  style.css