[AD] Fullscreen programs losing palette under Windows |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Under Windows, when an 8-bit fullscreen program is tabbed away from,
then tabbed back to, it loses it's palette.
A potential fix is attached.
Index: src/win/wddfull.c
===================================================================
--- src/win/wddfull.c (revision 7876)
+++ src/win/wddfull.c (working copy)
@@ -24,6 +24,7 @@
static struct BITMAP *init_directx_safe(int w, int h, int v_w, int v_h, int color_depth);
static void finalize_fullscreen_init(void);
static void switch_in_fullscreen(void);
+static void switch_out_fullscreen(void);
GFX_DRIVER gfx_directx_accel =
@@ -148,7 +149,7 @@
{
FALSE, // true if driver has backing store
switch_in_fullscreen,
- NULL, // AL_METHOD(void, switch_out, (void));
+ switch_out_fullscreen,
NULL, // AL_METHOD(void, enter_sysmode, (void));
NULL, // AL_METHOD(void, exit_sysmode, (void));
NULL, // AL_METHOD(void, move, (int x, int y, int w, int h));
@@ -157,7 +158,14 @@
};
+/*
+ * When switching away from an 8-bit fullscreen program,
+ * the palette is lost. This stores the palette so it
+ * can be restored when switching back in.
+ */
+static PALETTE saved_palette;
+
/* init_directx_accel:
* Initializes the DirectDraw fullscreen hardware-accelerated driver.
*/
@@ -249,5 +257,17 @@
static void switch_in_fullscreen(void)
{
restore_all_ddraw_surfaces();
+ if (_color_depth == 8)
+ set_palette(saved_palette);
}
+
+/* switch_out_fullscreen:
+ * Handles screen switched out.
+ */
+static void switch_out_fullscreen(void)
+{
+ if (_color_depth == 8)
+ get_palette(saved_palette);
+}
+