mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-17 01:21:12 +00:00
soft: support direct copy raw image
This commit is contained in:
parent
642aeedc43
commit
d7b5bfc06f
4 changed files with 51 additions and 6 deletions
|
@ -845,15 +845,16 @@ SCR_DrawCinematic(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (cin_force43->value)
|
||||
if (cin_force43->value && cin.height && cin.width)
|
||||
{
|
||||
w = viddef.height * 4 / 3;
|
||||
/* Try to left original aspect ratio */
|
||||
w = viddef.height * cin.width / cin.height;
|
||||
if (w > viddef.width)
|
||||
{
|
||||
w = viddef.width;
|
||||
}
|
||||
w &= ~3;
|
||||
h = w * 3 / 4;
|
||||
h = w * cin.height / cin.width;
|
||||
x = (viddef.width - w) / 2;
|
||||
y = (viddef.height - h) / 2;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,10 @@ ResizeSTB(const byte *input_pixels, int input_width, int input_height,
|
|||
{
|
||||
if (stbir_resize_uint8_linear(input_pixels, input_width, input_height, 0,
|
||||
output_pixels, output_width, output_height, 0, STBIR_RGBA))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ RE_Draw_StretchRaw
|
|||
=============
|
||||
*/
|
||||
void
|
||||
RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int bits)
|
||||
RE_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *data, int bits)
|
||||
{
|
||||
image_t pic;
|
||||
byte *image_scaled;
|
||||
|
|
|
@ -211,12 +211,14 @@ int cachewidth;
|
|||
pixel_t *d_viewbuffer;
|
||||
zvalue_t *d_pzbuffer;
|
||||
|
||||
static void RE_BeginFrame( float camera_separation );
|
||||
static void RE_BeginFrame(float camera_separation);
|
||||
static void Draw_BuildGammaTable(void);
|
||||
static void RE_FlushFrame(int vmin, int vmax);
|
||||
static void RE_CleanFrame(void);
|
||||
static void RE_EndFrame(void);
|
||||
static void R_DrawBeam(const entity_t *e);
|
||||
static void RE_Draw_StretchDirectRaw(int x, int y, int w, int h,
|
||||
int cols, int rows, const byte *data, int bits);
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -1812,7 +1814,7 @@ GetRefAPI(refimport_t imp)
|
|||
refexport.DrawFill = RE_Draw_Fill;
|
||||
refexport.DrawFadeScreen = RE_Draw_FadeScreen;
|
||||
|
||||
refexport.DrawStretchRaw = RE_Draw_StretchRaw;
|
||||
refexport.DrawStretchRaw = RE_Draw_StretchDirectRaw;
|
||||
|
||||
refexport.Init = RE_Init;
|
||||
refexport.IsVSyncActive = RE_IsVsyncActive;
|
||||
|
@ -2198,6 +2200,45 @@ RE_FlushFrame(int vmin, int vmax)
|
|||
VID_NoDamageBuffer();
|
||||
}
|
||||
|
||||
static void
|
||||
RE_Draw_StretchDirectRaw(int x, int y, int w, int h, int cols, int rows, const byte *data, int bits)
|
||||
{
|
||||
int pitch;
|
||||
Uint32 *pixels;
|
||||
|
||||
if (bits != 32 || x || y ||
|
||||
w != vid_buffer_width || h != vid_buffer_height ||
|
||||
cols != vid_buffer_width || rows != vid_buffer_height)
|
||||
{
|
||||
/* Not full screen update */
|
||||
RE_Draw_StretchRaw(x, y, w, h, cols, rows, data, bits);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Full screen update should be faster */
|
||||
if (SDL_LockTexture(texture, NULL, (void**)&pixels, &pitch))
|
||||
{
|
||||
Com_Printf("Can't lock texture: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
if (pitch != (vid_buffer_width * sizeof(Uint32)))
|
||||
{
|
||||
/* Oops: different texture format? */
|
||||
SDL_UnlockTexture(texture);
|
||||
/* Failback full image convert */
|
||||
RE_Draw_StretchRaw(x, y, w, h, cols, rows, data, bits);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(pixels, data, vid_buffer_width * vid_buffer_height * sizeof(Uint32));
|
||||
|
||||
SDL_UnlockTexture(texture);
|
||||
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
/*
|
||||
** RE_EndFrame
|
||||
**
|
||||
|
|
Loading…
Reference in a new issue