grs_canvas_ptr gr_create_canvas(uint16_t w, uint16_t h) { grs_canvas_ptr n = make_unique<grs_main_canvas>(); unsigned char *pixdata; MALLOC(pixdata, unsigned char, MAX_BMP_SIZE(w, h)); gr_init_canvas(*n.get(), pixdata, bm_mode::linear, w, h); return n; }
int gr_set_mode(u_int32_t mode) { unsigned int w, h; char *gr_bm_data; if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); if (!gr_check_mode(mode)) { con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",w,h); w=640; h=480; Game_screen_mode=mode=SM(w,h); } gr_bm_data=(char *)grd_curscreen->sc_canvas.cv_bitmap.bm_data;//since we use realloc, we want to keep this pointer around. memset( grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; 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, d_realloc(gr_bm_data,w*h), BM_OGL, w, h); gr_set_current_canvas(NULL); ogl_init_window(w,h);//platform specific code ogl_get_verinfo(); OGL_VIEWPORT(0,0,w,h); ogl_init_state(); gamefont_choose_game_font(w,h); gr_remap_color_fonts(); gr_remap_mono_fonts(); return 0; }