16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

build 180805. minor bug fixes

This commit is contained in:
tmj-fstate
2018-08-05 13:22:21 +02:00
parent 9830e6c15e
commit 47d8944d17
8 changed files with 23 additions and 12 deletions

View File

@@ -44,10 +44,16 @@ openal_source::play() {
::alGetError(); // pop the error stack ::alGetError(); // pop the error stack
::alSourcePlay( id ); ::alSourcePlay( id );
ALint state;
::alGetSourcei( id, AL_SOURCE_STATE, &state );
is_playing = ( state == AL_PLAYING );
/*
is_playing = ( is_playing = (
::alGetError() == AL_NO_ERROR ? ::alGetError() == AL_NO_ERROR ?
true : true :
false ); false );
*/
} }
// stops the playback // stops the playback
@@ -78,14 +84,17 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity
if( id != audio::null_resource ) { if( id != audio::null_resource ) {
sound_change = false;
::alGetSourcei( id, AL_BUFFERS_PROCESSED, &sound_index ); ::alGetSourcei( id, AL_BUFFERS_PROCESSED, &sound_index );
// for multipart sounds trim away processed sources until only one remains, the last one may be set to looping by the controller // for multipart sounds trim away processed sources until only one remains, the last one may be set to looping by the controller
// TBD, TODO: instead of change flag move processed buffer ids to separate queue, for accurate tracking of longer buffer sequences
ALuint bufferid; ALuint bufferid;
while( ( sound_index > 0 ) while( ( sound_index > 0 )
&& ( sounds.size() > 1 ) ) { && ( sounds.size() > 1 ) ) {
::alSourceUnqueueBuffers( id, 1, &bufferid ); ::alSourceUnqueueBuffers( id, 1, &bufferid );
sounds.erase( std::begin( sounds ) ); sounds.erase( std::begin( sounds ) );
--sound_index; --sound_index;
sound_change = true;
} }
int state; int state;

View File

@@ -50,6 +50,7 @@ struct openal_source {
uint32_sequence sounds; // uint32_sequence sounds; //
// buffer_sequence buffers; // sequence of samples the source will emit // buffer_sequence buffers; // sequence of samples the source will emit
int sound_index { 0 }; // currently queued sample from the buffer sequence int sound_index { 0 }; // currently queued sample from the buffer sequence
bool sound_change { false }; // indicates currently queued sample has changed
bool is_playing { false }; bool is_playing { false };
bool is_looping { false }; bool is_looping { false };
sound_properties properties; sound_properties properties;

View File

@@ -16,6 +16,7 @@ driverkeyboard_input::init() {
default_bindings(); default_bindings();
recall_bindings(); recall_bindings();
bind(); bind();
m_bindingsetups.clear();
return true; return true;
} }

View File

@@ -344,7 +344,7 @@ driver_mode::on_key( int const Key, int const Scancode, int const Action, int co
} }
} }
if( Action == GLFW_PRESS ) { if( Action != GLFW_RELEASE ) {
OnKeyDown( Key ); OnKeyDown( Key );

View File

@@ -17,6 +17,8 @@ editorkeyboard_input::init() {
// TODO: re-enable after mode-specific binding import is in place // TODO: re-enable after mode-specific binding import is in place
// return recall_bindings(); // return recall_bindings();
bind(); bind();
m_bindingsetups.clear();
return true; return true;
} }

View File

@@ -87,7 +87,7 @@ keyboard_input::recall_bindings() {
if( bindingkeyname == "shift" ) { binding |= keymodifier::shift; } if( bindingkeyname == "shift" ) { binding |= keymodifier::shift; }
else if( bindingkeyname == "ctrl" ) { binding |= keymodifier::control; } else if( bindingkeyname == "ctrl" ) { binding |= keymodifier::control; }
else if( bindingkeyname == "none" ) { binding = -1; } else if( bindingkeyname == "none" ) { binding = 0; }
else { else {
// regular key, convert it to glfw key code // regular key, convert it to glfw key code
auto const keylookup = nametokeymap.find( bindingkeyname ); auto const keylookup = nametokeymap.find( bindingkeyname );
@@ -143,10 +143,10 @@ keyboard_input::key( int const Key, int const Action ) {
true ); true );
} }
if( Key == -1 ) { return false; }
// store key state // store key state
if( Key != -1 ) { input::keys[ Key ] = Action;
input::keys[ Key ] = Action;
}
if( true == is_movement_key( Key ) ) { if( true == is_movement_key( Key ) ) {
// if the received key was one of movement keys, it's been handled and we don't need to bother further // if the received key was one of movement keys, it's been handled and we don't need to bother further
@@ -187,7 +187,7 @@ keyboard_input::bind() {
for( auto const &bindingsetup : m_bindingsetups ) { for( auto const &bindingsetup : m_bindingsetups ) {
m_bindings[ bindingsetup.binding ] = bindingsetup.command; m_bindings[ bindingsetup.binding ] = bindingsetup.command;
} }
// cache movement key bindings // cache movement key bindings
m_bindingscache.forward = binding( user_command::moveforward ); m_bindingscache.forward = binding( user_command::moveforward );

View File

@@ -533,9 +533,8 @@ sound_source::update_basic( audio::openal_source &Source ) {
if( sound( sound_id::begin ).buffer != null_handle ) { if( sound( sound_id::begin ).buffer != null_handle ) {
// potentially a multipart sound // potentially a multipart sound
// detect the moment when the sound moves from startup sample to the main // detect the moment when the sound moves from startup sample to the main
if( ( false == Source.is_looping ) if( true == Source.sound_change ) {
&& ( soundhandle == sound_id::main ) ) { // when it happens update active sample counters, and potentially activate the looping
// when it happens update active sample counters, and activate the looping
update_counter( sound_id::begin, -1 ); update_counter( sound_id::begin, -1 );
update_counter( soundhandle, 1 ); update_counter( soundhandle, 1 );
Source.loop( TestFlag( m_flags, sound_flags::looping ) ); Source.loop( TestFlag( m_flags, sound_flags::looping ) );
@@ -618,8 +617,7 @@ sound_source::update_combined( audio::openal_source &Source ) {
if( sound( sound_id::begin ).buffer != null_handle ) { if( sound( sound_id::begin ).buffer != null_handle ) {
// potentially a multipart sound // potentially a multipart sound
// detect the moment when the sound moves from startup sample to the main // detect the moment when the sound moves from startup sample to the main
if( ( false == Source.is_looping ) if( true == Source.sound_change ) {
&& ( soundhandle == ( sound_id::chunk | 0 ) ) ) {
// when it happens update active sample counters, and activate the looping // when it happens update active sample counters, and activate the looping
update_counter( sound_id::begin, -1 ); update_counter( sound_id::begin, -1 );
update_counter( soundhandle, 1 ); update_counter( soundhandle, 1 );

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 18 #define VERSION_MAJOR 18
#define VERSION_MINOR 804 #define VERSION_MINOR 805
#define VERSION_REVISION 0 #define VERSION_REVISION 0