TETRIS: only change textures in the main thread
This commit is contained in:
+10
-6
@@ -308,7 +308,7 @@ prepareOptionsScene( std::shared_ptr< SDLPP::Renderer > renderer ) {
|
||||
void handleKeyDownMain( SDL_Keycode key, SDLPP::Scene &scene ) {
|
||||
switch ( key ) {
|
||||
case SDLK_ESCAPE:
|
||||
g_menu_scene->updateSizeAndPosition();
|
||||
g_update_scenes.push_back( g_menu_scene );
|
||||
g_active_scenes.push_back( g_menu_scene );
|
||||
g_input_functions.push_back( menuSceneInput );
|
||||
break;
|
||||
@@ -422,7 +422,7 @@ void pollEventsMain( SDLPP::Scene &scene ) {
|
||||
case SDL_WINDOWEVENT:
|
||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||
for ( auto &x : g_active_scenes )
|
||||
x->updateSizeAndPosition();
|
||||
g_update_scenes.push_back(x);
|
||||
g_update_size = true;
|
||||
}
|
||||
default:
|
||||
@@ -523,7 +523,7 @@ void handleKeyDownMenu( SDL_Keycode key ) {
|
||||
g_input_functions.pop_back();
|
||||
} break;
|
||||
case MAIN_MENU_OPTIONS:
|
||||
g_options_scene->updateSizeAndPosition();
|
||||
g_update_scenes.push_back(g_options_scene);
|
||||
g_active_scenes.push_back( g_options_scene );
|
||||
g_input_functions.push_back( optionsSceneInput );
|
||||
break;
|
||||
@@ -554,7 +554,7 @@ void pollEventsMenu() {
|
||||
case SDL_WINDOWEVENT:
|
||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||
for ( auto &x : g_active_scenes )
|
||||
x->updateSizeAndPosition();
|
||||
g_update_scenes.push_back(x);
|
||||
g_update_size = true;
|
||||
}
|
||||
default:
|
||||
@@ -625,7 +625,7 @@ void pollEventsGameOver() {
|
||||
case SDL_WINDOWEVENT:
|
||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||
for ( auto &x : g_active_scenes )
|
||||
x->updateSizeAndPosition();
|
||||
g_update_scenes.push_back(x);
|
||||
g_update_size = true;
|
||||
}
|
||||
default:
|
||||
@@ -693,6 +693,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
g_options_options[OPTIONS_MENU_SHADOW].get() )
|
||||
->changeText( std::string( "Show shadow: " ) +
|
||||
( g_show_shadow ? "YES" : "NO" ) );
|
||||
g_update_objects.push_back(g_options_options[OPTIONS_MENU_SHADOW]);
|
||||
break;
|
||||
case OPTIONS_MENU_3D:
|
||||
g_show_3d = !g_show_3d;
|
||||
@@ -700,6 +701,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
g_options_options[OPTIONS_MENU_3D].get() )
|
||||
->changeText( std::string( "Show block texture: " ) +
|
||||
( g_show_3d ? "YES" : "NO" ) );
|
||||
g_update_objects.push_back(g_options_options[OPTIONS_MENU_3D]);
|
||||
g_update_3d = true;
|
||||
default:
|
||||
break;
|
||||
@@ -724,6 +726,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
g_options_options[OPTIONS_MENU_SHADOW].get() )
|
||||
->changeText( std::string( "Show shadow: " ) +
|
||||
( g_show_shadow ? "YES" : "NO" ) );
|
||||
g_update_objects.push_back(g_options_options[OPTIONS_MENU_SHADOW]);
|
||||
break;
|
||||
case OPTIONS_MENU_3D:
|
||||
g_show_3d = !g_show_3d;
|
||||
@@ -731,6 +734,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
g_options_options[OPTIONS_MENU_3D].get() )
|
||||
->changeText( std::string( "Show block texture: " ) +
|
||||
( g_show_3d ? "YES" : "NO" ) );
|
||||
g_update_objects.push_back(g_options_options[OPTIONS_MENU_3D]);
|
||||
g_update_3d = true;
|
||||
default:
|
||||
break;
|
||||
@@ -770,7 +774,7 @@ void pollEventsOptions() {
|
||||
case SDL_WINDOWEVENT:
|
||||
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
|
||||
for ( auto &x : g_active_scenes )
|
||||
x->updateSizeAndPosition();
|
||||
g_update_scenes.push_back(x);
|
||||
g_update_size = true;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user