shithub: m8c

Download patch

ref: 6aa48d6e0f993dd4adc35aaa5a41b220e0652cc7
parent: ea502a43ed577ca36f35b737281f7c531159ea1c
author: laamaa <jonne.kokkonen@gmail.com>
date: Tue Sep 9 18:04:50 EDT 2025

render settings texture to main/hd texture instead of direct window

--- a/src/input.c
+++ b/src/input.c
@@ -176,7 +176,7 @@
   }
 
   if (event->key.key == SDLK_RETURN && (event->key.mod & SDL_KMOD_ALT) > 0) {
-    toggle_fullscreen();
+    toggle_fullscreen(&ctx->conf);
     return;
   }
   if (event->key.key == SDLK_F4 && (event->key.mod & SDL_KMOD_ALT) > 0) {
--- a/src/render.c
+++ b/src/render.c
@@ -127,12 +127,14 @@
     SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't create HD texture: %s", SDL_GetError());
   }
 
-  // Optionally, set a linear scaling mode for smoother rendering
+  // Set a linear scaling mode for smoother rendering
   if (!SDL_SetTextureScaleMode(hd_texture, SDL_SCALEMODE_LINEAR)) {
     SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't set HD texture scale mode: %s",
                     SDL_GetError());
   }
 
+  SDL_SetTextureBlendMode(hd_texture,SDL_BLENDMODE_BLEND);
+
   setup_hd_texture_scaling();
 }
 
@@ -390,11 +392,11 @@
   SDL_DestroyWindow(win);
 }
 
-void toggle_fullscreen(void) {
+int toggle_fullscreen(config_params_s *conf) {
 
   const unsigned long fullscreen_state = SDL_GetWindowFlags(win) & SDL_WINDOW_FULLSCREEN;
-
   SDL_SetWindowFullscreen(win, fullscreen_state ? false : true);
+  conf->init_fullscreen = (unsigned int)!fullscreen_state;
   SDL_SyncWindow(win);
   if (fullscreen_state) {
     // Show cursor when in a windowed state
@@ -404,6 +406,7 @@
   }
 
   dirty = 1;
+  return (int)conf->init_fullscreen;
 }
 
 int draw_character(struct draw_character_command *command) {
@@ -640,6 +643,25 @@
   }
 
   if (conf->integer_scaling) {
+    SDL_SetRenderTarget(rend, main_texture);
+    // Ensure the log overlay is up to date, then composite it if visible before present
+    if (log_overlay_visible) {
+      render_log_overlay_texture();
+      if (log_texture) {
+        if (!SDL_RenderTexture(rend, log_texture, NULL, NULL)) {
+          SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't render log overlay texture to HD texture: %s",
+                        SDL_GetError());
+        }
+      }
+    }
+
+    // Settings overlay composited last
+    if (settings_is_open()) {
+      settings_render_overlay(rend, conf, texture_width, texture_height);
+    }
+
+    SDL_SetRenderTarget(rend, NULL);
+
     // Direct rendering with integer scaling
     if (!SDL_RenderTexture(rend, main_texture, NULL, NULL)) {
       SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't render texture: %s", SDL_GetError());
@@ -677,8 +699,24 @@
     if (!SDL_RenderTexture(rend, main_texture, NULL, NULL)) {
       SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't render main texture to HD texture: %s",
                       SDL_GetError());
-    };
+    }
 
+    // Ensure the log overlay is up to date, then composite it if visible before present
+    if (log_overlay_visible) {
+      render_log_overlay_texture();
+      if (log_texture) {
+        if (!SDL_RenderTexture(rend, log_texture, NULL, NULL)) {
+          SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't render log overlay texture to HD texture: %s",
+                        SDL_GetError());
+        }
+      }
+    }
+
+    // Settings overlay composited last
+    if (settings_is_open()) {
+      settings_render_overlay(rend, conf, texture_width, texture_height);
+    }
+
     // Switch the render target back to the window
     if (!SDL_SetRenderTarget(rend, NULL)) {
       SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Couldn't reset render target to window: %s",
@@ -709,19 +747,6 @@
       // Window and texture aspect ratios match
       SDL_RenderTexture(rend, hd_texture, NULL, NULL);
     }
-  }
-
-  // Ensure log overlay is up to date, then composite it if visible before present
-  if (log_overlay_visible) {
-    render_log_overlay_texture();
-    if (log_texture) {
-      SDL_RenderTexture(rend, log_texture, NULL, NULL);
-    }
-  }
-
-  // Settings overlay composited last
-  if (settings_is_open()) {
-    settings_render_overlay(rend, conf, texture_width, texture_height);
   }
 
   if (!SDL_RenderPresent(rend)) {
--- a/src/render.h
+++ b/src/render.h
@@ -22,7 +22,7 @@
 void set_m8_model(unsigned int model);
 
 void render_screen(config_params_s *conf);
-void toggle_fullscreen(void);
+int toggle_fullscreen(config_params_s *conf);
 void display_keyjazz_overlay(uint8_t show, uint8_t base_octave, uint8_t velocity);
 
 void show_error_message(const char *message);
--- a/src/settings.c
+++ b/src/settings.c
@@ -199,8 +199,8 @@
     unsigned int *val = it->target;
     *val = *val ? 0 : 1;
     if (it->target == &conf->init_fullscreen) {
-      extern void toggle_fullscreen(void);
-      toggle_fullscreen();
+      extern int toggle_fullscreen(config_params_s *config);
+      toggle_fullscreen(conf);
     }
     if (it->target == &conf->integer_scaling) {
       extern void renderer_fix_texture_scaling_after_window_resize(config_params_s * config);
--