Use new/delete for grs_screen

This commit is contained in:
Kp 2014-11-30 22:09:19 +00:00
parent ad35ff421e
commit 0790eda153
4 changed files with 12 additions and 8 deletions

View file

@ -30,7 +30,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "compiler-make_unique.h"
grs_canvas * grd_curcanv; //active canvas
grs_screen * grd_curscreen; //active screen
std::unique_ptr<grs_screen> grd_curscreen; //active screen
grs_canvas_ptr gr_create_canvas(uint16_t w, uint16_t h)
{

View file

@ -146,7 +146,7 @@ struct grs_font : public prohibit_void_ptr<grs_font>
#define GRS_FONT_SIZE 28 // how much space it takes up on disk
struct grs_canvas : public prohibit_void_ptr<grs_canvas>
struct grs_canvas : prohibit_void_ptr<grs_canvas>
{
grs_bitmap cv_bitmap; // the bitmap for this canvas
const grs_font * cv_font; // the currently selected font
@ -158,7 +158,7 @@ struct grs_canvas : public prohibit_void_ptr<grs_canvas>
ubyte cv_blend_func; // blending function to use
};
struct grs_screen : public prohibit_void_ptr<grs_screen>
struct grs_screen : prohibit_void_ptr<grs_screen>
{ // This is a video screen
grs_canvas sc_canvas; // Represents the entire screen
u_int32_t sc_mode; // Video mode number
@ -381,7 +381,7 @@ void scale_bitmap(const grs_bitmap &bp, const array<grs_point, 3> &vertbuf, int
//===========================================================================
// Global variables
extern grs_canvas *grd_curcanv; //active canvas
extern grs_screen *grd_curscreen; //active screen
extern std::unique_ptr<grs_screen> grd_curscreen; //active screen
extern void gr_set_current_canvas( grs_canvas *canv );

View file

@ -72,6 +72,8 @@
#endif
#endif
#include "compiler-make_unique.h"
using std::max;
#ifdef OGLES
@ -769,7 +771,7 @@ int gr_init(int mode)
ogl_init_texture_list_internal();
CALLOC( grd_curscreen,grs_screen,1 );
grd_curscreen = make_unique<grs_screen, grs_screen>({});
grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL;
// Set the mode.
@ -805,7 +807,7 @@ void gr_close()
{
if (grd_curscreen->sc_canvas.cv_bitmap.bm_data)
d_free(grd_curscreen->sc_canvas.cv_bitmap.bm_data);
d_free(grd_curscreen);
grd_curscreen.reset();
}
ogl_close_pixel_buffers();
#ifdef _WIN32

View file

@ -26,6 +26,8 @@
#include "config.h"
#include "palette.h"
#include "compiler-make_unique.h"
int sdl_video_flags = SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
SDL_Surface *screen,*canvas;
int gr_installed = 0;
@ -184,7 +186,7 @@ int gr_init(int mode)
Error("SDL library video initialisation failed: %s.",SDL_GetError());
}
CALLOC( grd_curscreen,grs_screen,1 );
grd_curscreen = make_unique<grs_screen, grs_screen>({});
if (!GameCfg.WindowMode && !GameArg.SysWindow)
sdl_video_flags|=SDL_FULLSCREEN;
@ -221,7 +223,7 @@ void gr_close()
if (gr_installed==1)
{
gr_installed = 0;
d_free(grd_curscreen);
grd_curscreen.reset();
SDL_ShowCursor(1);
SDL_FreeSurface(canvas);
}