From 8b757570d5ca39db9d94b54404f740eca71a55a4 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Sat, 24 Mar 2012 14:43:08 +0800 Subject: [PATCH] Update the canvas data pointers for all windows after changing the screen mode, so the main menu draws properly after leaving the editor --- 2d/bitmap.c | 5 +++-- CHANGELOG.txt | 1 + arch/include/window.h | 1 + arch/sdl/gr.c | 1 + arch/sdl/window.c | 13 +++++++++++++ include/gr.h | 2 +- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/2d/bitmap.c b/2d/bitmap.c index c7c25eb44..c7fe4e3ff 100644 --- a/2d/bitmap.c +++ b/2d/bitmap.c @@ -81,8 +81,9 @@ void gr_init_bitmap_alloc( grs_bitmap *bm, int mode, int x, int y, int w, int h, void gr_init_bitmap_data (grs_bitmap *bm) // TODO: virtulize { bm->bm_data = NULL; + bm->bm_parent=NULL; #ifdef OGL - bm->bm_parent=NULL;bm->gltexture=NULL; + bm->gltexture=NULL; #endif } @@ -134,8 +135,8 @@ void gr_init_sub_bitmap (grs_bitmap *bm, grs_bitmap *bmParent, int x, int y, int #ifdef OGL bm->gltexture=bmParent->gltexture; - bm->bm_parent=bmParent; #endif + bm->bm_parent=bmParent; bm->bm_data = bmParent->bm_data+(unsigned int)((y*bmParent->bm_rowsize)+x); } diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 460f3d19f..72f8717d4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D1X-Rebirth Changelog 20120324 -------- arch/ogl/gr.c, arch/sdl/gr.c, ui/menubar.c: Draw the editor menubar properly - by drawing in response to EVENT_WINDOW_DRAW and initialising the screen canvas properly. The latter fixes a lot of other editor drawing issues as well +2d/bitmap.c, arch/include/window.h, arch/sdl/gr.c, arch/sdl/window.c, include/gr.h: Update the canvas data pointers for all windows after changing the screen mode, so the main menu draws properly after leaving the editor 20120319 -------- diff --git a/arch/include/window.h b/arch/include/window.h index 2ad12e020..14186310b 100644 --- a/arch/include/window.h +++ b/arch/include/window.h @@ -28,6 +28,7 @@ extern void window_select(window *wind); extern void window_set_visible(window *wind, int visible); extern int window_is_visible(window *wind); extern grs_canvas *window_get_canvas(window *wind); +extern void window_update_canvases(void); extern int window_send_event(window *wind, d_event *event); extern void window_set_modal(window *wind, int modal); extern int window_is_modal(window *wind); diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index d92946c43..4658ddadb 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -133,6 +133,7 @@ int gr_set_mode(u_int32_t mode) grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*GameCfg.AspectX,grd_curscreen->sc_h*GameCfg.AspectY); gr_init_canvas(&grd_curscreen->sc_canvas, canvas->pixels, BM_LINEAR, w, h); + window_update_canvases(); gr_set_current_canvas(NULL); SDL_ShowCursor(0); diff --git a/arch/sdl/window.c b/arch/sdl/window.c index bef02aaa5..53ef0859c 100644 --- a/arch/sdl/window.c +++ b/arch/sdl/window.c @@ -192,6 +192,19 @@ grs_canvas *window_get_canvas(window *wind) return &wind->w_canv; } +extern void window_update_canvases(void) +{ + window *wind; + + for (wind = FirstWindow; wind != NULL; wind = wind->next) + gr_init_sub_bitmap (&wind->w_canv.cv_bitmap, + wind->w_canv.cv_bitmap.bm_parent, + wind->w_canv.cv_bitmap.bm_x, + wind->w_canv.cv_bitmap.bm_y, + wind->w_canv.cv_bitmap.bm_w, + wind->w_canv.cv_bitmap.bm_h); +} + int window_send_event(window *wind, d_event *event) { return wind->w_callback(wind, event, wind->data); diff --git a/include/gr.h b/include/gr.h index 68f3642eb..21c4c74a3 100644 --- a/include/gr.h +++ b/include/gr.h @@ -112,9 +112,9 @@ typedef struct _grs_bitmap { ubyte avg_color; // Average color of all pixels in texture map. fix avg_color_rgb[3]; // same as above but real rgb value to be used to textured objects that should emit light sbyte unused; // to 4-byte align. + struct _grs_bitmap *bm_parent; #ifdef OGL struct _ogl_texture *gltexture; - struct _grs_bitmap *bm_parent; #endif /* def OGL */ } grs_bitmap;