Merge branch 'Saturn-Next' into dsdacol
This commit is contained in:
commit
3de4c7cbad
5 files changed
+76
-62
No files matched your search
+1
-1
@@ -53,7 +53,7 @@ r_data.c
|
||||
r_draw.c
|
||||
r_fps.cpp
|
||||
r_main.cpp
|
||||
r_patch.c
|
||||
r_patch.cpp
|
||||
r_patchrotation.c
|
||||
r_plane.cpp
|
||||
r_segs.cpp
|
||||
|
||||
@@ -5332,7 +5332,9 @@ static void HWR_SetTransformAiming(FTransform *trans)
|
||||
if (cv_glshearing.value)
|
||||
{
|
||||
fixed_t fixedaiming = AIMINGTODY(aimingangle);
|
||||
trans->viewaiming = FixedToFloat(fixedaiming);
|
||||
trans->viewaiming = FixedToFloat(fixedaiming) * ((float)vid.width / vid.height) / ((float)BASEVIDWIDTH / BASEVIDHEIGHT);
|
||||
if (splitscreen == 1) // only for 2 player splitscreen
|
||||
trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
|
||||
trans->shearing = true;
|
||||
gl_aimingangle = 0;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "r_skins.h"
|
||||
#include "z_zone.h"
|
||||
#include "w_wad.h"
|
||||
#include <vector>
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_glob.h"
|
||||
@@ -37,7 +38,7 @@ static void R_ParseSpriteInfoFrame(spriteinfo_t *info)
|
||||
UINT8 frameFrame = 0xFF;
|
||||
INT16 frameXPivot = 0;
|
||||
INT16 frameYPivot = 0;
|
||||
rotaxis_t frameRotAxis = 0;
|
||||
rotaxis_t frameRotAxis = ROTAXIS_X;
|
||||
|
||||
// Sprite identifier
|
||||
sprinfoToken = M_GetToken(NULL);
|
||||
@@ -158,14 +159,14 @@ static void R_ParseSpriteInfo(boolean spr2)
|
||||
I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName);
|
||||
if (!memcmp(newSpriteName,sprnames[i],4))
|
||||
{
|
||||
sprnum = i;
|
||||
sprnum = static_cast<spritenum_t>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// allocate a spriteinfo
|
||||
info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
|
||||
info = static_cast<spriteinfo_t*>(Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL));
|
||||
info->available = true;
|
||||
|
||||
// Left Curly Brace
|
||||
@@ -329,7 +330,7 @@ void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps)
|
||||
|
||||
patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
|
||||
{
|
||||
patch_t *patch = (dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_PATCH, NULL) : (patch_t *)(dest);
|
||||
patch_t *patch = static_cast<patch_t*>((dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_PATCH, NULL) : dest);
|
||||
|
||||
if (source)
|
||||
{
|
||||
@@ -341,7 +342,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
|
||||
patch->height = SHORT(source->height);
|
||||
patch->leftoffset = SHORT(source->leftoffset);
|
||||
patch->topoffset = SHORT(source->topoffset);
|
||||
patch->columnofs = Z_Calloc(size, PU_PATCH_DATA, NULL);
|
||||
patch->columnofs = static_cast<INT32*>(Z_Calloc(size, PU_PATCH_DATA, NULL));
|
||||
|
||||
for (col = 0; col < source->width; col++)
|
||||
{
|
||||
@@ -357,7 +358,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
|
||||
if (colsize <= 0)
|
||||
I_Error("Patch_Create: no column data!");
|
||||
|
||||
patch->columns = Z_Calloc(colsize, PU_PATCH_DATA, NULL);
|
||||
patch->columns = static_cast<UINT8*>(Z_Calloc(colsize, PU_PATCH_DATA, NULL));
|
||||
M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize);
|
||||
}
|
||||
|
||||
@@ -429,8 +430,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
|
||||
{
|
||||
if (!patch->hardware)
|
||||
{
|
||||
GLPatch_t *glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware);
|
||||
glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap);
|
||||
GLPatch_t *glPatch = static_cast<GLPatch_t*>(Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware));
|
||||
glPatch->mipmap = static_cast<GLMipmap_t*>(Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap));
|
||||
}
|
||||
return (void *)(patch->hardware);
|
||||
}
|
||||
@@ -448,7 +449,8 @@ void *Patch_CreateGL(patch_t *patch)
|
||||
}
|
||||
#endif // HWRENDER
|
||||
|
||||
static UINT8 *imgbuf = NULL;
|
||||
// 1 MB should be enough for most cases
|
||||
static std::vector<UINT8> imgbuf(1024 * 1024);
|
||||
|
||||
//
|
||||
// R_MaskedFlatToPatch
|
||||
@@ -458,17 +460,27 @@ static UINT8 *imgbuf = NULL;
|
||||
void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize)
|
||||
{
|
||||
INT16 x, y;
|
||||
UINT8 *img;
|
||||
UINT8 *img, *imgptr;
|
||||
UINT8 *colpointers, *startofspan;
|
||||
size_t size = 0;
|
||||
|
||||
if (!raw)
|
||||
return NULL;
|
||||
|
||||
if (!imgbuf)
|
||||
imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL);
|
||||
// Allocate a staging buffer with the maximum size needed for a patch of the same size as the input.
|
||||
|
||||
UINT8 *imgptr = imgbuf;
|
||||
// round up to nearest multiple of 254-pixel posts, plus 1 more 254-pixel post for paranoia reasons
|
||||
size_t maxcolumnsize = (2 + (height - 1) / 256) * 256;
|
||||
// the patch header, and width columns of the max column size
|
||||
size_t maxoutsize = maxcolumnsize * width + (8 + 4 * width);
|
||||
// so, a 512x512 flat should maximally need 393,760 (384.53 KiB) bytes.
|
||||
// quite a bit smaller than 64 megabytes, and much less annoying to the windows debug allocator!
|
||||
while (imgbuf.size() < maxoutsize)
|
||||
{
|
||||
imgbuf.resize(imgbuf.size() * 2);
|
||||
}
|
||||
|
||||
imgptr = imgbuf.data();
|
||||
|
||||
// Write image size and offset
|
||||
WRITEINT16(imgptr, width);
|
||||
@@ -488,7 +500,7 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
|
||||
startofspan = NULL;
|
||||
|
||||
// Write column pointer
|
||||
WRITEINT32(colpointers, imgptr - imgbuf);
|
||||
WRITEINT32(colpointers, imgptr - imgbuf.data());
|
||||
|
||||
// Write pixels
|
||||
for (y = 0; y < height; y++)
|
||||
@@ -557,9 +569,9 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
|
||||
WRITEUINT8(imgptr, 0xFF);
|
||||
}
|
||||
|
||||
size = imgptr-imgbuf;
|
||||
img = Z_Malloc(size, PU_STATIC, NULL);
|
||||
memcpy(img, imgbuf, size);
|
||||
size = imgptr-imgbuf.data();
|
||||
img = static_cast<UINT8*>(Z_Malloc(size, PU_STATIC, NULL));
|
||||
memcpy(img, imgbuf.data(), size);
|
||||
|
||||
if (destsize != NULL)
|
||||
*destsize = size;
|
||||
@@ -582,17 +594,27 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
|
||||
void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize)
|
||||
{
|
||||
INT16 x, y;
|
||||
UINT8 *img;
|
||||
UINT8 *img, *imgptr;
|
||||
UINT8 *colpointers, *startofspan;
|
||||
size_t size = 0;
|
||||
|
||||
if (!raw)
|
||||
return NULL;
|
||||
|
||||
if (!imgbuf)
|
||||
imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL);
|
||||
// Allocate a staging buffer with the maximum size needed for a patch of the same size as the input.
|
||||
|
||||
UINT8 *imgptr = imgbuf;
|
||||
// round up to nearest multiple of 254-pixel posts, plus 1 more 254-pixel post for paranoia reasons
|
||||
size_t maxcolumnsize = (2 + (height - 1) / 256) * 256;
|
||||
// the patch header, and width columns of the max column size
|
||||
size_t maxoutsize = maxcolumnsize * width + (8 + 4 * width);
|
||||
// so, a 512x512 flat should maximally need 393,760 (384.53 KiB) bytes.
|
||||
// quite a bit smaller than 64 megabytes, and much less annoying to the windows debug allocator!
|
||||
while (imgbuf.size() < maxoutsize)
|
||||
{
|
||||
imgbuf.resize(imgbuf.size() * 2);
|
||||
}
|
||||
|
||||
imgptr = imgbuf.data();
|
||||
|
||||
// Write image size and offset
|
||||
WRITEINT16(imgptr, width);
|
||||
@@ -612,7 +634,7 @@ void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffs
|
||||
startofspan = NULL;
|
||||
|
||||
// Write column pointer
|
||||
WRITEINT32(colpointers, imgptr - imgbuf);
|
||||
WRITEINT32(colpointers, imgptr - imgbuf.data());
|
||||
|
||||
// Write pixels
|
||||
for (y = 0; y < height; y++)
|
||||
@@ -682,9 +704,9 @@ void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffs
|
||||
WRITEUINT8(imgptr, 0xFF);
|
||||
}
|
||||
|
||||
size = imgptr-imgbuf;
|
||||
img = Z_Malloc(size, PU_STATIC, NULL);
|
||||
memcpy(img, imgbuf, size);
|
||||
size = imgptr-imgbuf.data();
|
||||
img = static_cast<UINT8*>(Z_Malloc(size, PU_STATIC, NULL));
|
||||
memcpy(img, imgbuf.data(), size);
|
||||
|
||||
if (destsize != NULL)
|
||||
*destsize = size;
|
||||
@@ -14,6 +14,10 @@
|
||||
#ifndef __R_PATCH__
|
||||
#define __R_PATCH__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "r_defs.h"
|
||||
|
||||
// Structs
|
||||
@@ -63,4 +67,8 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
|
||||
UINT16 R_GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip);
|
||||
void R_PatchToPixels(patch_t *patch, UINT8 *dst); // Important: dst must have enough space for patch->width*patch->height pixels!
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // __R_PATCH__
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "r_patchrotation.h"
|
||||
#include "z_zone.h"
|
||||
#include "w_wad.h"
|
||||
#include <vector>
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
//
|
||||
@@ -89,14 +90,14 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri
|
||||
RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip);
|
||||
}
|
||||
|
||||
return rotsprite->patches[idx];
|
||||
return static_cast<patch_t*>(rotsprite->patches[idx]);
|
||||
}
|
||||
|
||||
rotsprite_t *RotatedPatch_Create(INT32 numangles)
|
||||
{
|
||||
rotsprite_t *rotsprite = Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL);
|
||||
rotsprite_t *rotsprite = static_cast<rotsprite_t*>(Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL));
|
||||
rotsprite->angles = numangles;
|
||||
rotsprite->patches = Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL);
|
||||
rotsprite->patches = static_cast<void**>(Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL));
|
||||
return rotsprite;
|
||||
}
|
||||
|
||||
@@ -118,30 +119,8 @@ static void RotatedPatch_CalculateDimensions(
|
||||
h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2)));
|
||||
h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2)));
|
||||
|
||||
*newwidth = max(width, max(w1, w2));
|
||||
*newheight = max(height, max(h1, h2));
|
||||
}
|
||||
|
||||
static void RotatedPatch_AllocImgBuf(UINT16 **buf, size_t size, size_t *capacity)
|
||||
{
|
||||
if (!*buf)
|
||||
{
|
||||
*buf = Z_Malloc(*capacity, PU_STATIC, NULL);
|
||||
}
|
||||
|
||||
size_t allocsize = size * sizeof(UINT16);
|
||||
|
||||
// make sure our buffer always fits with what we need
|
||||
if (allocsize > *capacity)
|
||||
{
|
||||
while (*capacity < allocsize)
|
||||
*capacity *= 2;
|
||||
|
||||
Z_Free(*buf);
|
||||
*buf = Z_Malloc(*capacity, PU_STATIC, NULL);
|
||||
}
|
||||
|
||||
//CONS_Printf("RotatedPatch_AllocBuf: Allocated %.2f KB\n", *capacity / 1024.0);
|
||||
*newwidth = std::max(width, std::max(w1, w2));
|
||||
*newheight = std::max(height, std::max(h1, h2));
|
||||
}
|
||||
|
||||
void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip)
|
||||
@@ -149,10 +128,10 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
|
||||
UINT32 i;
|
||||
patch_t *rotated;
|
||||
|
||||
static UINT16 *rawdst = NULL, *rawconv = NULL;
|
||||
static std::vector<UINT16> rawdst(1024 * 1024), rawconv(1024 * 1024); // 1 MB should be enough for most cases
|
||||
|
||||
UINT16 *rawout;
|
||||
size_t size;
|
||||
static size_t dst_capacity = (1024 * 1024), conv_capacity = (1024 * 1024); // 1 MB should be enough for most cases
|
||||
INT32 bflip = (flip != 0x00);
|
||||
|
||||
INT32 width = patch->width;
|
||||
@@ -206,7 +185,10 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
|
||||
if (!size)
|
||||
size = (width * height);
|
||||
|
||||
RotatedPatch_AllocImgBuf(&rawdst, size, &dst_capacity);
|
||||
while (rawdst.size() < size)
|
||||
{
|
||||
rawdst.resize(rawdst.size() * 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
rawdst[i] = 0xFF00;
|
||||
@@ -250,11 +232,11 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
|
||||
|
||||
size = (width * height);
|
||||
|
||||
RotatedPatch_AllocImgBuf(&rawconv, size, &conv_capacity);
|
||||
memset(rawconv, 0, conv_capacity * sizeof(UINT16));
|
||||
rawconv.resize(size);
|
||||
memset(rawconv.data(), 0, size * sizeof(UINT16));
|
||||
|
||||
src = &rawdst[(miny * newwidth) + minx];
|
||||
dest = rawconv;
|
||||
dest = rawconv.data();
|
||||
dy = height;
|
||||
|
||||
while (dy--)
|
||||
@@ -267,14 +249,14 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
|
||||
ox -= minx;
|
||||
oy -= miny;
|
||||
|
||||
rawout = rawconv;
|
||||
rawout = rawconv.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
width = newwidth;
|
||||
height = newheight;
|
||||
|
||||
rawout = rawdst;
|
||||
rawout = rawdst.data();
|
||||
}
|
||||
|
||||
// make patch
|
||||
Reference in new issue
Block a user