master #2
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**2.2.7**
|
||||||
|
* Fix Crash When OpenAL Is Unavailable
|
||||||
|
* Fix Command Input In Server
|
||||||
|
|
||||||
**2.2.5**
|
**2.2.5**
|
||||||
* Fix Bug In Texture Scaling Code
|
* Fix Bug In Texture Scaling Code
|
||||||
|
|
||||||
|
BIN
images/start.png
BIN
images/start.png
Binary file not shown.
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
@ -25,90 +25,96 @@ static std::vector<ALuint> &get_sources() {
|
|||||||
|
|
||||||
// Update Listener
|
// Update Listener
|
||||||
void media_audio_update(float volume, float x, float y, float z, float yaw) {
|
void media_audio_update(float volume, float x, float y, float z, float yaw) {
|
||||||
// Update Listener Volume
|
// Check
|
||||||
alListenerf(AL_GAIN, volume);
|
if (_media_audio_is_loaded()) {
|
||||||
AL_ERROR_CHECK();
|
// Update Listener Volume
|
||||||
|
alListenerf(AL_GAIN, volume);
|
||||||
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Update Listener Position
|
// Update Listener Position
|
||||||
alListener3f(AL_POSITION, x, y, z);
|
alListener3f(AL_POSITION, x, y, z);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Update Listener Orientation
|
// Update Listener Orientation
|
||||||
float radian_yaw = yaw * (M_PI / 180);
|
float radian_yaw = yaw * (M_PI / 180);
|
||||||
ALfloat orientation[] = {-sinf(radian_yaw), 0.0f, cosf(radian_yaw), 0.0f, 1.0f, 0.0f};
|
ALfloat orientation[] = {-sinf(radian_yaw), 0.0f, cosf(radian_yaw), 0.0f, 1.0f, 0.0f};
|
||||||
alListenerfv(AL_ORIENTATION, orientation);
|
alListenerfv(AL_ORIENTATION, orientation);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Clear Finished Sources
|
// Clear Finished Sources
|
||||||
std::vector<ALuint>::iterator it = get_sources().begin();
|
std::vector<ALuint>::iterator it = get_sources().begin();
|
||||||
while (it != get_sources().end()) {
|
while (it != get_sources().end()) {
|
||||||
ALuint source = *it;
|
ALuint source = *it;
|
||||||
bool remove = false;
|
bool remove = false;
|
||||||
// Check
|
// Check
|
||||||
if (source && alIsSource(source)) {
|
if (source && alIsSource(source)) {
|
||||||
// Is Valid Source
|
// Is Valid Source
|
||||||
ALint source_state;
|
ALint source_state;
|
||||||
alGetSourcei(source, AL_SOURCE_STATE, &source_state);
|
alGetSourcei(source, AL_SOURCE_STATE, &source_state);
|
||||||
AL_ERROR_CHECK();
|
|
||||||
if (source_state != AL_PLAYING) {
|
|
||||||
// Finished Playing
|
|
||||||
remove = true;
|
|
||||||
alDeleteSources(1, &source);
|
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
|
if (source_state != AL_PLAYING) {
|
||||||
|
// Finished Playing
|
||||||
|
remove = true;
|
||||||
|
alDeleteSources(1, &source);
|
||||||
|
AL_ERROR_CHECK();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Not A Source
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
// Remove If Needed
|
||||||
|
if (remove) {
|
||||||
|
it = get_sources().erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Not A Source
|
|
||||||
remove = true;
|
|
||||||
}
|
|
||||||
// Remove If Needed
|
|
||||||
if (remove) {
|
|
||||||
it = get_sources().erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void media_audio_play(const char *source, const char *name, float x, float y, float z, float pitch, float volume, int is_ui) {
|
void media_audio_play(const char *source, const char *name, float x, float y, float z, float pitch, float volume, int is_ui) {
|
||||||
// Load Sound
|
// Check
|
||||||
ALuint buffer = _media_audio_get_buffer(source, name);
|
if (_media_audio_is_loaded()) {
|
||||||
if (volume > 0.0f && buffer) {
|
// Load Sound
|
||||||
// Create Source
|
ALuint buffer = _media_audio_get_buffer(source, name);
|
||||||
ALuint al_source;
|
if (volume > 0.0f && buffer) {
|
||||||
alGenSources(1, &al_source);
|
// Create Source
|
||||||
AL_ERROR_CHECK();
|
ALuint al_source;
|
||||||
|
alGenSources(1, &al_source);
|
||||||
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Set Properties
|
// Set Properties
|
||||||
alSourcef(al_source, AL_PITCH, pitch);
|
alSourcef(al_source, AL_PITCH, pitch);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSourcef(al_source, AL_GAIN, volume);
|
alSourcef(al_source, AL_GAIN, volume);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSource3f(al_source, AL_POSITION, x, y, z);
|
alSource3f(al_source, AL_POSITION, x, y, z);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSource3f(al_source, AL_VELOCITY, 0, 0, 0);
|
alSource3f(al_source, AL_VELOCITY, 0, 0, 0);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSourcei(al_source, AL_LOOPING, AL_FALSE);
|
alSourcei(al_source, AL_LOOPING, AL_FALSE);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSourcei(al_source, AL_SOURCE_RELATIVE, is_ui ? AL_TRUE : AL_FALSE);
|
alSourcei(al_source, AL_SOURCE_RELATIVE, is_ui ? AL_TRUE : AL_FALSE);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Set Attenuation
|
// Set Attenuation
|
||||||
alSourcei(al_source, AL_DISTANCE_MODEL, AL_LINEAR_DISTANCE);
|
alSourcei(al_source, AL_DISTANCE_MODEL, AL_LINEAR_DISTANCE);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSourcef(al_source, AL_MAX_DISTANCE, 16.0f);
|
alSourcef(al_source, AL_MAX_DISTANCE, 16.0f);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSourcef(al_source, AL_ROLLOFF_FACTOR, 1.0f);
|
alSourcef(al_source, AL_ROLLOFF_FACTOR, 1.0f);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
alSourcef(al_source, AL_REFERENCE_DISTANCE, 0.0f);
|
alSourcef(al_source, AL_REFERENCE_DISTANCE, 0.0f);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Set Buffer
|
// Set Buffer
|
||||||
alSourcei(al_source, AL_BUFFER, buffer);
|
alSourcei(al_source, AL_BUFFER, buffer);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
|
|
||||||
// Play
|
// Play
|
||||||
alSourcePlay(al_source);
|
alSourcePlay(al_source);
|
||||||
AL_ERROR_CHECK();
|
AL_ERROR_CHECK();
|
||||||
get_sources().push_back(al_source);
|
get_sources().push_back(al_source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,6 @@ static void *read_stdin_thread(__attribute__((unused)) void *data) {
|
|||||||
stdin_buffer = strdup("");
|
stdin_buffer = strdup("");
|
||||||
}
|
}
|
||||||
stdin_buffer_complete = true;
|
stdin_buffer_complete = true;
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
string_append((char **) &stdin_buffer, "%c", (char) x);
|
string_append((char **) &stdin_buffer, "%c", (char) x);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user