Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 593

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/project-web/btanks/htdocs/blog/wp-includes/classes.php on line 710

Strict Standards: Redefining already defined constructor for class wpdb in /home/project-web/btanks/htdocs/blog/wp-includes/wp-db.php on line 58

Deprecated: Assigning the return value of new by reference is deprecated in /home/project-web/btanks/htdocs/blog/wp-includes/cache.php on line 99

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/project-web/btanks/htdocs/blog/wp-includes/cache.php on line 404

Deprecated: Assigning the return value of new by reference is deprecated in /home/project-web/btanks/htdocs/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/project-web/btanks/htdocs/blog/wp-includes/theme.php on line 576

Warning: Cannot modify header information - headers already sent by (output started at /home/project-web/btanks/htdocs/blog/wp-includes/classes.php:576) in /home/project-web/btanks/htdocs/blog/wp-content/plugins/LangSwitch/langswitch.php on line 587

Deprecated: Function eregi() is deprecated in /home/project-web/btanks/htdocs/blog/wp-content/plugins/captcha/captcha.php on line 1429

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/project-web/btanks/htdocs/blog/wp-includes/plugin.php on line 311
Battle Tanks » Blog Archive » OpenAL programming faq
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Captcha::css() should not be called statically in /home/project-web/btanks/htdocs/blog/wp-includes/plugin.php on line 311


Warning: mktime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 19

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 28

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 30

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 32

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 33

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 19

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 28

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 30

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 32

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/project-web/btanks/htdocs/blog/wp-includes/functions.php on line 33

OpenAL programming faq

OpenAL Lite Programming FAQ

How could I determine maximum sources number available for OpenAL ?
Many people use alut for OpenAL initialization and do not know it’s simple to do yourself. You will gain additional control over device and context by doing so.
Do not use alut for that!

  1. Choose audio device (by name or using NULL as name for default device, usually the best hardware driver available)
  2. You can skip this step : create context attributes:
    ALCint attrs[] = {
    ALC_STEREO_SOURCES, stereo_sources,
    ALC_MONO_SOURCES, mono_sources,
    ALC_INVALID, ALC_INVALID,
    }; //stereo_sources and mono_sources are OpenAL hints. Minimal and working for the most people value - 16. Note that stereo source use 2 real mono source. So if you have music thread, only 14 mono sources remain available.
  3. create contexrt alcCreateContext(alc_device, attrs);
  4. Get context attributes:
    ALCInt attr_size;
    alcGetIntegerv(alc_device, ALC_ATTRIBUTES_SIZE, sizeof(attr_size), &attr_size);
    const ALCInt * attributes = (ALCint *)malloc(attr_size * sizeof(ALCint));
    alcGetIntegerv(alc_device, ALC_ALL_ATTRIBUTES, attr_size, attributes);
    Now ‘attributes’ points to the context attributes, arranged as attrs[] array from (2).


How could I open non-default device?

alcGetString(NULL, ALC_DEVICE_SPECIFIER) doesn’t only return default device string. It returns all devices supported by OpenAL, arranged in the following manner:
“Generic Hardware”, 0, “Generic Software”, 0, 0
Just for sanity you could check the presence of ALC_ENUMERATION_EXT, but as long as I remember, OpenAL 1.1 made it mandatory. (fix me?)

I do not want OpenAL mixer thread, I want mixer working from my own thread.

It’s very easy : use attribute ALC_SYNC set in AL_TRUE. Call alcProcessContext(context); from your worker thread.

I’m experiencing weird errors or crashes. What should I do ?

Check the following conditions in your code:

  1. After every single OpenAL call, you call alGetError() and process critical errors for your code. alGetError cleans internal OpenAL error state.
  2. You call alGenSources once while your application starts. You do not use alGetSources(&source, 1); every time you need a single source.
  3. Have debian-amd64? Try my openAL build. Do not forget report bug against debian bug tracker system. OpenAL mistakenly use mmx ia32 builtins on x86_64 architecture. At least disabling all __MMX__ dependent sources helps.

16 sources is not enough. I have more than hundred objects on single level.

You don’t need all hundred sources playing simultaneously. :) OpenAL does not have any source manager. You should write it yourself or take from another project. (Do not forget to read the license)

  1. OpenAL initialization
  2. Tracking object positions, remove distant sounds.
  3. Restart previously removed loops. (helicopters or such)

How could I create stereo source playing music without 3d attenuation.

Set the following source attributes:
alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE);
alSourcef (source, AL_ROLLOFF_FACTOR, 0.0);
To restore 3d state set it back to default values (AL_FALSE and 1.0 respectively)

©2007 Vladimir Menshakov, Netive Media Group.

7509 Responses to “OpenAL programming faq”

  1. jin Says:

    ^^

Leave a Reply

You must be logged in to post a comment.