Update the canvas data pointers for all windows after changing the screen mode, so the main menu draws properly after leaving the editor

This commit is contained in:
Chris Taylor 2012-03-24 14:43:08 +08:00
parent cd0213122c
commit 8b757570d5
6 changed files with 20 additions and 3 deletions

View file

@ -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);
}

View file

@ -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
--------

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;