Picture formats test

This commit is contained in:
Jaime Passos 2020-01-06 18:22:23 -03:00
parent 0fbc459243
commit a1af6b9134
17 changed files with 703 additions and 346 deletions

View file

@ -123,7 +123,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_sky.c
r_splats.c
r_things.c
r_patch.c
r_picformats.c
r_portal.c
r_bsp.h
@ -138,7 +138,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_splats.h
r_state.h
r_things.h
r_patch.h
r_picformats.h
r_portal.h
)

View file

@ -471,7 +471,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/r_sky.o \
$(OBJDIR)/r_splats.o \
$(OBJDIR)/r_things.o \
$(OBJDIR)/r_patch.o \
$(OBJDIR)/r_picformats.o \
$(OBJDIR)/r_portal.o \
$(OBJDIR)/screen.o \
$(OBJDIR)/v_video.o \

View file

@ -29,7 +29,7 @@
#include "p_setup.h"
#include "r_data.h"
#include "r_draw.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_sky.h"
#include "fastcmp.h"
#include "lua_script.h"

View file

@ -30,7 +30,7 @@
#include "../z_zone.h"
#include "../v_video.h"
#include "../r_draw.h"
#include "../r_patch.h"
#include "../r_picformats.h"
#include "../p_setup.h"
// Values set after a call to HWR_ResizeBlock()

View file

@ -30,7 +30,7 @@
#include "../p_local.h"
#include "../p_setup.h"
#include "../r_local.h"
#include "../r_patch.h"
#include "../r_picformats.h"
#include "../r_bsp.h"
#include "../d_clisrv.h"
#include "../w_wad.h"

View file

@ -18,7 +18,7 @@
#include "p_mobj.h"
#include "p_local.h"
#include "z_zone.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_things.h"
#include "doomstat.h" // luabanks[]

View file

@ -28,7 +28,7 @@
#include "r_data.h"
#include "r_things.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_sky.h"
#include "r_draw.h"
@ -574,6 +574,8 @@ Ploadflat (levelflat_t *levelflat, const char *flatname)
lumpnum_t flatnum;
int texturenum;
patch_t *flatpatch;
size_t lumplength;
size_t i;
@ -635,7 +637,9 @@ texturefound:
{
flatfound:
/* This could be a flat, patch, or PNG. */
if (R_CheckIfPatch(flatnum))
flatpatch = W_CacheLumpNum(flatnum, PU_STATIC);
lumplength = W_LumpLength(flatnum);
if (R_CheckIfPatch(flatpatch, lumplength))
levelflat->type = LEVELFLAT_PATCH;
else
{
@ -644,8 +648,10 @@ flatfound:
Only need eight bytes for PNG headers.
FIXME: Put this elsewhere.
*/
if (flatpatch)
Z_Free(flatpatch);
W_ReadLumpHeader(flatnum, buffer, 8, 0);
if (R_IsLumpPNG(buffer, W_LumpLength(flatnum)))
if (R_IsLumpPNG(buffer, lumplength))
levelflat->type = LEVELFLAT_PNG;
else
#endif/*NO_PNG_LUMPS*/

View file

@ -19,7 +19,7 @@
#include "p_local.h"
#include "m_misc.h"
#include "r_data.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "w_wad.h"
#include "z_zone.h"
#include "p_setup.h" // levelflats

File diff suppressed because it is too large Load diff

View file

@ -1,14 +1,14 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2018-2019 by Jaime "Lactozilla" Passos.
// Copyright (C) 2019 by Sonic Team Junior.
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos.
// Copyright (C) 2019-2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_patch.h
/// \file r_picformats.h
/// \brief Patch generation.
#ifndef __R_PATCH__
@ -17,6 +17,57 @@
#include "r_defs.h"
#include "doomdef.h"
typedef enum
{
PICFMT_NONE = 0,
// Doom formats
PICFMT_PATCH,
PICFMT_FLAT,
// PNG
PICFMT_PNG,
// 16bpp
PICFMT_PATCH16,
PICFMT_FLAT16,
// 32bpp
PICFMT_PATCH32,
PICFMT_FLAT32
} pictureformat_t;
typedef enum
{
PICFLAGS_XFLIP = 1,
PICFLAGS_YFLIP = 1<<1
} pictureflags_t;
void *Picture_Convert(
pictureformat_t informat, void *picture, pictureformat_t outformat,
size_t insize, size_t *outsize,
INT32 inwidth, INT32 inheight, INT32 inleftoffset, INT32 intopoffset,
pictureflags_t flags);
void *Picture_PatchConvert(
pictureformat_t informat, void *picture, pictureformat_t outformat,
size_t insize, size_t *outsize,
INT16 inwidth, INT16 inheight, INT16 inleftoffset, INT16 intopoffset,
pictureflags_t flags);
void *Picture_FlatConvert(
pictureformat_t informat, void *picture, pictureformat_t outformat,
size_t insize, size_t *outsize,
INT16 inwidth, INT16 inheight, INT16 inleftoffset, INT16 intopoffset,
pictureflags_t flags);
void *Picture_GetPatchPixel(
patch_t *patch, pictureformat_t informat,
INT32 x, INT32 y,
pictureflags_t flags);
INT32 Picture_FormatBPP(pictureformat_t format);
boolean Picture_IsPatchFormat(pictureformat_t format);
boolean Picture_IsFlatFormat(pictureformat_t format);
// Structs
#ifdef ROTSPRITE
typedef enum
@ -42,7 +93,7 @@ typedef struct
} spriteinfo_t;
// Conversions between patches / flats / textures...
boolean R_CheckIfPatch(lumpnum_t lump);
boolean R_CheckIfPatch(patch_t *patch, size_t size);
void R_TextureToFlat(size_t tex, UINT8 *flat);
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip);

View file

@ -24,7 +24,7 @@
#include "i_video.h" // rendermode
#include "i_system.h"
#include "r_things.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_plane.h"
#include "r_portal.h"
#include "p_tick.h"

View file

@ -16,7 +16,7 @@
#include "sounds.h"
#include "r_plane.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_portal.h"
#include "r_defs.h"

View file

@ -281,7 +281,7 @@
<ClInclude Include="..\r_local.h" />
<ClInclude Include="..\r_main.h" />
<ClInclude Include="..\r_plane.h" />
<ClInclude Include="..\r_patch.h" />
<ClInclude Include="..\r_picformats.h" />
<ClInclude Include="..\r_portal.h" />
<ClInclude Include="..\r_segs.h" />
<ClInclude Include="..\r_sky.h" />
@ -443,7 +443,7 @@
</ClCompile>
<ClCompile Include="..\r_main.c" />
<ClCompile Include="..\r_plane.c" />
<ClCompile Include="..\r_patch.c" />
<ClCompile Include="..\r_picformats.c" />
<ClCompile Include="..\r_portal.c" />
<ClCompile Include="..\r_segs.c" />
<ClCompile Include="..\r_sky.c" />

View file

@ -465,7 +465,7 @@
<ClInclude Include="..\hardware\hw_clip.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\r_patch.h">
<ClInclude Include="..\r_picformats.h">
<Filter>R_Rend</Filter>
</ClInclude>
<ClInclude Include="..\r_portal.h">
@ -928,7 +928,7 @@
<Filter>Hw_Hardware</Filter>
</ClCompile>
<ClCompile Include="..\apng.c" />
<ClCompile Include="..\r_patch.c">
<ClCompile Include="..\r_picformats.c">
<Filter>R_Rend</Filter>
</ClCompile>
<ClCompile Include="..\r_portal.c">

View file

@ -300,7 +300,7 @@
</ClCompile>
<ClCompile Include="..\r_main.c" />
<ClCompile Include="..\r_plane.c" />
<ClCompile Include="..\r_patch.c" />
<ClCompile Include="..\r_picformats.c" />
<ClCompile Include="..\r_portal.c" />
<ClCompile Include="..\r_segs.c" />
<ClCompile Include="..\r_sky.c" />
@ -456,7 +456,7 @@
<ClInclude Include="..\r_local.h" />
<ClInclude Include="..\r_main.h" />
<ClInclude Include="..\r_plane.h" />
<ClInclude Include="..\r_patch.h" />
<ClInclude Include="..\r_picformats.h" />
<ClInclude Include="..\r_portal.h" />
<ClInclude Include="..\r_segs.h" />
<ClInclude Include="..\r_sky.h" />

View file

@ -472,7 +472,7 @@
<Filter>Hw_Hardware</Filter>
</ClCompile>
<ClCompile Include="..\apng.c" />
<ClCompile Include="..\r_patch.c">
<ClCompile Include="..\r_picformats.c">
<Filter>R_Rend</Filter>
</ClCompile>
<ClCompile Include="..\r_portal.c">
@ -892,7 +892,7 @@
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\apng.h" />
<ClInclude Include="..\r_patch.h">
<ClInclude Include="..\r_picformats.h">
<Filter>R_Rend</Filter>
</ClInclude>
<ClInclude Include="..\r_portal.h">

View file

@ -27,7 +27,7 @@
#include "doomdef.h"
#include "doomstat.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "i_system.h" // I_GetFreeMem
#include "i_video.h" // rendermode
#include "z_zone.h"