mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 22:40:50 +00:00
move render prepere staff to separate function
This commit is contained in:
parent
f1bf4d2b44
commit
8fc5bafb64
2 changed files with 74 additions and 59 deletions
|
@ -327,6 +327,7 @@ R_UnRegister (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SWimp_DestroyRender(void);
|
static void SWimp_DestroyRender(void);
|
||||||
|
static void SWimp_CreateRender(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
|
@ -1500,6 +1501,12 @@ RE_IsVsyncActive(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int RE_PrepareForWindow(void)
|
||||||
|
{
|
||||||
|
int flags = SDL_SWSURFACE;
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
GetRefAPI
|
GetRefAPI
|
||||||
|
@ -1538,6 +1545,7 @@ GetRefAPI(refimport_t imp)
|
||||||
re.Init = RE_Init;
|
re.Init = RE_Init;
|
||||||
re.IsVSyncActive = RE_IsVsyncActive;
|
re.IsVSyncActive = RE_IsVsyncActive;
|
||||||
re.Shutdown = RE_Shutdown;
|
re.Shutdown = RE_Shutdown;
|
||||||
|
re.PrepareForWindow = RE_PrepareForWindow;
|
||||||
|
|
||||||
re.SetPalette = RE_SetPalette;
|
re.SetPalette = RE_SetPalette;
|
||||||
re.BeginFrame = RE_BeginFrame;
|
re.BeginFrame = RE_BeginFrame;
|
||||||
|
@ -1662,6 +1670,15 @@ R_InitContext(SDL_Window *win)
|
||||||
snprintf(title, sizeof(title), "Yamagi Quake II %s - Soft Render", YQ2VERSION);
|
snprintf(title, sizeof(title), "Yamagi Quake II %s - Soft Render", YQ2VERSION);
|
||||||
SDL_SetWindowTitle(window, title);
|
SDL_SetWindowTitle(window, title);
|
||||||
|
|
||||||
|
if (r_vsync->value)
|
||||||
|
{
|
||||||
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
|
}
|
||||||
|
|
||||||
surface = SDL_CreateRGBSurface(0, vid.width, vid.height, bpp, Rmask, Gmask, Bmask, Amask);
|
surface = SDL_CreateRGBSurface(0, vid.width, vid.height, bpp, Rmask, Gmask, Bmask, Amask);
|
||||||
|
|
||||||
texture = SDL_CreateTexture(renderer,
|
texture = SDL_CreateTexture(renderer,
|
||||||
|
@ -1680,14 +1697,6 @@ CreateSDLWindow(int flags, int w, int h)
|
||||||
// TODO: support fullscreen on different displays with SDL_WINDOWPOS_UNDEFINED_DISPLAY(displaynum)
|
// TODO: support fullscreen on different displays with SDL_WINDOWPOS_UNDEFINED_DISPLAY(displaynum)
|
||||||
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos, w, h, flags);
|
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos, w, h, flags);
|
||||||
|
|
||||||
if (r_vsync->value)
|
|
||||||
{
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
|
||||||
}
|
|
||||||
return window != NULL;
|
return window != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1863,7 +1872,7 @@ SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
|
||||||
// let the sound and input subsystems know about the new window
|
// let the sound and input subsystems know about the new window
|
||||||
ri.Vid_NewWindow (vid.width, vid.height);
|
ri.Vid_NewWindow (vid.width, vid.height);
|
||||||
|
|
||||||
flags = SDL_SWSURFACE;
|
flags = RE_PrepareForWindow();
|
||||||
if (fs_flag)
|
if (fs_flag)
|
||||||
{
|
{
|
||||||
flags |= fs_flag;
|
flags |= fs_flag;
|
||||||
|
@ -1895,51 +1904,6 @@ SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
|
||||||
/* No cursor */
|
/* No cursor */
|
||||||
SDL_ShowCursor(0);
|
SDL_ShowCursor(0);
|
||||||
|
|
||||||
vid_buffer = malloc(vid.height * vid.width * sizeof(pixel_t));
|
|
||||||
|
|
||||||
sintable = malloc((vid.width+CYCLE) * sizeof(int));
|
|
||||||
intsintable = malloc((vid.width+CYCLE) * sizeof(int));
|
|
||||||
blanktable = malloc((vid.width+CYCLE) * sizeof(int));
|
|
||||||
|
|
||||||
newedges = malloc(vid.width * sizeof(edge_t *));
|
|
||||||
removeedges = malloc(vid.width * sizeof(edge_t *));
|
|
||||||
|
|
||||||
// 1 extra for spanpackage that marks end
|
|
||||||
triangle_spans = malloc((vid.width + 1) * sizeof(spanpackage_t));
|
|
||||||
|
|
||||||
warp_rowptr = malloc((vid.width+AMP2*2) * sizeof(byte*));
|
|
||||||
warp_column = malloc((vid.width+AMP2*2) * sizeof(int));
|
|
||||||
|
|
||||||
edge_basespans = malloc((vid.width*2) * sizeof(espan_t));
|
|
||||||
|
|
||||||
// count of "out of items"
|
|
||||||
r_outofsurfaces = r_outofedges = r_outofverts = 0;
|
|
||||||
// pointers to allocated buffers
|
|
||||||
finalverts = NULL;
|
|
||||||
r_edges = NULL;
|
|
||||||
lsurfs = NULL;
|
|
||||||
// curently allocated items
|
|
||||||
r_cnumsurfs = r_numallocatededges = r_numallocatedverts = 0;
|
|
||||||
|
|
||||||
R_ReallocateMapBuffers();
|
|
||||||
|
|
||||||
r_warpbuffer = malloc(vid.height * vid.width * sizeof(pixel_t));
|
|
||||||
|
|
||||||
if ((vid.width >= 2048) && (sizeof(shift20_t) == 4)) // 2k+ resolution and 32 == shift20_t
|
|
||||||
{
|
|
||||||
shift_size = 18;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shift_size = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
R_InitTurb ();
|
|
||||||
|
|
||||||
vid_polygon_spans = malloc(sizeof(espan_t) * (vid.height + 1));
|
|
||||||
|
|
||||||
memset(sw_state.currentpalette, 0, sizeof(sw_state.currentpalette));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2029,11 +1993,62 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen )
|
||||||
return rserr_invalid_mode;
|
return rserr_invalid_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
|
SWimp_CreateRender();
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
SWimp_CreateRender(void)
|
||||||
|
{
|
||||||
|
vid_buffer = malloc(vid.height * vid.width * sizeof(pixel_t));
|
||||||
|
|
||||||
|
sintable = malloc((vid.width+CYCLE) * sizeof(int));
|
||||||
|
intsintable = malloc((vid.width+CYCLE) * sizeof(int));
|
||||||
|
blanktable = malloc((vid.width+CYCLE) * sizeof(int));
|
||||||
|
|
||||||
|
newedges = malloc(vid.width * sizeof(edge_t *));
|
||||||
|
removeedges = malloc(vid.width * sizeof(edge_t *));
|
||||||
|
|
||||||
|
// 1 extra for spanpackage that marks end
|
||||||
|
triangle_spans = malloc((vid.width + 1) * sizeof(spanpackage_t));
|
||||||
|
|
||||||
|
warp_rowptr = malloc((vid.width+AMP2*2) * sizeof(byte*));
|
||||||
|
warp_column = malloc((vid.width+AMP2*2) * sizeof(int));
|
||||||
|
|
||||||
|
edge_basespans = malloc((vid.width*2) * sizeof(espan_t));
|
||||||
|
|
||||||
|
// count of "out of items"
|
||||||
|
r_outofsurfaces = r_outofedges = r_outofverts = 0;
|
||||||
|
// pointers to allocated buffers
|
||||||
|
finalverts = NULL;
|
||||||
|
r_edges = NULL;
|
||||||
|
lsurfs = NULL;
|
||||||
|
// curently allocated items
|
||||||
|
r_cnumsurfs = r_numallocatededges = r_numallocatedverts = 0;
|
||||||
|
|
||||||
|
R_ReallocateMapBuffers();
|
||||||
|
|
||||||
|
r_warpbuffer = malloc(vid.height * vid.width * sizeof(pixel_t));
|
||||||
|
|
||||||
|
if ((vid.width >= 2048) && (sizeof(shift20_t) == 4)) // 2k+ resolution and 32 == shift20_t
|
||||||
|
{
|
||||||
|
shift_size = 18;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shift_size = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
R_InitTurb ();
|
||||||
|
|
||||||
|
vid_polygon_spans = malloc(sizeof(espan_t) * (vid.height + 1));
|
||||||
|
|
||||||
|
memset(sw_state.currentpalette, 0, sizeof(sw_state.currentpalette));
|
||||||
|
|
||||||
|
R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
|
||||||
|
}
|
||||||
|
|
||||||
// this is only here so the functions in q_shared.c and q_shwin.c can link
|
// this is only here so the functions in q_shared.c and q_shwin.c can link
|
||||||
void
|
void
|
||||||
Sys_Error (char *error, ...)
|
Sys_Error (char *error, ...)
|
||||||
|
|
|
@ -219,10 +219,10 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only do this if we already have a working window and a fully
|
/* Only do this if we already have a working window and a fully
|
||||||
initialized rendering backend GLimp_InitGraphics() is also
|
initialized rendering backend GLimp_InitGraphics() is also
|
||||||
called when recovering if creating GL context fails or the
|
called when recovering if creating GL context fails or the
|
||||||
one we got is unusable. */
|
one we got is unusable. */
|
||||||
if (initSuccessful && GetWindowSize(&curWidth, &curHeight)
|
if (initSuccessful && GetWindowSize(&curWidth, &curHeight)
|
||||||
&& (curWidth == width) && (curHeight == height))
|
&& (curWidth == width) && (curHeight == height))
|
||||||
{
|
{
|
||||||
/* If we want fullscreen, but aren't */
|
/* If we want fullscreen, but aren't */
|
||||||
|
|
Loading…
Reference in a new issue