mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-29 07:21:54 +00:00
Merge branch 'master' into whaven
# Conflicts: # source/core/gameinput.h # source/core/version.h # source/games/exhumed/src/enginesubs.cpp # source/games/sw/src/game.cpp
This commit is contained in:
commit
7ba152e588
418 changed files with 28036 additions and 14036 deletions
|
@ -236,7 +236,7 @@ if( MSVC )
|
|||
set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC /MTd" )
|
||||
|
||||
# Disable warnings for unsecure CRT functions from VC8+
|
||||
set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4996 /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600" )
|
||||
set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS" )
|
||||
|
||||
# These must be silenced because the code is full of them. Expect some of undefined behavior hidden in this mess. :(
|
||||
#set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4244 /wd4018 /wd4267" )
|
||||
|
@ -287,7 +287,7 @@ else()
|
|||
|
||||
|
||||
if( APPLE )
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12")
|
||||
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
|
||||
# If we're compiling with a custom GCC on the Mac (which we know since g++-4.2 doesn't support C++11) statically link libgcc.
|
||||
set( ALL_C_FLAGS "-static-libgcc" )
|
||||
|
|
|
@ -2,6 +2,10 @@ cmake_minimum_required( VERSION 3.1.0 )
|
|||
|
||||
make_release_only()
|
||||
|
||||
if (MSVC)
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244" )
|
||||
endif()
|
||||
|
||||
add_definitions( -DBZ_NO_STDIO )
|
||||
add_library( bz2 STATIC
|
||||
blocksort.c
|
||||
|
|
|
@ -21,6 +21,10 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
|||
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4146" )
|
||||
endif()
|
||||
|
||||
# Request C++11
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.1)
|
||||
# CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
|
||||
|
|
|
@ -6,6 +6,10 @@ if( DEM_CMAKE_COMPILER_IS_GNUC_COMPATIBLE )
|
|||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -fomit-frame-pointer" )
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267" )
|
||||
endif()
|
||||
|
||||
add_library( jpeg STATIC
|
||||
jaricom.c
|
||||
jcomapi.c
|
||||
|
|
|
@ -688,7 +688,7 @@ set( NOT_COMPILED_SOURCE_FILES
|
|||
zcc-parse.c
|
||||
zcc-parse.h
|
||||
common/platform/win32/zutil.natvis
|
||||
|
||||
common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.natvis
|
||||
games/blood/src/_polymost.cpp
|
||||
games/duke/src/_polymost.cpp
|
||||
games/sw/src/_polymost.cpp
|
||||
|
|
|
@ -28,7 +28,7 @@ static_assert('\xff' == 255, "Char must be unsigned!");
|
|||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN int16_t sintable[2048];
|
||||
EXTERN int sintable[2048];
|
||||
|
||||
#include "buildtiles.h"
|
||||
#include "c_cvars.h"
|
||||
|
@ -154,6 +154,32 @@ extern walltype wall[MAXWALLS];
|
|||
extern spritetype sprite[MAXSPRITES];
|
||||
EXTERN int leveltimer;
|
||||
|
||||
inline sectortype* spritetype::sector() const
|
||||
{
|
||||
return &::sector[sectnum];
|
||||
}
|
||||
|
||||
inline sectortype* walltype::nextSector() const
|
||||
{
|
||||
return &::sector[nextsector];
|
||||
}
|
||||
|
||||
inline walltype* walltype::nextWall() const
|
||||
{
|
||||
return &::wall[nextwall];
|
||||
}
|
||||
|
||||
inline walltype* walltype::point2Wall() const
|
||||
{
|
||||
return &::wall[point2];
|
||||
}
|
||||
|
||||
inline walltype* sectortype::firstWall() const
|
||||
{
|
||||
return &wall[wallptr];
|
||||
}
|
||||
|
||||
|
||||
extern sectortype sectorbackup[MAXSECTORS];
|
||||
extern walltype wallbackup[MAXWALLS];
|
||||
|
||||
|
@ -187,6 +213,16 @@ EXTERN int32_t Numsprites;
|
|||
EXTERN int16_t numsectors, numwalls;
|
||||
EXTERN int32_t display_mirror;
|
||||
|
||||
inline bool validSectorIndex(int sectnum)
|
||||
{
|
||||
return sectnum >= 0 && sectnum < numsectors;
|
||||
}
|
||||
|
||||
inline bool validWallIndex(int wallnum)
|
||||
{
|
||||
return wallnum >= 0 && wallnum < numwalls;
|
||||
}
|
||||
|
||||
EXTERN int32_t randomseed;
|
||||
|
||||
EXTERN uint8_t paletteloaded;
|
||||
|
@ -343,7 +379,8 @@ int32_t engineInit(void);
|
|||
void engineUnInit(void);
|
||||
void initspritelists(void);
|
||||
|
||||
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
|
||||
void ValidateSprite(spritetype& spr);
|
||||
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int *dacursectnum);
|
||||
void loadMapBackup(const char* filename);
|
||||
void G_LoadMapHack(const char* filename, const unsigned char*);
|
||||
|
||||
|
@ -392,17 +429,18 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange
|
|||
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1,
|
||||
int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
|
||||
int32_t inside(int32_t x, int32_t y, int sectnum);
|
||||
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags = 0);
|
||||
void dragpoint(int pointhighlight, int32_t dax, int32_t day, uint8_t flags = 0);
|
||||
int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
|
||||
int32_t vx, int32_t vy, int32_t vz,
|
||||
vec3_t * const intp, int32_t strictly_smaller_than_p);
|
||||
|
||||
#define MAXUPDATESECTORDIST 1536
|
||||
#define INITIALUPDATESECTORDIST 256
|
||||
void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3)));
|
||||
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum) ATTRIBUTE((nonnull(4)));
|
||||
void updatesectorneighbor(int32_t const x, int32_t const y, int16_t * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));
|
||||
void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4)));
|
||||
void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3)));
|
||||
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum) ATTRIBUTE((nonnull(4)));
|
||||
|
||||
void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));
|
||||
void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(4)));
|
||||
|
||||
int findwallbetweensectors(int sect1, int sect2);
|
||||
inline int sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; }
|
||||
|
@ -427,12 +465,6 @@ inline constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy)
|
|||
return (uint32_t)dx*dx + (uint32_t)dy*dy;
|
||||
}
|
||||
|
||||
inline int32_t logapproach(int32_t const val, int32_t const targetval)
|
||||
{
|
||||
int32_t const dif = targetval - val;
|
||||
return (dif>>1) ? val + (dif>>1) : targetval;
|
||||
}
|
||||
|
||||
void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * const p2) ATTRIBUTE((nonnull(4)));
|
||||
inline void rotatepoint(int px, int py, int ptx, int pty, int daang, int* resx, int* resy)
|
||||
{
|
||||
|
@ -446,6 +478,17 @@ inline void rotatepoint(int px, int py, int ptx, int pty, int daang, int* resx,
|
|||
|
||||
int32_t lastwall(int16_t point);
|
||||
int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
|
||||
inline sectortype* nextsectorneighborzptr(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction)
|
||||
{
|
||||
auto sect = nextsectorneighborz(sectnum, refz, topbottom, direction);
|
||||
return sect == -1? nullptr : §or[sect];
|
||||
}
|
||||
|
||||
inline sectortype* nextsectorneighborzptr(sectortype* sectp, int32_t refz, int16_t topbottom, int16_t direction)
|
||||
{
|
||||
auto sect = nextsectorneighborz(int(sectp - sector), refz, topbottom, direction);
|
||||
return sect == -1? nullptr : §or[sect];
|
||||
}
|
||||
|
||||
int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
|
||||
int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
|
||||
|
@ -629,50 +672,6 @@ static inline int64_t compat_maybe_truncate_to_int32(int64_t val)
|
|||
return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val;
|
||||
}
|
||||
|
||||
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist,
|
||||
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));
|
||||
|
||||
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist,
|
||||
int32_t ceildist, int32_t flordist, uint32_t cliptype)
|
||||
{
|
||||
vec3_t vector = { *x, *y, *z };
|
||||
|
||||
int32_t result = clipmove(&vector, sectnum, xvect, yvect, walldist, ceildist, flordist, cliptype);
|
||||
|
||||
*x = vector.x;
|
||||
*y = vector.y;
|
||||
*z = vector.z;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
|
||||
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));
|
||||
|
||||
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
|
||||
int32_t ceildist, int32_t flordist, uint32_t cliptype)
|
||||
{
|
||||
vec3_t vector = { *x, *y, *z };
|
||||
|
||||
int32_t result = pushmove(&vector, sectnum, walldist, ceildist, flordist, cliptype);
|
||||
|
||||
*x = vector.x;
|
||||
*y = vector.y;
|
||||
*z = vector.z;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void getzrange_old(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
||||
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(5,6,7,8)));
|
||||
|
||||
static inline void getzrange_old(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
||||
int32_t *florhit, int32_t walldist, uint32_t cliptype)
|
||||
{
|
||||
const vec3_t vector = { x, y, z };
|
||||
getzrange(&vector, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
|
||||
}
|
||||
|
||||
static inline int32_t setspritez_old(int16_t spritenum, int32_t x, int32_t y, int32_t z)
|
||||
{
|
||||
const vec3_t vector = { x, y, z };
|
||||
|
|
|
@ -51,6 +51,7 @@ enum
|
|||
|
||||
|
||||
//40 bytes
|
||||
struct walltype;
|
||||
struct sectortype
|
||||
{
|
||||
int16_t wallptr, wallnum;
|
||||
|
@ -87,6 +88,7 @@ struct sectortype
|
|||
void addfloorypan(float add) { floorypan_ = fmodf(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets
|
||||
void addceilingxpan(float add) { ceilingxpan_ = fmodf(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets
|
||||
void addceilingypan(float add) { ceilingypan_ = fmodf(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets
|
||||
walltype *firstWall() const;
|
||||
};
|
||||
|
||||
//cstat:
|
||||
|
@ -134,6 +136,10 @@ struct walltype
|
|||
void setypan(float add) { ypan_ = fmodf(add + 512, 256); } // +512 is for handling negative offsets
|
||||
void addxpan(float add) { xpan_ = fmodf(xpan_ + add + 512, 256); } // +512 is for handling negative offsets
|
||||
void addypan(float add) { ypan_ = fmodf(ypan_ + add + 512, 256); } // +512 is for handling negative offsets
|
||||
sectortype* nextSector() const;
|
||||
walltype* nextWall() const;
|
||||
walltype* point2Wall() const;
|
||||
bool twoSided() const { return nextsector >= 0; }
|
||||
|
||||
#if 0
|
||||
// make sure we do not accidentally copy this
|
||||
|
@ -362,6 +368,8 @@ struct spritetype
|
|||
{
|
||||
return interpolatedangle(oang, ang, smoothratio, 16);
|
||||
}
|
||||
|
||||
sectortype* sector() const;
|
||||
};
|
||||
|
||||
using tspritetype = spritetype;
|
||||
|
|
|
@ -29,35 +29,11 @@ inline int clipinsidebox(int x, int y, int wall, int dist)
|
|||
}
|
||||
int clipinsideboxline(int x, int y, int x1, int y1, int x2, int y2, int walldist);
|
||||
|
||||
extern int32_t clipmoveboxtracenum;
|
||||
|
||||
int32_t clipmove(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
|
||||
int32_t const flordist, uint32_t const cliptype) ATTRIBUTE((nonnull(1, 2)));
|
||||
int32_t clipmove(vec3_t *const pos, int *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
|
||||
int32_t const flordist, uint32_t const cliptype, int clipmoveboxtracenum = 3) ATTRIBUTE((nonnull(1, 2)));
|
||||
|
||||
inline int clipmove(int* x, int* y, int* z, short* sect, int xv, int yv, int wal, int ceil, int flor, int ct)
|
||||
{
|
||||
vec3_t xyz = { *x,*y,*z };
|
||||
int retval = clipmove(&xyz, sect, xv, yv, wal, ceil, flor, ct);
|
||||
*x = xyz.x;
|
||||
*y = xyz.y;
|
||||
*z = xyz.z;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int32_t clipmovex(vec3_t *const pos, int16_t *const sectnum, int32_t xvect, int32_t yvect, int32_t const walldist, int32_t const ceildist,
|
||||
int32_t const flordist, uint32_t const cliptype, uint8_t const noslidep) ATTRIBUTE((nonnull(1, 2)));
|
||||
int pushmove(vec3_t *const vect, int16_t *const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
|
||||
int pushmove(vec3_t *const vect, int *const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
|
||||
uint32_t const cliptype, bool clear = true) ATTRIBUTE((nonnull(1, 2)));
|
||||
|
||||
inline int pushmove(int* x, int* y, int* z, int16_t* const sectnum, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
|
||||
uint32_t const cliptype, bool clear = true)
|
||||
{
|
||||
vec3_t v = { *x,*y,*z };
|
||||
auto r = pushmove(&v, sectnum, walldist, ceildist, flordist, cliptype, clear);
|
||||
*x = v.x;
|
||||
*y = v.y;
|
||||
*z = v.z;
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang,
|
|||
int32_t* tposx, int32_t* tposy, fixed_t* tang);
|
||||
void renderCompleteMirror(void);
|
||||
|
||||
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int16_t dacursectnum);
|
||||
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int dacursectnum, bool fromoutside);
|
||||
|
||||
void renderDrawMasks(void);
|
||||
|
||||
|
|
|
@ -101,8 +101,6 @@ static inline void get_floorspr_points(T const * const spr, int32_t px, int32_t
|
|||
*y3 = *y2 + ofs.y, *y4 = *y1 + ofs.y;
|
||||
}
|
||||
|
||||
int32_t clipmoveboxtracenum = 3;
|
||||
|
||||
//
|
||||
// clipinsidebox
|
||||
//
|
||||
|
@ -217,7 +215,7 @@ inline void clipmove_tweak_pos(const vec3_t *pos, int32_t gx, int32_t gy, int32_
|
|||
// Returns: should clip?
|
||||
static int cliptestsector(int const dasect, int const nextsect, int32_t const flordist, int32_t const ceildist, vec2_t const pos, int32_t const posz)
|
||||
{
|
||||
assert((unsigned)dasect < (unsigned)numsectors && (unsigned)nextsect < (unsigned)numsectors);
|
||||
assert(validSectorIndex(dasect) && validSectorIndex(nextsect));
|
||||
|
||||
auto const sec2 = (usectorptr_t)§or[nextsect];
|
||||
|
||||
|
@ -272,22 +270,6 @@ static int cliptestsector(int const dasect, int const nextsect, int32_t const fl
|
|||
dacz2 > dacz+CLIPCURBHEIGHT)); // ceilings check the same conditions ^^^^^
|
||||
}
|
||||
|
||||
int32_t clipmovex(vec3_t *pos, int16_t *sectnum,
|
||||
int32_t xvect, int32_t yvect,
|
||||
int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype,
|
||||
uint8_t const noslidep)
|
||||
{
|
||||
const int32_t oboxtracenum = clipmoveboxtracenum;
|
||||
|
||||
if (noslidep)
|
||||
clipmoveboxtracenum = 1;
|
||||
int32_t ret = clipmove(pos, sectnum, xvect, yvect,
|
||||
walldist, ceildist, flordist, cliptype);
|
||||
clipmoveboxtracenum = oboxtracenum;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// raytrace (internal)
|
||||
//
|
||||
|
@ -394,7 +376,7 @@ static int get_floorspr_clipyou(vec2_t const v1, vec2_t const v2, vec2_t const v
|
|||
return clipyou;
|
||||
}
|
||||
|
||||
static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int walldist)
|
||||
static void clipupdatesector(vec2_t const pos, int * const sectnum, int walldist)
|
||||
{
|
||||
#if 0
|
||||
if (enginecompatibility_mode != ENGINECOMPATIBILITY_NONE)
|
||||
|
@ -469,8 +451,8 @@ static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int wall
|
|||
//
|
||||
// clipmove
|
||||
//
|
||||
int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int32_t yvect,
|
||||
int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype)
|
||||
int32_t clipmove(vec3_t * const pos, int * const sectnum, int32_t xvect, int32_t yvect,
|
||||
int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype, int clipmoveboxtracenum)
|
||||
{
|
||||
if ((xvect|yvect) == 0 || *sectnum < 0)
|
||||
return 0;
|
||||
|
@ -742,13 +724,13 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
|
|||
vec2_t const clipr = { clipit[hitwall].x2 - clipit[hitwall].x1, clipit[hitwall].y2 - clipit[hitwall].y1 };
|
||||
// clamp to the max value we can utilize without reworking the scaling below
|
||||
// this works around the overflow issue that affects dukedc2.map
|
||||
int32_t const templl = (int32_t)clamp(compat_maybe_truncate_to_int32((int64_t)clipr.x * clipr.x + (int64_t)clipr.y * clipr.y), INT32_MIN, INT32_MAX);
|
||||
int32_t const templl = (int32_t)clamp<int64_t>(compat_maybe_truncate_to_int32((int64_t)clipr.x * clipr.x + (int64_t)clipr.y * clipr.y), INT32_MIN, INT32_MAX);
|
||||
|
||||
if (templl > 0)
|
||||
{
|
||||
// I don't know if this one actually overflows or not, but I highly doubt it hurts to check
|
||||
int32_t const templl2
|
||||
= (int32_t)clamp(compat_maybe_truncate_to_int32((int64_t)(goal.x - vec.x) * clipr.x + (int64_t)(goal.y - vec.y) * clipr.y), INT32_MIN, INT32_MAX);
|
||||
= (int32_t)clamp<int64_t>(compat_maybe_truncate_to_int32((int64_t)(goal.x - vec.x) * clipr.x + (int64_t)(goal.y - vec.y) * clipr.y), INT32_MIN, INT32_MAX);
|
||||
int32_t const i = (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829 || (abs(templl2)>>11) < templl) ?
|
||||
(int)DivScaleL(templl2, templl, 20) : 0;
|
||||
|
||||
|
@ -789,7 +771,9 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
|
|||
}
|
||||
|
||||
if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE)
|
||||
{
|
||||
clipupdatesector(vec, sectnum, rad);
|
||||
}
|
||||
|
||||
pos->x = vec.x;
|
||||
pos->y = vec.y;
|
||||
|
@ -851,7 +835,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
|
|||
//
|
||||
// pushmove
|
||||
//
|
||||
int pushmove(vec3_t *const vect, int16_t *const sectnum,
|
||||
int pushmove(vec3_t *const vect, int *const sectnum,
|
||||
int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype, bool clear /*= true*/)
|
||||
{
|
||||
int bad;
|
||||
|
|
|
@ -207,7 +207,7 @@ static int32_t engineLoadTables(void)
|
|||
int32_t i;
|
||||
|
||||
for (i=0; i<=512; i++)
|
||||
sintable[i] = bsinf(i);
|
||||
sintable[i] = int(sin(i * BAngRadian) * +SINTABLEUNIT);
|
||||
for (i=513; i<1024; i++)
|
||||
sintable[i] = sintable[1024-i];
|
||||
for (i=1024; i<2048; i++)
|
||||
|
@ -702,35 +702,10 @@ void initspritelists(void)
|
|||
//
|
||||
// See http://fabiensanglard.net/duke3d/build_engine_internals.php,
|
||||
// "Inside details" for the idea behind the algorithm.
|
||||
int32_t inside_ps(int32_t x, int32_t y, int16_t sectnum)
|
||||
|
||||
int32_t inside(int32_t x, int32_t y, int sectnum)
|
||||
{
|
||||
if (sectnum >= 0 && sectnum < numsectors)
|
||||
{
|
||||
int32_t cnt = 0;
|
||||
auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
|
||||
int wallsleft = sector[sectnum].wallnum;
|
||||
|
||||
do
|
||||
{
|
||||
vec2_t v1 = { wal->x - x, wal->y - y };
|
||||
auto const &wal2 = *(uwallptr_t)&wall[wal->point2];
|
||||
vec2_t v2 = { wal2.x - x, wal2.y - y };
|
||||
|
||||
if ((v1.y^v2.y) < 0)
|
||||
cnt ^= (((v1.x^v2.x) < 0) ? (v1.x*v2.y<v2.x*v1.y)^(v1.y<v2.y) : (v1.x >= 0));
|
||||
|
||||
wal++;
|
||||
}
|
||||
while (--wallsleft);
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
int32_t inside_old(int32_t x, int32_t y, int16_t sectnum)
|
||||
{
|
||||
if (sectnum >= 0 && sectnum < numsectors)
|
||||
if (validSectorIndex(sectnum))
|
||||
{
|
||||
uint32_t cnt = 0;
|
||||
auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
|
||||
|
@ -763,71 +738,6 @@ int32_t inside_old(int32_t x, int32_t y, int16_t sectnum)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t inside(int32_t x, int32_t y, int sectnum)
|
||||
{
|
||||
switch (enginecompatibility_mode)
|
||||
{
|
||||
case ENGINECOMPATIBILITY_NONE:
|
||||
break;
|
||||
case ENGINECOMPATIBILITY_19950829:
|
||||
return inside_ps(x, y, sectnum);
|
||||
default:
|
||||
return inside_old(x, y, sectnum);
|
||||
}
|
||||
if ((unsigned)sectnum < (unsigned)numsectors)
|
||||
{
|
||||
uint32_t cnt1 = 0, cnt2 = 0;
|
||||
|
||||
auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr];
|
||||
int wallsleft = sector[sectnum].wallnum;
|
||||
|
||||
do
|
||||
{
|
||||
// Get the x and y components of the [tested point]-->[wall
|
||||
// point{1,2}] vectors.
|
||||
vec2_t v1 = { wal->x - x, wal->y - y };
|
||||
auto const &wal2 = *(uwallptr_t)&wall[wal->point2];
|
||||
vec2_t v2 = { wal2.x - x, wal2.y - y };
|
||||
|
||||
// First, test if the point is EXACTLY_ON_WALL_POINT.
|
||||
if ((v1.x|v1.y) == 0 || (v2.x|v2.y)==0)
|
||||
return 1;
|
||||
|
||||
// If their signs differ[*], ...
|
||||
//
|
||||
// [*] where '-' corresponds to <0 and '+' corresponds to >=0.
|
||||
// Equivalently, the branch is taken iff
|
||||
// y1 != y2 AND y_m <= y < y_M,
|
||||
// where y_m := min(y1, y2) and y_M := max(y1, y2).
|
||||
if ((v1.y^v2.y) < 0)
|
||||
cnt1 ^= (((v1.x^v2.x) >= 0) ? v1.x : (v1.x*v2.y-v2.x*v1.y)^v2.y);
|
||||
|
||||
v1.y--;
|
||||
v2.y--;
|
||||
|
||||
// Now, do the same comparisons, but with the interval half-open on
|
||||
// the other side! That is, take the branch iff
|
||||
// y1 != y2 AND y_m < y <= y_M,
|
||||
// For a rectangular sector, without EXACTLY_ON_WALL_POINT, this
|
||||
// would still leave the lower left and upper right points
|
||||
// "outside" the sector.
|
||||
if ((v1.y^v2.y) < 0)
|
||||
{
|
||||
v1.x--;
|
||||
v2.x--;
|
||||
|
||||
cnt2 ^= (((v1.x^v2.x) >= 0) ? v1.x : (v1.x*v2.y-v2.x*v1.y)^v2.y);
|
||||
}
|
||||
|
||||
wal++;
|
||||
}
|
||||
while (--wallsleft);
|
||||
|
||||
return (cnt1|cnt2)>>31;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t getangle(int32_t xvect, int32_t yvect)
|
||||
{
|
||||
|
@ -878,7 +788,7 @@ int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyo
|
|||
//
|
||||
int32_t setsprite(int16_t spritenum, const vec3_t *newpos)
|
||||
{
|
||||
int16_t tempsectnum = sprite[spritenum].sectnum;
|
||||
int tempsectnum = sprite[spritenum].sectnum;
|
||||
|
||||
if (newpos != &sprite[spritenum].pos)
|
||||
sprite[spritenum].pos = *newpos;
|
||||
|
@ -895,7 +805,7 @@ int32_t setsprite(int16_t spritenum, const vec3_t *newpos)
|
|||
|
||||
int32_t setspritez(int16_t spritenum, const vec3_t *newpos)
|
||||
{
|
||||
int16_t tempsectnum = sprite[spritenum].sectnum;
|
||||
int tempsectnum = sprite[spritenum].sectnum;
|
||||
|
||||
if ((void const *)newpos != (void *)&sprite[spritenum])
|
||||
sprite[spritenum].pos = *newpos;
|
||||
|
@ -1177,7 +1087,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
|
|||
// flags:
|
||||
// 1: don't reset walbitmap[] (the bitmap of already dragged vertices)
|
||||
// 2: In the editor, do wall[].cstat |= (1<<14) also for the lastwall().
|
||||
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags)
|
||||
void dragpoint(int pointhighlight, int32_t dax, int32_t day, uint8_t flags)
|
||||
{
|
||||
int32_t i, numyaxwalls=0;
|
||||
static int16_t yaxwalls[MAXWALLS];
|
||||
|
@ -1356,9 +1266,9 @@ int findwallbetweensectors(int sect1, int sect2)
|
|||
//
|
||||
// updatesector[z]
|
||||
//
|
||||
void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum)
|
||||
void updatesector(int32_t const x, int32_t const y, int * const sectnum)
|
||||
{
|
||||
int16_t sect = *sectnum;
|
||||
int sect = *sectnum;
|
||||
updatesectorneighbor(x, y, §, INITIALUPDATESECTORDIST, MAXUPDATESECTORDIST);
|
||||
if (sect != -1)
|
||||
SET_AND_RETURN(*sectnum, sect);
|
||||
|
@ -1373,37 +1283,15 @@ void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum)
|
|||
}
|
||||
|
||||
|
||||
// new: if *sectnum >= MAXSECTORS, *sectnum-=MAXSECTORS is considered instead
|
||||
// as starting sector and the 'initial' z check is skipped
|
||||
// (not initial anymore because it follows the sector updating due to TROR)
|
||||
|
||||
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum)
|
||||
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int* const sectnum)
|
||||
{
|
||||
if (enginecompatibility_mode != ENGINECOMPATIBILITY_NONE)
|
||||
{
|
||||
if ((uint32_t)(*sectnum) < 2*MAXSECTORS)
|
||||
{
|
||||
int32_t nofirstzcheck = 0;
|
||||
|
||||
if (*sectnum >= MAXSECTORS)
|
||||
{
|
||||
*sectnum -= MAXSECTORS;
|
||||
nofirstzcheck = 1;
|
||||
}
|
||||
|
||||
// this block used to be outside the "if" and caused crashes in Polymost Mapster32
|
||||
int32_t cz, fz;
|
||||
getzsofslope(*sectnum, x, y, &cz, &fz);
|
||||
|
||||
if (nofirstzcheck || (z >= cz && z <= fz))
|
||||
if (inside_p(x, y, *sectnum))
|
||||
return;
|
||||
|
||||
walltype const * wal = &wall[sector[*sectnum].wallptr];
|
||||
int wallsleft = sector[*sectnum].wallnum;
|
||||
do
|
||||
{
|
||||
// YAX: TODO: check neighboring sectors here too?
|
||||
int const next = wal->nextsector;
|
||||
if (next>=0 && inside_z_p(x,y,z, next))
|
||||
SET_AND_RETURN(*sectnum, next);
|
||||
|
@ -1411,15 +1299,6 @@ void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t *
|
|||
wal++;
|
||||
}
|
||||
while (--wallsleft);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int16_t sect = *sectnum;
|
||||
updatesectorneighborz(x, y, z, §, INITIALUPDATESECTORDIST, MAXUPDATESECTORDIST);
|
||||
if (sect != -1)
|
||||
SET_AND_RETURN(*sectnum, sect);
|
||||
}
|
||||
|
||||
// we need to support passing in a sectnum of -1, unfortunately
|
||||
for (int i = numsectors - 1; i >= 0; --i)
|
||||
|
@ -1429,11 +1308,11 @@ void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t *
|
|||
*sectnum = -1;
|
||||
}
|
||||
|
||||
void updatesectorneighbor(int32_t const x, int32_t const y, int16_t * const sectnum, int32_t initialMaxDistance /*= INITIALUPDATESECTORDIST*/, int32_t maxDistance /*= MAXUPDATESECTORDIST*/)
|
||||
void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t initialMaxDistance /*= INITIALUPDATESECTORDIST*/, int32_t maxDistance /*= MAXUPDATESECTORDIST*/)
|
||||
{
|
||||
int const initialsectnum = *sectnum;
|
||||
|
||||
if ((unsigned)initialsectnum < (unsigned)numsectors && getsectordist({x, y}, initialsectnum) <= initialMaxDistance)
|
||||
if ((validSectorIndex(initialsectnum)) && getsectordist({x, y}, initialsectnum) <= initialMaxDistance)
|
||||
{
|
||||
if (inside_p(x, y, initialsectnum))
|
||||
return;
|
||||
|
@ -1465,53 +1344,6 @@ void updatesectorneighbor(int32_t const x, int32_t const y, int16_t * const sect
|
|||
*sectnum = -1;
|
||||
}
|
||||
|
||||
void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum, int32_t initialMaxDistance /*= 0*/, int32_t maxDistance /*= 0*/)
|
||||
{
|
||||
bool nofirstzcheck = false;
|
||||
|
||||
if (*sectnum >= MAXSECTORS && *sectnum - MAXSECTORS < numsectors)
|
||||
{
|
||||
*sectnum -= MAXSECTORS;
|
||||
nofirstzcheck = true;
|
||||
}
|
||||
|
||||
uint32_t const correctedsectnum = (unsigned)*sectnum;
|
||||
|
||||
if (correctedsectnum < (unsigned)numsectors && getsectordist({x, y}, correctedsectnum) <= initialMaxDistance)
|
||||
{
|
||||
int32_t cz, fz;
|
||||
getzsofslope(correctedsectnum, x, y, &cz, &fz);
|
||||
|
||||
if ((nofirstzcheck || (z >= cz && z <= fz)) && inside_p(x, y, *sectnum))
|
||||
return;
|
||||
|
||||
static int16_t sectlist[MAXSECTORS];
|
||||
static uint8_t sectbitmap[(MAXSECTORS+7)>>3];
|
||||
int16_t nsecs;
|
||||
|
||||
bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, correctedsectnum);
|
||||
|
||||
for (int sectcnt=0; sectcnt<nsecs; sectcnt++)
|
||||
{
|
||||
int const listsectnum = sectlist[sectcnt];
|
||||
|
||||
if (inside_z_p(x, y, z, listsectnum))
|
||||
SET_AND_RETURN(*sectnum, listsectnum);
|
||||
|
||||
auto const sec = §or[listsectnum];
|
||||
int const startwall = sec->wallptr;
|
||||
int const endwall = sec->wallptr + sec->wallnum;
|
||||
auto uwal = (uwallptr_t)&wall[startwall];
|
||||
|
||||
for (int j=startwall; j<endwall; j++, uwal++)
|
||||
if (uwal->nextsector >= 0 && getsectordist({x, y}, uwal->nextsector) <= maxDistance)
|
||||
bfirst_search_try(sectlist, sectbitmap, &nsecs, uwal->nextsector);
|
||||
}
|
||||
}
|
||||
|
||||
*sectnum = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// rotatepoint
|
||||
//
|
||||
|
|
|
@ -981,10 +981,8 @@ static int32_t global_cf_shade, global_cf_pal, global_cf_fogpal;
|
|||
static float (*global_getzofslope_func)(usectorptr_t, float, float);
|
||||
|
||||
static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0, float ryp1, float x0, float x1,
|
||||
float y0, float y1, int32_t sectnum)
|
||||
float y0, float y1, int32_t sectnum, bool have_floor)
|
||||
{
|
||||
int const have_floor = sectnum & MAXSECTORS;
|
||||
sectnum &= ~MAXSECTORS;
|
||||
auto const sec = (usectorptr_t)§or[sectnum];
|
||||
|
||||
// comments from floor code:
|
||||
|
@ -1622,7 +1620,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
{
|
||||
int32_t fz = getflorzofslope(sectnum, globalposx, globalposy);
|
||||
if (globalposz <= fz)
|
||||
polymost_internal_nonparallaxed(n0, n1, ryp0, ryp1, x0, x1, fy0, fy1, sectnum | MAXSECTORS);
|
||||
polymost_internal_nonparallaxed(n0, n1, ryp0, ryp1, x0, x1, fy0, fy1, sectnum, true);
|
||||
}
|
||||
else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1)))
|
||||
{
|
||||
|
@ -1675,7 +1673,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
{
|
||||
int32_t cz = getceilzofslope(sectnum, globalposx, globalposy);
|
||||
if (globalposz >= cz)
|
||||
polymost_internal_nonparallaxed(n0, n1, ryp0, ryp1, x0, x1, cy0, cy1, sectnum);
|
||||
polymost_internal_nonparallaxed(n0, n1, ryp0, ryp1, x0, x1, cy0, cy1, sectnum, false);
|
||||
}
|
||||
else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1)))
|
||||
{
|
||||
|
@ -3307,7 +3305,7 @@ void renderCompleteMirror(void)
|
|||
EXTERN_CVAR(Int, gl_fogmode)
|
||||
|
||||
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
||||
fixed_t daang, fixed_t dahoriz, int16_t dacursectnum)
|
||||
fixed_t daang, fixed_t dahoriz, int dacursectnum, bool fromoutside)
|
||||
{
|
||||
pm_spritesortcnt = 0;
|
||||
checkRotatedWalls();
|
||||
|
@ -3316,9 +3314,7 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
|||
|
||||
// Update starting sector number (common to classic and Polymost).
|
||||
// ADJUST_GLOBALCURSECTNUM.
|
||||
if (dacursectnum >= MAXSECTORS)
|
||||
dacursectnum -= MAXSECTORS;
|
||||
else
|
||||
if (!fromoutside)
|
||||
{
|
||||
int i = dacursectnum;
|
||||
updatesector(daposx, daposy, &dacursectnum);
|
||||
|
@ -3894,7 +3890,7 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate)
|
|||
GLInterface.EnableBlend(true); // else GLInterface.EnableBlend(false);
|
||||
}
|
||||
else pc[3] = 1.f;
|
||||
GLInterface.SetShade(std::max(0, globalshade), numshades);
|
||||
GLInterface.SetShade(max(0, globalshade), numshades);
|
||||
//------------
|
||||
|
||||
//transform to Build coords
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "templates.h"
|
||||
|
||||
#include "v_2ddrawer.h"
|
||||
#include "vectors.h"
|
||||
#include "vm.h"
|
||||
|
@ -455,7 +455,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
|
|||
// Note that this only works for unflipped and unrotated full textures.
|
||||
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
|
||||
{
|
||||
double wi = std::min(parms.windowright, parms.texwidth);
|
||||
double wi = min(parms.windowright, parms.texwidth);
|
||||
x += parms.windowleft * xscale;
|
||||
w -= (parms.texwidth - wi + parms.windowleft) * xscale;
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public:
|
|||
|
||||
RenderCommand()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
memset((void*)this, 0, sizeof(*this));
|
||||
}
|
||||
|
||||
// If these fields match, two draw commands can be batched.
|
||||
|
@ -306,8 +306,8 @@ public:
|
|||
|
||||
void UploadData(F2DDrawer::TwoDVertex *vertices, int vertcount, int *indices, int indexcount)
|
||||
{
|
||||
mVertexBuffer->SetData(vertcount * sizeof(*vertices), vertices, false);
|
||||
mIndexBuffer->SetData(indexcount * sizeof(unsigned int), indices, false);
|
||||
mVertexBuffer->SetData(vertcount * sizeof(*vertices), vertices, BufferUsageType::Stream);
|
||||
mIndexBuffer->SetData(indexcount * sizeof(unsigned int), indices, BufferUsageType::Stream);
|
||||
}
|
||||
|
||||
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <stdarg.h>
|
||||
#include "v_draw.h"
|
||||
#include "vm.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "texturemanager.h"
|
||||
#include "r_videoscale.h"
|
||||
#include "c_cvars.h"
|
||||
|
@ -151,8 +151,8 @@ int GetUIScale(F2DDrawer *drawer, int altval)
|
|||
// block scales that result in something larger than the current screen.
|
||||
int vmax = drawer->GetHeight() / 200;
|
||||
int hmax = drawer->GetWidth() / 320;
|
||||
int max = MAX(vmax, hmax);
|
||||
return MAX(1,MIN(scaleval, max));
|
||||
int max = std::max(vmax, hmax);
|
||||
return std::max(1,min(scaleval, max));
|
||||
}
|
||||
|
||||
// The new console font is twice as high, so the scaling calculation must factor that in.
|
||||
|
@ -172,8 +172,8 @@ int GetConScale(F2DDrawer* drawer, int altval)
|
|||
// block scales that result in something larger than the current screen.
|
||||
int vmax = drawer->GetHeight() / 400;
|
||||
int hmax = drawer->GetWidth() / 640;
|
||||
int max = MAX(vmax, hmax);
|
||||
return MAX(1, MIN(scaleval, max));
|
||||
int max = std::max(vmax, hmax);
|
||||
return std::max(1, min(scaleval, max));
|
||||
}
|
||||
|
||||
|
||||
|
@ -357,7 +357,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect)
|
|||
if (numret > 1) ret[1].SetInt(y);
|
||||
if (numret > 2) ret[2].SetInt(w);
|
||||
if (numret > 3) ret[3].SetInt(h);
|
||||
return MIN(numret, 4);
|
||||
return min(numret, 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -460,7 +460,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetFullscreenRect)
|
|||
if (numret >= 2) ret[1].SetFloat(rect.top);
|
||||
if (numret >= 3) ret[2].SetFloat(rect.width);
|
||||
if (numret >= 4) ret[3].SetFloat(rect.height);
|
||||
return MIN(numret, 4);
|
||||
return min(numret, 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -905,7 +905,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
|
|||
break;
|
||||
|
||||
case DTA_Alpha:
|
||||
parms->Alpha = (float)(MIN<double>(1., ListGetDouble(tags)));
|
||||
parms->Alpha = (float)(min<double>(1., ListGetDouble(tags)));
|
||||
break;
|
||||
|
||||
case DTA_AlphaChannel:
|
||||
|
@ -1090,7 +1090,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
|
|||
break;
|
||||
|
||||
case DTA_ShadowAlpha:
|
||||
//parms->shadowAlpha = (float)MIN(1., ListGetDouble(tags));
|
||||
//parms->shadowAlpha = (float)min(1., ListGetDouble(tags));
|
||||
break;
|
||||
|
||||
case DTA_ShadowColor:
|
||||
|
@ -1286,10 +1286,10 @@ static void VirtualToRealCoords(F2DDrawer *drawer, double Width, double Height,
|
|||
{
|
||||
case 1:
|
||||
default:
|
||||
myratio = MIN(64.0f / 27.0f, myratio);
|
||||
myratio = min(64.0f / 27.0f, myratio);
|
||||
break;
|
||||
case 0:
|
||||
myratio = MIN(16.0f / 9.0f, myratio);
|
||||
myratio = min(16.0f / 9.0f, myratio);
|
||||
case -1:
|
||||
break;
|
||||
}
|
||||
|
@ -1348,7 +1348,7 @@ DEFINE_ACTION_FUNCTION(_Screen, VirtualToRealCoords)
|
|||
VirtualToRealCoords(twod, x, y, w, h, vw, vh, vbottom, handleaspect);
|
||||
if (numret >= 1) ret[0].SetVector2(DVector2(x, y));
|
||||
if (numret >= 2) ret[1].SetVector2(DVector2(w, h));
|
||||
return MIN(numret, 2);
|
||||
return min(numret, 2);
|
||||
}
|
||||
|
||||
void VirtualToRealCoordsInt(F2DDrawer *drawer, int &x, int &y, int &w, int &h,
|
||||
|
@ -1529,8 +1529,9 @@ DEFINE_ACTION_FUNCTION(_Screen, Dim)
|
|||
PARAM_INT(y1);
|
||||
PARAM_INT(w);
|
||||
PARAM_INT(h);
|
||||
PARAM_INT(style);
|
||||
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
|
||||
Dim(twod, color, float(amount), x1, y1, w, h);
|
||||
Dim(twod, color, float(amount), x1, y1, w, h, &LegacyRenderStyles[style]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1593,7 +1594,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawLineFrame)
|
|||
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2)
|
||||
{
|
||||
if (designheight < 240 && realheight >= 480) designheight = 240;
|
||||
*cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight);
|
||||
*cleanx = *cleany = min(realwidth / designwidth, realheight / designheight);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "m_argv.h"
|
||||
#include "filesystem.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "stats.h"
|
||||
#include "cmdlib.h"
|
||||
#include "c_cvars.h"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <chrono>
|
||||
|
||||
#include "c_cvars.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "oalsound.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "v_text.h"
|
||||
|
@ -579,7 +579,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
// Make sure one source is capable of stereo output with the rest doing
|
||||
// mono, without running out of voices
|
||||
attribs.Push(ALC_MONO_SOURCES);
|
||||
attribs.Push(std::max<ALCint>(snd_channels, 2) - 1);
|
||||
attribs.Push(max<ALCint>(snd_channels, 2) - 1);
|
||||
attribs.Push(ALC_STEREO_SOURCES);
|
||||
attribs.Push(1);
|
||||
if(ALC.SOFT_HRTF)
|
||||
|
@ -681,7 +681,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
// At least Apple's OpenAL implementation returns zeroes,
|
||||
// although it can generate reasonable number of sources.
|
||||
|
||||
const int numChannels = std::max<int>(snd_channels, 2);
|
||||
const int numChannels = max<int>(snd_channels, 2);
|
||||
int numSources = numMono + numStereo;
|
||||
|
||||
if (0 == numSources)
|
||||
|
@ -689,7 +689,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
numSources = numChannels;
|
||||
}
|
||||
|
||||
Sources.Resize(std::min<int>(numChannels, numSources));
|
||||
Sources.Resize(min<int>(numChannels, numSources));
|
||||
for(unsigned i = 0;i < Sources.Size();i++)
|
||||
{
|
||||
alGenSources(1, &Sources[i]);
|
||||
|
@ -1346,7 +1346,7 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
|
|||
float gain = GetRolloff(rolloff, dist * distscale);
|
||||
// Don't let the ref distance go to 0, or else distance attenuation is
|
||||
// lost with the inverse distance model.
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, std::max<float>(gain*dist, 0.0004f));
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
|
||||
alSourcef(source, AL_MAX_DISTANCE, std::numeric_limits<float>::max());
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, 1.f);
|
||||
}
|
||||
|
@ -1466,9 +1466,9 @@ void OpenALSoundRenderer::ChannelPitch(FISoundChannel *chan, float pitch)
|
|||
|
||||
ALuint source = GET_PTRID(chan->SysChannel);
|
||||
if (WasInWater && !(chan->ChanFlags & CHANF_UI))
|
||||
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f)*PITCH_MULT);
|
||||
alSourcef(source, AL_PITCH, max(pitch, 0.0001f)*PITCH_MULT);
|
||||
else
|
||||
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f));
|
||||
alSourcef(source, AL_PITCH, max(pitch, 0.0001f));
|
||||
}
|
||||
|
||||
void OpenALSoundRenderer::StopChannel(FISoundChannel *chan)
|
||||
|
@ -1622,7 +1622,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh
|
|||
{
|
||||
float dist = sqrtf(dist_sqr);
|
||||
float gain = GetRolloff(&chan->Rolloff, dist * chan->DistanceScale);
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, std::max<float>(gain*dist, 0.0004f));
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
|
||||
}
|
||||
|
||||
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "s_soundinternal.h"
|
||||
#include "sc_man.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "cmdlib.h"
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "s_soundinternal.h"
|
||||
#include "sc_man.h"
|
||||
#include "cmdlib.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "i_system.h"
|
||||
#include "printf.h"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "s_soundinternal.h"
|
||||
#include "m_swap.h"
|
||||
#include "superfasthash.h"
|
||||
|
@ -407,7 +407,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
sfx = &S_sfx[sound_id];
|
||||
|
||||
// Scale volume according to SNDINFO data.
|
||||
volume = std::min(volume * sfx->Volume, 1.f);
|
||||
volume = min(volume * sfx->Volume, 1.f);
|
||||
if (volume <= 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -847,7 +847,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
|
|||
|
||||
CalcPosVel(chan, &chanorigin, NULL);
|
||||
// scale the limit distance with the attenuation. An attenuation of 0 means the limit distance is infinite and all sounds within the level are inside the limit.
|
||||
float attn = std::min(chan->DistanceScale, attenuation);
|
||||
float attn = min(chan->DistanceScale, attenuation);
|
||||
if (attn <= 0 || (chanorigin - pos).LengthSquared() <= limit_range / attn)
|
||||
{
|
||||
count++;
|
||||
|
@ -1074,8 +1074,8 @@ void SoundEngine::ChangeSoundPitch(int sourcetype, const void *source, int chann
|
|||
void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
|
||||
{
|
||||
assert(chan != nullptr);
|
||||
GSnd->ChannelPitch(chan, std::max(0.0001f, pitch));
|
||||
chan->Pitch = std::max(1, int(float(DEFAULT_PITCH) * pitch));
|
||||
GSnd->ChannelPitch(chan, max(0.0001f, pitch));
|
||||
chan->Pitch = max(1, int(float(DEFAULT_PITCH) * pitch));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "c_dispatch.h"
|
||||
#include "configfile.h"
|
||||
#include "filesystem.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "i_time.h"
|
||||
#include "printf.h"
|
||||
#include "sc_man.h"
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include "c_buttons.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include "printf.h"
|
||||
#include "cmdlib.h"
|
||||
|
|
|
@ -144,7 +144,7 @@ void FCommandBuffer::MakeStartPosGood()
|
|||
{ // The cursor is in front of the visible part of the line
|
||||
n = CursorPosCells;
|
||||
}
|
||||
StartPosCells = std::max(0, n);
|
||||
StartPosCells = max(0, n);
|
||||
bool overflow;
|
||||
StartPos = CharsForCells(StartPosCells, &overflow);
|
||||
if (overflow)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "c_bind.h"
|
||||
#include "c_console.h"
|
||||
|
@ -856,7 +856,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
|
|||
{ // Scroll console buffer down
|
||||
if (ev->subtype == EV_GUI_WheelDown)
|
||||
{
|
||||
RowAdjust = std::max (0, RowAdjust - 3);
|
||||
RowAdjust = max (0, RowAdjust - 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "cmdlib.h"
|
||||
#include "c_console.h"
|
||||
#include "c_dispatch.h"
|
||||
|
@ -1092,7 +1092,7 @@ void C_SearchForPullins(FExecList *exec, const char *file, FCommandLine &argv)
|
|||
|
||||
lastSlash1 = strrchr(file, '/');
|
||||
lastSlash2 = strrchr(file, '\\');
|
||||
lastSlash = MAX(lastSlash1, lastSlash2);
|
||||
lastSlash = max(lastSlash1, lastSlash2);
|
||||
#endif
|
||||
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
|
|
|
@ -273,7 +273,7 @@ bool C_TabCompleteList ()
|
|||
}
|
||||
}
|
||||
nummatches++;
|
||||
maxwidth = std::max (maxwidth, strlen (TabCommands[i].TabName.GetChars()));
|
||||
maxwidth = max (maxwidth, strlen (TabCommands[i].TabName.GetChars()));
|
||||
}
|
||||
}
|
||||
if (nummatches > 1)
|
||||
|
|
|
@ -562,7 +562,7 @@ public:
|
|||
}
|
||||
flags = flags_;
|
||||
Smacker_GetFrameSize(hSMK, nWidth, nHeight);
|
||||
pFrame.Resize(nWidth * nHeight + std::max(nWidth, nHeight));
|
||||
pFrame.Resize(nWidth * nHeight + max(nWidth, nHeight));
|
||||
float frameRate = Smacker_GetFrameRate(hSMK);
|
||||
nFrameNs = uint64_t(1'000'000'000 / frameRate);
|
||||
nFrames = Smacker_GetNumFrames(hSMK);
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include "v_draw.h"
|
||||
#include "s_music.h"
|
||||
#include "cmdlib.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
#include "cmdlib.h"
|
||||
#include "printf.h"
|
||||
#include "i_interface.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
#include "i_net.h"
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "m_crc32.h"
|
||||
#include "printf.h"
|
||||
#include "colormatcher.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "palettecontainer.h"
|
||||
#include "files.h"
|
||||
|
||||
|
@ -565,9 +565,9 @@ bool FRemapTable::AddDesaturation(int start, int end, double r1, double g1, doub
|
|||
GPalette.BaseColors[c].g * 143 +
|
||||
GPalette.BaseColors[c].b * 37) / 256.0;
|
||||
|
||||
PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)),
|
||||
MIN(255, int(g1 + intensity*g2)),
|
||||
MIN(255, int(b1 + intensity*b2)));
|
||||
PalEntry pe = PalEntry( min(255, int(r1 + intensity*r2)),
|
||||
min(255, int(g1 + intensity*g2)),
|
||||
min(255, int(b1 + intensity*b2)));
|
||||
|
||||
int cc = GPalette.Remap[c];
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "basics.h"
|
||||
#include "renderstyle.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
#include "engineerrors.h"
|
||||
#include "sc_man.h"
|
||||
#include "cmdlib.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "printf.h"
|
||||
#include "name.h"
|
||||
#include "v_text.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "zstring.h"
|
||||
#include "name.h"
|
||||
#include <inttypes.h>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
//==========================================================================
|
||||
|
@ -219,7 +219,7 @@ int FRFFLump::FillCache()
|
|||
|
||||
if (Flags & LUMPF_COMPRESSED)
|
||||
{
|
||||
int cryptlen = MIN<int> (LumpSize, 256);
|
||||
int cryptlen = min<int> (LumpSize, 256);
|
||||
uint8_t *data = (uint8_t *)Cache;
|
||||
|
||||
for (int i = 0; i < cryptlen; ++i)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <time.h>
|
||||
#include "file_zip.h"
|
||||
#include "cmdlib.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "printf.h"
|
||||
#include "w_zip.h"
|
||||
|
||||
|
@ -124,7 +124,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin)
|
|||
uint32_t uPosFound=0;
|
||||
|
||||
FileSize = (uint32_t)fin.GetLength();
|
||||
uMaxBack = MIN<uint32_t>(0xffff, FileSize);
|
||||
uMaxBack = min<uint32_t>(0xffff, FileSize);
|
||||
|
||||
uBackRead = 4;
|
||||
while (uBackRead < uMaxBack)
|
||||
|
@ -137,7 +137,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin)
|
|||
uBackRead += BUFREADCOMMENT;
|
||||
uReadPos = FileSize - uBackRead;
|
||||
|
||||
uReadSize = MIN<uint32_t>((BUFREADCOMMENT + 4), (FileSize - uReadPos));
|
||||
uReadSize = min<uint32_t>((BUFREADCOMMENT + 4), (FileSize - uReadPos));
|
||||
|
||||
if (fin.Seek(uReadPos, FileReader::SeekSet) != 0) break;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "m_swap.h"
|
||||
#include "v_font.h"
|
||||
#include "printf.h"
|
||||
|
@ -936,7 +936,7 @@ int FFont::StringWidth(const uint8_t *string, int spacing) const
|
|||
}
|
||||
}
|
||||
|
||||
return std::max(maxw, w);
|
||||
return max(maxw, w);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "m_swap.h"
|
||||
#include "v_font.h"
|
||||
#include "filesystem.h"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "texturemanager.h"
|
||||
#include "printf.h"
|
||||
#include "i_interface.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
|
||||
bool CheckSkipGameOptionBlock(FScanner& sc);
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
// HEADER FILES ------------------------------------------------------------
|
||||
|
||||
#include "dobject.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include "menu.h"
|
||||
#include "stats.h"
|
||||
|
@ -348,7 +348,7 @@ static size_t SingleStep()
|
|||
State = GCS_Finalize;
|
||||
}
|
||||
//assert(old >= AllocBytes);
|
||||
Estimate -= MAX<size_t>(0, old - AllocBytes);
|
||||
Estimate -= max<size_t>(0, old - AllocBytes);
|
||||
return (GCSWEEPMAX - finalize_count) * GCSWEEPCOST + finalize_count * GCFINALIZECOST;
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ CCMD(gc)
|
|||
}
|
||||
else
|
||||
{
|
||||
GC::Pause = MAX(1,atoi(argv[2]));
|
||||
GC::Pause = max(1,atoi(argv[2]));
|
||||
}
|
||||
}
|
||||
else if (stricmp(argv[1], "stepmul") == 0)
|
||||
|
@ -636,7 +636,7 @@ CCMD(gc)
|
|||
}
|
||||
else
|
||||
{
|
||||
GC::StepMul = MAX(100, atoi(argv[2]));
|
||||
GC::StepMul = max(100, atoi(argv[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,11 +284,11 @@ uint8_t ModifierToDIK(const uint32_t modifier)
|
|||
{
|
||||
switch (modifier)
|
||||
{
|
||||
case NSAlphaShiftKeyMask: return DIK_CAPITAL;
|
||||
case NSShiftKeyMask: return DIK_LSHIFT;
|
||||
case NSControlKeyMask: return DIK_LCONTROL;
|
||||
case NSAlternateKeyMask: return DIK_LMENU;
|
||||
case NSCommandKeyMask: return DIK_LWIN;
|
||||
case NSEventModifierFlagCapsLock: return DIK_CAPITAL;
|
||||
case NSEventModifierFlagShift: return DIK_LSHIFT;
|
||||
case NSEventModifierFlagControl: return DIK_LCONTROL;
|
||||
case NSEventModifierFlagOption: return DIK_LMENU;
|
||||
case NSEventModifierFlagCommand: return DIK_LWIN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -296,20 +296,20 @@ uint8_t ModifierToDIK(const uint32_t modifier)
|
|||
|
||||
int16_t ModifierFlagsToGUIKeyModifiers(NSEvent* theEvent)
|
||||
{
|
||||
const NSUInteger modifiers([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask);
|
||||
return ((modifiers & NSShiftKeyMask ) ? GKM_SHIFT : 0)
|
||||
| ((modifiers & NSControlKeyMask ) ? GKM_CTRL : 0)
|
||||
| ((modifiers & NSAlternateKeyMask) ? GKM_ALT : 0)
|
||||
| ((modifiers & NSCommandKeyMask ) ? GKM_META : 0);
|
||||
const NSUInteger modifiers([theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask);
|
||||
return ((modifiers & NSEventModifierFlagShift ) ? GKM_SHIFT : 0)
|
||||
| ((modifiers & NSEventModifierFlagControl) ? GKM_CTRL : 0)
|
||||
| ((modifiers & NSEventModifierFlagOption ) ? GKM_ALT : 0)
|
||||
| ((modifiers & NSEventModifierFlagCommand) ? GKM_META : 0);
|
||||
}
|
||||
|
||||
bool ShouldGenerateGUICharEvent(NSEvent* theEvent)
|
||||
{
|
||||
const NSUInteger modifiers([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask);
|
||||
return !(modifiers & NSControlKeyMask)
|
||||
&& !(modifiers & NSAlternateKeyMask)
|
||||
&& !(modifiers & NSCommandKeyMask)
|
||||
&& !(modifiers & NSFunctionKeyMask);
|
||||
const NSUInteger modifiers([theEvent modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask);
|
||||
return !(modifiers & NSEventModifierFlagControl)
|
||||
&& !(modifiers & NSEventModifierFlagOption)
|
||||
&& !(modifiers & NSEventModifierFlagCommand)
|
||||
&& !(modifiers & NSEventModifierFlagFunction);
|
||||
}
|
||||
|
||||
|
||||
|
@ -373,7 +373,7 @@ void ProcessKeyboardEventInMenu(NSEvent* theEvent)
|
|||
|
||||
unichar realchar;
|
||||
event.type = EV_GUI_Event;
|
||||
event.subtype = NSKeyDown == [theEvent type] ? EV_GUI_KeyDown : EV_GUI_KeyUp;
|
||||
event.subtype = NSEventTypeKeyDown == [theEvent type] ? EV_GUI_KeyDown : EV_GUI_KeyUp;
|
||||
event.data2 = GetCharacterFromNSEvent(theEvent, &realchar);
|
||||
event.data3 = ModifierFlagsToGUIKeyModifiers(theEvent);
|
||||
|
||||
|
@ -505,8 +505,8 @@ void ProcessKeyboardEvent(NSEvent* theEvent)
|
|||
|
||||
if (k_allowfullscreentoggle
|
||||
&& (kVK_ANSI_F == keyCode)
|
||||
&& (NSCommandKeyMask & [theEvent modifierFlags])
|
||||
&& (NSKeyDown == [theEvent type])
|
||||
&& (NSEventModifierFlagCommand & [theEvent modifierFlags])
|
||||
&& (NSEventTypeKeyDown == [theEvent type])
|
||||
&& !isARepeat)
|
||||
{
|
||||
ToggleFullscreen = !ToggleFullscreen;
|
||||
|
@ -521,7 +521,7 @@ void ProcessKeyboardEvent(NSEvent* theEvent)
|
|||
{
|
||||
event_t event = {};
|
||||
|
||||
event.type = NSKeyDown == [theEvent type] ? EV_KeyDown : EV_KeyUp;
|
||||
event.type = NSEventTypeKeyDown == [theEvent type] ? EV_KeyDown : EV_KeyUp;
|
||||
event.data1 = KEYCODE_TO_DIK[ keyCode ];
|
||||
|
||||
if (0 != event.data1)
|
||||
|
@ -542,7 +542,7 @@ void ProcessKeyboardFlagsEvent(NSEvent* theEvent)
|
|||
}
|
||||
|
||||
static const uint32_t FLAGS_MASK =
|
||||
NSDeviceIndependentModifierFlagsMask & ~NSNumericPadKeyMask;
|
||||
NSEventModifierFlagDeviceIndependentFlagsMask & ~NSEventModifierFlagNumericPad;
|
||||
|
||||
const uint32_t modifiers = [theEvent modifierFlags] & FLAGS_MASK;
|
||||
static uint32_t oldModifiers = 0;
|
||||
|
@ -611,12 +611,12 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
|
|||
|
||||
switch (cocoaEventType)
|
||||
{
|
||||
case NSLeftMouseDown: event.subtype = EV_GUI_LButtonDown; break;
|
||||
case NSRightMouseDown: event.subtype = EV_GUI_RButtonDown; break;
|
||||
case NSOtherMouseDown: event.subtype = EV_GUI_MButtonDown; break;
|
||||
case NSLeftMouseUp: event.subtype = EV_GUI_LButtonUp; break;
|
||||
case NSRightMouseUp: event.subtype = EV_GUI_RButtonUp; break;
|
||||
case NSOtherMouseUp: event.subtype = EV_GUI_MButtonUp; break;
|
||||
case NSEventTypeLeftMouseDown: event.subtype = EV_GUI_LButtonDown; break;
|
||||
case NSEventTypeRightMouseDown: event.subtype = EV_GUI_RButtonDown; break;
|
||||
case NSEventTypeOtherMouseDown: event.subtype = EV_GUI_MButtonDown; break;
|
||||
case NSEventTypeLeftMouseUp: event.subtype = EV_GUI_LButtonUp; break;
|
||||
case NSEventTypeRightMouseUp: event.subtype = EV_GUI_RButtonUp; break;
|
||||
case NSEventTypeOtherMouseUp: event.subtype = EV_GUI_MButtonUp; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -628,15 +628,15 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
|
|||
{
|
||||
switch (cocoaEventType)
|
||||
{
|
||||
case NSLeftMouseDown:
|
||||
case NSRightMouseDown:
|
||||
case NSOtherMouseDown:
|
||||
case NSEventTypeLeftMouseDown:
|
||||
case NSEventTypeRightMouseDown:
|
||||
case NSEventTypeOtherMouseDown:
|
||||
event.type = EV_KeyDown;
|
||||
break;
|
||||
|
||||
case NSLeftMouseUp:
|
||||
case NSRightMouseUp:
|
||||
case NSOtherMouseUp:
|
||||
case NSEventTypeLeftMouseUp:
|
||||
case NSEventTypeRightMouseUp:
|
||||
case NSEventTypeOtherMouseUp:
|
||||
event.type = EV_KeyUp;
|
||||
break;
|
||||
|
||||
|
@ -644,7 +644,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
|
|||
break;
|
||||
}
|
||||
|
||||
event.data1 = MIN(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8));
|
||||
event.data1 = min(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8));
|
||||
|
||||
D_PostEvent(&event);
|
||||
}
|
||||
|
@ -694,36 +694,36 @@ void I_ProcessEvent(NSEvent* event)
|
|||
|
||||
switch (eventType)
|
||||
{
|
||||
case NSMouseMoved:
|
||||
case NSEventTypeMouseMoved:
|
||||
ProcessMouseMoveEvent(event);
|
||||
break;
|
||||
|
||||
case NSLeftMouseDown:
|
||||
case NSLeftMouseUp:
|
||||
case NSRightMouseDown:
|
||||
case NSRightMouseUp:
|
||||
case NSOtherMouseDown:
|
||||
case NSOtherMouseUp:
|
||||
case NSEventTypeLeftMouseDown:
|
||||
case NSEventTypeLeftMouseUp:
|
||||
case NSEventTypeRightMouseDown:
|
||||
case NSEventTypeRightMouseUp:
|
||||
case NSEventTypeOtherMouseDown:
|
||||
case NSEventTypeOtherMouseUp:
|
||||
ProcessMouseButtonEvent(event);
|
||||
break;
|
||||
|
||||
case NSLeftMouseDragged:
|
||||
case NSRightMouseDragged:
|
||||
case NSOtherMouseDragged:
|
||||
case NSEventTypeLeftMouseDragged:
|
||||
case NSEventTypeRightMouseDragged:
|
||||
case NSEventTypeOtherMouseDragged:
|
||||
ProcessMouseButtonEvent(event);
|
||||
ProcessMouseMoveEvent(event);
|
||||
break;
|
||||
|
||||
case NSScrollWheel:
|
||||
case NSEventTypeScrollWheel:
|
||||
ProcessMouseWheelEvent(event);
|
||||
break;
|
||||
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
case NSEventTypeKeyDown:
|
||||
case NSEventTypeKeyUp:
|
||||
ProcessKeyboardEvent(event);
|
||||
break;
|
||||
|
||||
case NSFlagsChanged:
|
||||
case NSEventTypeFlagsChanged:
|
||||
ProcessKeyboardFlagsEvent(event);
|
||||
break;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "i_system.h"
|
||||
#include "m_argv.h"
|
||||
#include "m_joy.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "v_text.h"
|
||||
#include "printf.h"
|
||||
#include "keydef.h"
|
||||
|
|
|
@ -73,23 +73,6 @@ void Mac_I_FatalError(const char* const message)
|
|||
}
|
||||
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
|
||||
// Available since 10.9 with no public declaration/definition until 10.10
|
||||
|
||||
struct NSOperatingSystemVersion
|
||||
{
|
||||
NSInteger majorVersion;
|
||||
NSInteger minorVersion;
|
||||
NSInteger patchVersion;
|
||||
};
|
||||
|
||||
@interface NSProcessInfo(OperatingSystemVersion)
|
||||
- (NSOperatingSystemVersion)operatingSystemVersion;
|
||||
@end
|
||||
|
||||
#endif // before 10.10
|
||||
|
||||
static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 110000
|
||||
|
@ -169,9 +152,6 @@ void I_DetectOS()
|
|||
case 10:
|
||||
switch (version.minorVersion)
|
||||
{
|
||||
case 9: name = "OS X Mavericks"; break;
|
||||
case 10: name = "OS X Yosemite"; break;
|
||||
case 11: name = "OS X El Capitan"; break;
|
||||
case 12: name = "macOS Sierra"; break;
|
||||
case 13: name = "macOS High Sierra"; break;
|
||||
case 14: name = "macOS Mojave"; break;
|
||||
|
@ -196,9 +176,7 @@ void I_DetectOS()
|
|||
sysctlbyname("hw.model", model, &size, nullptr, 0);
|
||||
|
||||
const char* const architecture =
|
||||
#ifdef __i386__
|
||||
"32-bit Intel";
|
||||
#elif defined __x86_64__
|
||||
#ifdef __x86_64__
|
||||
"64-bit Intel";
|
||||
#elif defined __aarch64__
|
||||
"64-bit ARM";
|
||||
|
@ -396,7 +374,7 @@ extern bool AppActive;
|
|||
|
||||
while (true)
|
||||
{
|
||||
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||
untilDate:[NSDate dateWithTimeIntervalSinceNow:0]
|
||||
inMode:NSDefaultRunLoopMode
|
||||
dequeue:YES];
|
||||
|
@ -449,7 +427,7 @@ NSMenuItem* CreateApplicationMenu()
|
|||
[[menu addItemWithTitle:@"Hide Others"
|
||||
action:@selector(hideOtherApplications:)
|
||||
keyEquivalent:@"h"]
|
||||
setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask];
|
||||
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
|
||||
[menu addItemWithTitle:@"Show All"
|
||||
action:@selector(unhideAllApplications:)
|
||||
keyEquivalent:@""];
|
||||
|
|
|
@ -121,8 +121,8 @@ namespace
|
|||
const NSInteger LEVEL_FULLSCREEN = NSMainMenuWindowLevel + 1;
|
||||
const NSInteger LEVEL_WINDOWED = NSNormalWindowLevel;
|
||||
|
||||
const NSUInteger STYLE_MASK_FULLSCREEN = NSBorderlessWindowMask;
|
||||
const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;
|
||||
const NSUInteger STYLE_MASK_FULLSCREEN = NSWindowStyleMaskBorderless;
|
||||
const NSUInteger STYLE_MASK_WINDOWED = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
|
||||
}
|
||||
|
||||
|
||||
|
@ -969,7 +969,7 @@ bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
|
|||
else
|
||||
{
|
||||
const bool result = *count >= extensionCount;
|
||||
*count = std::min(*count, extensionCount);
|
||||
*count = min(*count, extensionCount);
|
||||
|
||||
for (unsigned int i = 0; i < *count; ++i)
|
||||
{
|
||||
|
|
|
@ -104,7 +104,7 @@ FConsoleWindow::FConsoleWindow()
|
|||
NSString* const title = [NSString stringWithFormat:@"%s %s - Console", GAMENAME, GetVersionString()];
|
||||
|
||||
[m_window initWithContentRect:initialRect
|
||||
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
|
||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
[m_window setMinSize:[m_window frame].size];
|
||||
|
@ -348,7 +348,7 @@ void FConsoleWindow::SetTitleText()
|
|||
NSTextField* titleText = [[NSTextField alloc] initWithFrame:titleTextRect];
|
||||
[titleText setStringValue:[NSString stringWithCString:GameStartupInfo.Name.GetChars()
|
||||
encoding:NSISOLatin1StringEncoding]];
|
||||
[titleText setAlignment:NSCenterTextAlignment];
|
||||
[titleText setAlignment:NSTextAlignmentCenter];
|
||||
[titleText setTextColor:RGB(GameStartupInfo.FgColor)];
|
||||
[titleText setBackgroundColor:RGB(GameStartupInfo.BkColor)];
|
||||
[titleText setFont:[NSFont fontWithName:@"Trebuchet MS Bold" size:18.0f]];
|
||||
|
@ -434,7 +434,7 @@ void FConsoleWindow::NetInit(const char* const message, const int playerCount)
|
|||
// Text with connected/total players count
|
||||
m_netCountText = [[NSTextField alloc] initWithFrame:NSMakeRect(428.0f, 64.0f, 72.0f, 16.0f)];
|
||||
[m_netCountText setAutoresizingMask:NSViewMinXMargin];
|
||||
[m_netCountText setAlignment:NSRightTextAlignment];
|
||||
[m_netCountText setAlignment:NSTextAlignmentRight];
|
||||
[m_netCountText setDrawsBackground:NO];
|
||||
[m_netCountText setSelectable:NO];
|
||||
[m_netCountText setBordered:NO];
|
||||
|
@ -510,7 +510,7 @@ void FConsoleWindow::NetProgress(const int count)
|
|||
if (m_netMaxPos > 1)
|
||||
{
|
||||
[m_netCountText setStringValue:[NSString stringWithFormat:@"%d / %d", m_netCurPos, m_netMaxPos]];
|
||||
[m_netProgressBar setDoubleValue:MIN(m_netCurPos, m_netMaxPos)];
|
||||
[m_netProgressBar setDoubleValue:min(m_netCurPos, m_netMaxPos)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ static NSArray* GetKnownExtensions()
|
|||
[openPanel setResolvesAliases:YES];
|
||||
[openPanel setAllowedFileTypes:GetKnownExtensions()];
|
||||
|
||||
if (NSOKButton == [openPanel runModal])
|
||||
if (NSModalResponseOK == [openPanel runModal])
|
||||
{
|
||||
NSArray* files = [openPanel URLs];
|
||||
NSMutableString* parameters = [NSMutableString string];
|
||||
|
@ -259,7 +259,7 @@ static NSArray* GetKnownExtensions()
|
|||
id windowTitle = [NSString stringWithFormat:@"%s %s", GAMENAME, GetVersionString()];
|
||||
|
||||
NSRect frame = NSMakeRect(0, 0, 440, 450);
|
||||
window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO];
|
||||
window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskTitled backing:NSBackingStoreBuffered defer:NO];
|
||||
[window setTitle:windowTitle];
|
||||
|
||||
NSTextField *description = [[NSTextField alloc] initWithFrame:NSMakeRect(18, 384, 402, 50)];
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "basics.h"
|
||||
#include "cmdlib.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "m_joy.h"
|
||||
#include "keydef.h"
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "gl_sysfb.h"
|
||||
#include "hardware.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "c_console.h"
|
||||
#include "v_video.h"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "gl_sysfb.h"
|
||||
#include "hardware.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "c_console.h"
|
||||
#include "v_video.h"
|
||||
|
|
|
@ -111,9 +111,9 @@ void I_InitGraphics ()
|
|||
// todo: implement ATI version of this. this only works for nvidia notebooks, for now.
|
||||
currentgpuswitch = vid_gpuswitch;
|
||||
if (currentgpuswitch == 1)
|
||||
putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
|
||||
_putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
|
||||
else if (currentgpuswitch == 2)
|
||||
putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
|
||||
_putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
|
||||
|
||||
// If the focus window is destroyed, it doesn't go back to the active window.
|
||||
// (e.g. because the net pane was up, and a button on it had focus)
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
// HEADER FILES ------------------------------------------------------------
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <richedit.h>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "i_input.h"
|
||||
#include "d_eventbase.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "gameconfigfile.h"
|
||||
#include "cmdlib.h"
|
||||
#include "v_text.h"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "i_input.h"
|
||||
#include "d_eventbase.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "gameconfigfile.h"
|
||||
#include "m_argv.h"
|
||||
#include "cmdlib.h"
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
// HEADER FILES ------------------------------------------------------------
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -73,7 +74,7 @@
|
|||
|
||||
#include "i_input.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "gameconfigfile.h"
|
||||
#include "v_font.h"
|
||||
#include "i_system.h"
|
||||
|
@ -778,7 +779,7 @@ static HCURSOR CreateAlphaCursor(FBitmap &source, int leftofs, int topofs)
|
|||
// Find closest integer scale factor for the monitor DPI
|
||||
HDC screenDC = GetDC(0);
|
||||
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
|
||||
int scale = std::max((dpi + 96 / 2 - 1) / 96, 1);
|
||||
int scale = max((dpi + 96 / 2 - 1) / 96, 1);
|
||||
ReleaseDC(0, screenDC);
|
||||
|
||||
memset(&bi, 0, sizeof(bi));
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "i_input.h"
|
||||
#include "d_eventbase.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "gameconfigfile.h"
|
||||
#include "m_argv.h"
|
||||
#include "cmdlib.h"
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
#include "st_start.h"
|
||||
#include "cmdlib.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "i_system.h"
|
||||
#include "i_input.h"
|
||||
#include "hardware.h"
|
||||
|
@ -351,7 +351,7 @@ void FBasicStartupScreen :: NetProgress(int count)
|
|||
|
||||
mysnprintf (buf, countof(buf), "%d/%d", NetCurPos, NetMaxPos);
|
||||
SetDlgItemTextA (NetStartPane, IDC_NETSTARTCOUNT, buf);
|
||||
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, std::min(NetCurPos, NetMaxPos), 0);
|
||||
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, min(NetCurPos, NetMaxPos), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -831,7 +831,7 @@ void FStrifeStartupScreen::DrawStuff(int old_laser, int new_laser)
|
|||
ST_LASERSPACE_X + new_laser, ST_LASERSPACE_Y, ST_LASER_WIDTH, ST_LASER_HEIGHT);
|
||||
|
||||
// The bot jumps up and down like crazy.
|
||||
y = std::max(0, (new_laser >> 1) % 5 - 2);
|
||||
y = max(0, (new_laser >> 1) % 5 - 2);
|
||||
if (y > 0)
|
||||
{
|
||||
ST_Util_ClearBlock(bitmap_info, 0xF0, ST_BOT_X, ST_BOT_Y, ST_BOT_WIDTH, y);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include "hardware.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "c_console.h"
|
||||
#include "v_video.h"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "gl_sysfb.h"
|
||||
#include "hardware.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "c_console.h"
|
||||
#include "v_video.h"
|
||||
|
|
|
@ -25,6 +25,17 @@
|
|||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="TSparseArrayView<*>">
|
||||
<DisplayString>Size = {Count}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Size">Count</Item>
|
||||
<ArrayItems>
|
||||
<Size>Count</Size>
|
||||
<ValuePointer>(value_type*)Array</ValuePointer>
|
||||
</ArrayItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="TStaticPointedArray<*>">
|
||||
<DisplayString>Size = {Count}</DisplayString>
|
||||
<Expand>
|
||||
|
|
|
@ -76,16 +76,20 @@ void GLBuffer::Bind()
|
|||
}
|
||||
|
||||
|
||||
void GLBuffer::SetData(size_t size, const void *data, bool staticdata)
|
||||
void GLBuffer::SetData(size_t size, const void *data, BufferUsageType usage)
|
||||
{
|
||||
Bind();
|
||||
if (data != nullptr)
|
||||
if (usage == BufferUsageType::Static)
|
||||
{
|
||||
glBufferData(mUseType, size, data, staticdata? GL_STATIC_DRAW : GL_STREAM_DRAW);
|
||||
glBufferData(mUseType, size, data, GL_STATIC_DRAW);
|
||||
}
|
||||
else
|
||||
else if (usage == BufferUsageType::Stream)
|
||||
{
|
||||
mPersistent = screen->BuffersArePersistent() && !staticdata;
|
||||
glBufferData(mUseType, size, data, GL_STREAM_DRAW);
|
||||
}
|
||||
else if (usage == BufferUsageType::Persistent)
|
||||
{
|
||||
mPersistent = screen->BuffersArePersistent();
|
||||
if (mPersistent)
|
||||
{
|
||||
glBufferStorage(mUseType, size, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
|
@ -93,10 +97,15 @@ void GLBuffer::SetData(size_t size, const void *data, bool staticdata)
|
|||
}
|
||||
else
|
||||
{
|
||||
glBufferData(mUseType, size, nullptr, staticdata ? GL_STATIC_DRAW : GL_STREAM_DRAW);
|
||||
glBufferData(mUseType, size, nullptr, GL_STREAM_DRAW);
|
||||
map = nullptr;
|
||||
}
|
||||
if (!staticdata) nomap = false;
|
||||
nomap = false;
|
||||
}
|
||||
else if (usage == BufferUsageType::Mappable)
|
||||
{
|
||||
glBufferData(mUseType, size, nullptr, GL_STATIC_DRAW);
|
||||
map = nullptr;
|
||||
}
|
||||
buffersize = size;
|
||||
InvalidateBufferState();
|
||||
|
@ -134,7 +143,7 @@ void GLBuffer::Unmap()
|
|||
void *GLBuffer::Lock(unsigned int size)
|
||||
{
|
||||
// This initializes this buffer as a static object with no data.
|
||||
SetData(size, nullptr, true);
|
||||
SetData(size, nullptr, BufferUsageType::Mappable);
|
||||
return glMapBufferRange(mUseType, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
}
|
||||
|
||||
|
@ -158,7 +167,7 @@ void GLBuffer::Resize(size_t newsize)
|
|||
glUnmapBuffer(mUseType);
|
||||
|
||||
glGenBuffers(1, &mBufferId);
|
||||
SetData(newsize, nullptr, false);
|
||||
SetData(newsize, nullptr, BufferUsageType::Persistent);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, oldbuffer);
|
||||
|
||||
// copy contents and delete the old buffer.
|
||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
|||
|
||||
GLBuffer(int usetype);
|
||||
~GLBuffer();
|
||||
void SetData(size_t size, const void *data, bool staticdata) override;
|
||||
void SetData(size_t size, const void *data, BufferUsageType usage) override;
|
||||
void SetSubData(size_t offset, size_t size, const void *data) override;
|
||||
void Map() override;
|
||||
void Unmap() override;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gl_debug.h"
|
||||
#include "stats.h"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "gl_system.h"
|
||||
#include "v_video.h"
|
||||
#include "m_png.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "i_time.h"
|
||||
|
||||
#include "gl_interface.h"
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "c_cvars.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "flatvertices.h"
|
||||
#include "r_videoscale.h"
|
||||
#include "v_video.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "hw_vrmodes.h"
|
||||
#include "v_draw.h"
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gl_interface.h"
|
||||
#include "gl_postprocessstate.h"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "gl_postprocessstate.h"
|
||||
#include "gl_shaderprogram.h"
|
||||
#include "gl_buffers.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include <random>
|
||||
|
||||
EXTERN_CVAR(Int, gl_debug_level)
|
||||
|
@ -952,7 +952,7 @@ void GLPPRenderState::Draw()
|
|||
{
|
||||
if (!shader->Uniforms)
|
||||
shader->Uniforms.reset(screen->CreateDataBuffer(POSTPROCESS_BINDINGPOINT, false, false));
|
||||
shader->Uniforms->SetData(Uniforms.Data.Size(), Uniforms.Data.Data());
|
||||
shader->Uniforms->SetData(Uniforms.Data.Size(), Uniforms.Data.Data(), BufferUsageType::Static);
|
||||
static_cast<GLDataBuffer*>(shader->Uniforms.get())->BindBase();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gl_interface.h"
|
||||
#include "hw_cvars.h"
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
|
||||
void EnableDrawBuffers(int count, bool apply = false) override
|
||||
{
|
||||
count = std::min(count, 3);
|
||||
count = min(count, 3);
|
||||
if (mNumDrawBuffers != count)
|
||||
{
|
||||
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
EXTERN_CVAR(Bool, r_skipmats)
|
||||
|
||||
namespace OpenGLRenderer
|
||||
{
|
||||
|
||||
|
@ -729,6 +731,9 @@ FShader *FShaderManager::BindEffect(int effect, EPassType passType)
|
|||
|
||||
FShader *FShaderManager::Get(unsigned int eff, bool alphateston, EPassType passType)
|
||||
{
|
||||
if (r_skipmats && eff >= 3 && eff <= 4)
|
||||
eff = 0;
|
||||
|
||||
if (passType < mPassShaders.Size())
|
||||
return mPassShaders[passType]->Get(eff, alphateston);
|
||||
else
|
||||
|
|
|
@ -263,7 +263,7 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const
|
|||
|
||||
// If we have 4.2, always use it because it adds important new syntax.
|
||||
if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420;
|
||||
int shaderVersion = std::min((int)round(gl.glslversion * 10) * 10, maxGlslVersion);
|
||||
int shaderVersion = min((int)round(gl.glslversion * 10) * 10, maxGlslVersion);
|
||||
patchedCode.AppendFormat("#version %d\n", shaderVersion);
|
||||
|
||||
// TODO: Find some way to add extension requirements to the patching
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "gl_framebuffer.h"
|
||||
#include "gl_shaderprogram.h"
|
||||
#include "gl_buffers.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
EXTERN_CVAR(Int, vr_mode)
|
||||
EXTERN_CVAR(Float, vid_saturation)
|
||||
|
|
|
@ -93,8 +93,9 @@ void GLBuffer::Bind()
|
|||
}
|
||||
|
||||
|
||||
void GLBuffer::SetData(size_t size, const void* data, bool staticdata)
|
||||
void GLBuffer::SetData(size_t size, const void* data, BufferUsageType usage)
|
||||
{
|
||||
bool staticdata = (usage == BufferUsageType::Static || usage == BufferUsageType::Mappable);
|
||||
if (isData || !gles.useMappedBuffers)
|
||||
{
|
||||
if (memory)
|
||||
|
@ -175,7 +176,7 @@ void GLBuffer::Unmap()
|
|||
void *GLBuffer::Lock(unsigned int size)
|
||||
{
|
||||
// This initializes this buffer as a static object with no data.
|
||||
SetData(size, nullptr, true);
|
||||
SetData(size, nullptr, BufferUsageType::Mappable);
|
||||
if (!isData && gles.useMappedBuffers)
|
||||
{
|
||||
return glMapBufferRange(mUseType, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
|||
|
||||
GLBuffer(int usetype);
|
||||
~GLBuffer();
|
||||
void SetData(size_t size, const void *data, bool staticdata) override;
|
||||
void SetData(size_t size, const void *data, BufferUsageType usage) override;
|
||||
void SetSubData(size_t offset, size_t size, const void *data) override;
|
||||
void Map() override;
|
||||
void Unmap() override;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "gles_system.h"
|
||||
#include "v_video.h"
|
||||
#include "m_png.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "i_time.h"
|
||||
|
||||
#include "gles_framebuffer.h"
|
||||
|
@ -122,7 +122,7 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
{
|
||||
static bool first=true;
|
||||
|
||||
mPipelineNbr = gl_pipeline_depth == 0? std::min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS);
|
||||
mPipelineNbr = gl_pipeline_depth == 0? min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS);
|
||||
mPipelineType = 1;
|
||||
|
||||
InitGLES();
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include "gles_system.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "c_cvars.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "flatvertices.h"
|
||||
#include "r_videoscale.h"
|
||||
#include "v_video.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "hw_vrmodes.h"
|
||||
#include "v_draw.h"
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "gles_system.h"
|
||||
#include "gles_postprocessstate.h"
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "gles_postprocessstate.h"
|
||||
#include "gles_shaderprogram.h"
|
||||
#include "gles_buffers.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include <random>
|
||||
|
||||
EXTERN_CVAR(Int, gl_debug_level)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
#include "gles_system.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "flatvertices.h"
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
void EnableDrawBuffers(int count, bool apply = false) override
|
||||
{
|
||||
/*
|
||||
count = std::min(count, 3);
|
||||
count = min(count, 3);
|
||||
if (mNumDrawBuffers != count)
|
||||
{
|
||||
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
void SetData()
|
||||
{
|
||||
if (mBuffer != nullptr)
|
||||
mBuffer->SetData(sizeof(T), &Values);
|
||||
mBuffer->SetData(sizeof(T), &Values, BufferUsageType::Static);
|
||||
}
|
||||
|
||||
IDataBuffer* GetBuffer() const
|
||||
|
|
|
@ -46,6 +46,14 @@ struct FVertexBufferAttribute
|
|||
int offset;
|
||||
};
|
||||
|
||||
enum class BufferUsageType
|
||||
{
|
||||
Static, // initial data is not null, staticdata is true
|
||||
Stream, // initial data is not null, staticdata is false
|
||||
Persistent, // initial data is null, staticdata is false
|
||||
Mappable // initial data is null, staticdata is true
|
||||
};
|
||||
|
||||
class IBuffer
|
||||
{
|
||||
protected:
|
||||
|
@ -57,7 +65,7 @@ public:
|
|||
IBuffer &operator=(const IBuffer &) = delete;
|
||||
virtual ~IBuffer() = default;
|
||||
|
||||
virtual void SetData(size_t size, const void *data, bool staticdata = true) = 0;
|
||||
virtual void SetData(size_t size, const void *data, BufferUsageType type) = 0;
|
||||
virtual void SetSubData(size_t offset, size_t size, const void *data) = 0;
|
||||
virtual void *Lock(unsigned int size) = 0;
|
||||
virtual void Unlock() = 0;
|
||||
|
|
|
@ -81,7 +81,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height, int pipelineNbr):
|
|||
|
||||
mIndexBuffer = screen->CreateIndexBuffer();
|
||||
int data[4] = {};
|
||||
mIndexBuffer->SetData(4, data); // On Vulkan this may not be empty, so set some dummy defaults to avoid crashes.
|
||||
mIndexBuffer->SetData(4, data, BufferUsageType::Static); // On Vulkan this may not be empty, so set some dummy defaults to avoid crashes.
|
||||
|
||||
|
||||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
|
@ -89,7 +89,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height, int pipelineNbr):
|
|||
mVertexBufferPipeline[n] = screen->CreateVertexBuffer();
|
||||
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
mVertexBufferPipeline[n]->SetData(bytesize, nullptr, false);
|
||||
mVertexBufferPipeline[n]->SetData(bytesize, nullptr, BufferUsageType::Persistent);
|
||||
|
||||
static const FVertexBufferAttribute format[] = {
|
||||
{ 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FFlatVertex, x) },
|
||||
|
|
|
@ -64,7 +64,7 @@ FLightBuffer::FLightBuffer(int pipelineNbr):
|
|||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n] = screen->CreateDataBuffer(LIGHTBUF_BINDINGPOINT, mBufferType, false);
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, false);
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, BufferUsageType::Persistent);
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
|
|
@ -117,7 +117,7 @@ void IShadowMap::UploadLights()
|
|||
if (mLightList == nullptr)
|
||||
mLightList = screen->CreateDataBuffer(LIGHTLIST_BINDINGPOINT, true, false);
|
||||
|
||||
mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0]);
|
||||
mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0], BufferUsageType::Stream);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,11 +129,11 @@ void IShadowMap::UploadAABBTree()
|
|||
|
||||
if (!mNodesBuffer)
|
||||
mNodesBuffer = screen->CreateDataBuffer(LIGHTNODES_BINDINGPOINT, true, false);
|
||||
mNodesBuffer->SetData(mAABBTree->NodesSize(), mAABBTree->Nodes());
|
||||
mNodesBuffer->SetData(mAABBTree->NodesSize(), mAABBTree->Nodes(), BufferUsageType::Static);
|
||||
|
||||
if (!mLinesBuffer)
|
||||
mLinesBuffer = screen->CreateDataBuffer(LIGHTLINES_BINDINGPOINT, true, false);
|
||||
mLinesBuffer->SetData(mAABBTree->LinesSize(), mAABBTree->Lines());
|
||||
mLinesBuffer->SetData(mAABBTree->LinesSize(), mAABBTree->Lines(), BufferUsageType::Static);
|
||||
}
|
||||
else if (mAABBTree->Update())
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ std::pair<PalEntry, PalEntry>& R_GetSkyCapColor(FGameTexture* tex)
|
|||
const uint32_t* buffer = (const uint32_t*)bitmap.GetPixels();
|
||||
if (buffer)
|
||||
{
|
||||
sky.Colors.first = averageColor((uint32_t*)buffer, w * MIN(30, h), 0);
|
||||
sky.Colors.first = averageColor((uint32_t*)buffer, w * min(30, h), 0);
|
||||
if (h > 30)
|
||||
{
|
||||
sky.Colors.second = averageColor(((uint32_t*)buffer) + (h - 30) * w, w * 30, 0);
|
||||
|
@ -130,7 +130,7 @@ FSkyVertexBuffer::FSkyVertexBuffer()
|
|||
{ 0, VATTR_COLOR, VFmt_Byte4, (int)myoffsetof(FSkyVertex, color) }
|
||||
};
|
||||
mVertexBuffer->SetFormat(1, 3, sizeof(FSkyVertex), format);
|
||||
mVertexBuffer->SetData(mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], true);
|
||||
mVertexBuffer->SetData(mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], BufferUsageType::Static);
|
||||
}
|
||||
|
||||
FSkyVertexBuffer::~FSkyVertexBuffer()
|
||||
|
|
|
@ -12,10 +12,7 @@ struct HWSkyPortal;
|
|||
struct HWDrawInfo;
|
||||
|
||||
// 57 world units roughly represent one sky texel for the glTranslate call.
|
||||
enum
|
||||
{
|
||||
skyoffsetfactor = 57
|
||||
};
|
||||
const int skyoffsetfactor = 57;
|
||||
|
||||
struct FSkyVertex
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ HWViewpointBuffer::HWViewpointBuffer(int pipelineNbr):
|
|||
for (int n = 0; n < mPipelineNbr; n++)
|
||||
{
|
||||
mBufferPipeline[n] = screen->CreateDataBuffer(VIEWPOINT_BINDINGPOINT, false, true);
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, false);
|
||||
mBufferPipeline[n]->SetData(mByteSize, nullptr, BufferUsageType::Persistent);
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
void SetData()
|
||||
{
|
||||
if (mBuffer != nullptr)
|
||||
mBuffer->SetData(sizeof(T), &Values);
|
||||
mBuffer->SetData(sizeof(T), &Values, BufferUsageType::Static);
|
||||
}
|
||||
|
||||
IDataBuffer* GetBuffer() const
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
|
||||
#include <random>
|
||||
#include "texturemanager.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include "stats.h"
|
||||
|
||||
Postprocess hw_postprocess;
|
||||
|
@ -326,9 +326,9 @@ void PPLensDistort::Render(PPRenderState *renderstate)
|
|||
// Scale factor to keep sampling within the input texture
|
||||
float r2 = aspect * aspect * 0.25f + 0.25f;
|
||||
float sqrt_r2 = sqrt(r2);
|
||||
float f0 = 1.0f + MAX(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f);
|
||||
float f2 = 1.0f + MAX(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f);
|
||||
float f = MAX(f0, f2);
|
||||
float f0 = 1.0f + max(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f);
|
||||
float f2 = 1.0f + max(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f);
|
||||
float f = max(f0, f2);
|
||||
float scale = 1.0f / f;
|
||||
|
||||
LensUniforms uniforms;
|
||||
|
@ -498,8 +498,8 @@ void PPCameraExposure::Render(PPRenderState *renderstate, int sceneWidth, int sc
|
|||
|
||||
void PPCameraExposure::UpdateTextures(int width, int height)
|
||||
{
|
||||
int firstwidth = MAX(width / 2, 1);
|
||||
int firstheight = MAX(height / 2, 1);
|
||||
int firstwidth = max(width / 2, 1);
|
||||
int firstheight = max(height / 2, 1);
|
||||
|
||||
if (ExposureLevels.size() > 0 && ExposureLevels[0].Viewport.width == firstwidth && ExposureLevels[0].Viewport.height == firstheight)
|
||||
{
|
||||
|
@ -511,8 +511,8 @@ void PPCameraExposure::UpdateTextures(int width, int height)
|
|||
int i = 0;
|
||||
do
|
||||
{
|
||||
width = MAX(width / 2, 1);
|
||||
height = MAX(height / 2, 1);
|
||||
width = max(width / 2, 1);
|
||||
height = max(height / 2, 1);
|
||||
|
||||
PPExposureLevel blevel;
|
||||
blevel.Viewport.left = 0;
|
||||
|
@ -746,7 +746,7 @@ void PPAmbientOcclusion::Render(PPRenderState *renderstate, float m5, int sceneW
|
|||
LinearDepthUniforms linearUniforms;
|
||||
linearUniforms.SampleIndex = 0;
|
||||
linearUniforms.LinearizeDepthA = 1.0f / screen->GetZFar() - 1.0f / screen->GetZNear();
|
||||
linearUniforms.LinearizeDepthB = MAX(1.0f / screen->GetZNear(), 1.e-8f);
|
||||
linearUniforms.LinearizeDepthB = max(1.0f / screen->GetZNear(), 1.e-8f);
|
||||
linearUniforms.InverseDepthRangeA = 1.0f;
|
||||
linearUniforms.InverseDepthRangeB = 0.0f;
|
||||
linearUniforms.Scale = sceneScale;
|
||||
|
@ -894,7 +894,7 @@ void PPShadowMap::Update(PPRenderState* renderstate)
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CVAR(Bool, gl_custompost, true, 0)
|
||||
CVAR(Bool, gl_custompost, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
|
||||
void PPCustomShaders::Run(PPRenderState *renderstate, FString target)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
struct FModelVertex
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ void PolyBuffer::Reset()
|
|||
{
|
||||
}
|
||||
|
||||
void PolyBuffer::SetData(size_t size, const void *data, bool staticdata)
|
||||
void PolyBuffer::SetData(size_t size, const void *data, BufferUsageType usage)
|
||||
{
|
||||
mData.resize(size);
|
||||
map = mData.data();
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
static void ResetAll();
|
||||
void Reset();
|
||||
|
||||
void SetData(size_t size, const void *data, bool staticdata) override;
|
||||
void SetData(size_t size, const void *data, BufferUsageType usage) override;
|
||||
void SetSubData(size_t offset, size_t size, const void *data) override;
|
||||
void Resize(size_t newsize) override;
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void PolyFrameBuffer::InitializeState()
|
|||
mScreenQuad.VertexBuffer->SetFormat(1, 3, sizeof(ScreenQuadVertex), format);
|
||||
|
||||
mScreenQuad.IndexBuffer = screen->CreateIndexBuffer();
|
||||
mScreenQuad.IndexBuffer->SetData(6 * sizeof(uint32_t), indices, false);
|
||||
mScreenQuad.IndexBuffer->SetData(6 * sizeof(uint32_t), indices, BufferUsageType::Stream);
|
||||
|
||||
CheckCanvas();
|
||||
}
|
||||
|
@ -219,8 +219,8 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<void(
|
|||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
bounds.width = std::min(tex->GetWidth(), image->GetWidth());
|
||||
bounds.height = std::min(tex->GetHeight(), image->GetHeight());
|
||||
bounds.width = min(tex->GetWidth(), image->GetWidth());
|
||||
bounds.height = min(tex->GetHeight(), image->GetHeight());
|
||||
|
||||
renderFunc(bounds);
|
||||
|
||||
|
@ -254,7 +254,7 @@ void PolyFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, c
|
|||
{ 0.0f, (float)mScreenViewport.height, 0.0f, 1.0f },
|
||||
{ (float)mScreenViewport.width, (float)mScreenViewport.height, 1.0f, 1.0f }
|
||||
};
|
||||
mScreenQuad.VertexBuffer->SetData(4 * sizeof(ScreenQuadVertex), vertices, false);
|
||||
mScreenQuad.VertexBuffer->SetData(4 * sizeof(ScreenQuadVertex), vertices, BufferUsageType::Stream);
|
||||
|
||||
mRenderState->SetVertexBuffer(mScreenQuad.VertexBuffer, 0, 0);
|
||||
mRenderState->SetIndexBuffer(mScreenQuad.IndexBuffer);
|
||||
|
|
|
@ -100,10 +100,10 @@ void PolyTriangleThreadData::SetScissor(int x, int y, int w, int h)
|
|||
|
||||
void PolyTriangleThreadData::UpdateClip()
|
||||
{
|
||||
clip.left = MAX(MAX(viewport_x, scissor.left), 0);
|
||||
clip.top = MAX(MAX(viewport_y, scissor.top), 0);
|
||||
clip.right = MIN(MIN(viewport_x + viewport_width, scissor.right), dest_width);
|
||||
clip.bottom = MIN(MIN(viewport_y + viewport_height, scissor.bottom), dest_height);
|
||||
clip.left = max(max(viewport_x, scissor.left), 0);
|
||||
clip.top = max(max(viewport_y, scissor.top), 0);
|
||||
clip.right = min(min(viewport_x + viewport_width, scissor.right), dest_width);
|
||||
clip.bottom = min(min(viewport_y + viewport_height, scissor.bottom), dest_height);
|
||||
}
|
||||
|
||||
void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPushConstants &constants)
|
||||
|
@ -206,11 +206,11 @@ void PolyTriangleThreadData::SetStencil(int stencilRef, int op)
|
|||
StencilTestValue = stencilRef;
|
||||
if (op == SOP_Increment)
|
||||
{
|
||||
StencilWriteValue = MIN(stencilRef + 1, (int)255);
|
||||
StencilWriteValue = min(stencilRef + 1, (int)255);
|
||||
}
|
||||
else if (op == SOP_Decrement)
|
||||
{
|
||||
StencilWriteValue = MAX(stencilRef - 1, (int)0);
|
||||
StencilWriteValue = max(stencilRef - 1, (int)0);
|
||||
}
|
||||
else // SOP_Keep
|
||||
{
|
||||
|
@ -453,8 +453,8 @@ void PolyTriangleThreadData::DrawShadedLine(const ShadedTriVertex *const* vert)
|
|||
{
|
||||
float clipdistance1 = clipdistance[0 * numclipdistances + p];
|
||||
float clipdistance2 = clipdistance[1 * numclipdistances + p];
|
||||
if (clipdistance1 < 0.0f) t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1);
|
||||
if (clipdistance2 < 0.0f) t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2);
|
||||
if (clipdistance1 < 0.0f) t1 = max(-clipdistance1 / (clipdistance2 - clipdistance1), t1);
|
||||
if (clipdistance2 < 0.0f) t2 = min(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2);
|
||||
if (t1 >= t2)
|
||||
return;
|
||||
}
|
||||
|
@ -792,8 +792,8 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts)
|
|||
// Clip halfspace
|
||||
if ((clipdistance1 >= 0.0f || clipdistance2 >= 0.0f) && outputverts + 1 < max_additional_vertices)
|
||||
{
|
||||
float t1 = (clipdistance1 < 0.0f) ? MAX(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f) : 0.0f;
|
||||
float t2 = (clipdistance2 < 0.0f) ? MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.0f;
|
||||
float t1 = (clipdistance1 < 0.0f) ? max(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f) : 0.0f;
|
||||
float t2 = (clipdistance2 < 0.0f) ? min(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.0f;
|
||||
|
||||
// add t1 vertex
|
||||
for (int k = 0; k < 3; k++)
|
||||
|
|
|
@ -85,16 +85,16 @@ public:
|
|||
|
||||
int skipped_by_thread(int first_line)
|
||||
{
|
||||
int clip_first_line = MAX(first_line, numa_start_y);
|
||||
int clip_first_line = max(first_line, numa_start_y);
|
||||
int core_skip = (num_cores - (clip_first_line - core) % num_cores) % num_cores;
|
||||
return clip_first_line + core_skip - first_line;
|
||||
}
|
||||
|
||||
int count_for_thread(int first_line, int count)
|
||||
{
|
||||
count = MIN(count, numa_end_y - first_line);
|
||||
count = min(count, numa_end_y - first_line);
|
||||
int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores;
|
||||
return MAX(c, 0);
|
||||
return max(c, 0);
|
||||
}
|
||||
|
||||
struct Scanline
|
||||
|
|
|
@ -336,10 +336,10 @@ void BlendColorAdd_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thread
|
|||
uint32_t srcscale = APART(src);
|
||||
srcscale += srcscale >> 7;
|
||||
|
||||
uint32_t a = MIN<int32_t>((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = MIN<int32_t>((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = MIN<int32_t>((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = MIN<int32_t>((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255);
|
||||
uint32_t a = min<int32_t>((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = min<int32_t>((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = min<int32_t>((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = min<int32_t>((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255);
|
||||
|
||||
line[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
@ -382,10 +382,10 @@ void BlendColorAdd_SrcCol_One(int y, int x0, int x1, PolyTriangleThreadData* thr
|
|||
srcscale_g += srcscale_g >> 7;
|
||||
srcscale_b += srcscale_b >> 7;
|
||||
|
||||
uint32_t a = MIN<int32_t>((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = MIN<int32_t>((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = MIN<int32_t>((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = MIN<int32_t>((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255);
|
||||
uint32_t a = min<int32_t>((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = min<int32_t>((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = min<int32_t>((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = min<int32_t>((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255);
|
||||
|
||||
line[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
@ -514,10 +514,10 @@ void BlendColorRevSub_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thr
|
|||
uint32_t srcscale = APART(src);
|
||||
srcscale += srcscale >> 7;
|
||||
|
||||
uint32_t a = MAX<int32_t>(APART(dst) - (((APART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t r = MAX<int32_t>(RPART(dst) - (((RPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t g = MAX<int32_t>(GPART(dst) - (((GPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t b = MAX<int32_t>(BPART(dst) - (((BPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t a = max<int32_t>(APART(dst) - (((APART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t r = max<int32_t>(RPART(dst) - (((RPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t g = max<int32_t>(GPART(dst) - (((GPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t b = max<int32_t>(BPART(dst) - (((BPART(src) * srcscale) + 127) >> 8), 0);
|
||||
|
||||
line[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
|
||||
// L = light-pos
|
||||
// dist = sqrt(dot(L, L))
|
||||
// distance_attenuation = 1 - MIN(dist * (1/radius), 1)
|
||||
// distance_attenuation = 1 - min(dist * (1/radius), 1)
|
||||
__m128 Lx = _mm_sub_ps(lightposX, _mm_loadu_ps(&worldposX[x]));
|
||||
__m128 Ly = _mm_sub_ps(lightposY, _mm_loadu_ps(&worldposY[x]));
|
||||
__m128 Lz = _mm_sub_ps(lightposZ, _mm_loadu_ps(&worldposZ[x]));
|
||||
|
@ -179,7 +179,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
|
||||
// L = light-pos
|
||||
// dist = sqrt(dot(L, L))
|
||||
// distance_attenuation = 1 - MIN(dist * (1/radius), 1)
|
||||
// distance_attenuation = 1 - min(dist * (1/radius), 1)
|
||||
float Lx = lightposX - worldposX[x];
|
||||
float Ly = lightposY - worldposY[x];
|
||||
float Lz = lightposZ - worldposZ[x];
|
||||
|
@ -191,7 +191,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(dist2)));
|
||||
#endif
|
||||
float dist = dist2 * rcp_dist;
|
||||
float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f);
|
||||
float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f);
|
||||
|
||||
// The simple light type
|
||||
float simple_attenuation = distance_attenuation;
|
||||
|
@ -202,7 +202,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
Ly *= rcp_dist;
|
||||
Lz *= rcp_dist;
|
||||
float dotNL = worldnormalX * Lx + worldnormalY * Ly + worldnormalZ * Lz;
|
||||
float point_attenuation = MAX(dotNL, 0.0f) * distance_attenuation;
|
||||
float point_attenuation = max(dotNL, 0.0f) * distance_attenuation;
|
||||
|
||||
uint32_t attenuation = (uint32_t)(is_attenuated ? (int32_t)point_attenuation : (int32_t)simple_attenuation);
|
||||
|
||||
|
@ -211,9 +211,9 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
lit_b += (BPART(light_color) * attenuation) >> 8;
|
||||
}
|
||||
|
||||
lit_r = MIN<uint32_t>(lit_r, 255);
|
||||
lit_g = MIN<uint32_t>(lit_g, 255);
|
||||
lit_b = MIN<uint32_t>(lit_b, 255);
|
||||
lit_r = min<uint32_t>(lit_r, 255);
|
||||
lit_g = min<uint32_t>(lit_g, 255);
|
||||
lit_b = min<uint32_t>(lit_b, 255);
|
||||
lightarray[x] = MAKEARGB(lit_a, lit_r, lit_g, lit_b);
|
||||
|
||||
// Palette version:
|
||||
|
@ -255,7 +255,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
uint32_t* lightarray = thread->scanline.lightarray;
|
||||
for (int x = x0; x < x1; x++)
|
||||
{
|
||||
uint32_t l = MIN(lightpos >> 8, 256);
|
||||
uint32_t l = min(lightpos >> 8, 256);
|
||||
|
||||
uint32_t r = vColorR[x];
|
||||
uint32_t g = vColorG[x];
|
||||
|
@ -273,9 +273,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
|
||||
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
|
||||
|
||||
r = MIN<uint32_t>(r, 255);
|
||||
g = MIN<uint32_t>(g, 255);
|
||||
b = MIN<uint32_t>(b, 255);
|
||||
r = min<uint32_t>(r, 255);
|
||||
g = min<uint32_t>(g, 255);
|
||||
b = min<uint32_t>(b, 255);
|
||||
}
|
||||
|
||||
lightarray[x] = MAKEARGB(a, r, g, b);
|
||||
|
@ -287,7 +287,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
uint32_t* lightarray = thread->scanline.lightarray;
|
||||
for (int x = x0; x < x1; x++)
|
||||
{
|
||||
uint32_t l = MIN((FRACUNIT - clamp<fixed_t>(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8, 256);
|
||||
uint32_t l = min((FRACUNIT - clamp<fixed_t>(shade - min(maxvis, lightpos), 0, maxlight)) >> 8, 256);
|
||||
uint32_t r = vColorR[x];
|
||||
uint32_t g = vColorG[x];
|
||||
uint32_t b = vColorB[x];
|
||||
|
@ -304,9 +304,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
|
||||
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
|
||||
|
||||
r = MIN<uint32_t>(r, 255);
|
||||
g = MIN<uint32_t>(g, 255);
|
||||
b = MIN<uint32_t>(b, 255);
|
||||
r = min<uint32_t>(r, 255);
|
||||
g = min<uint32_t>(g, 255);
|
||||
b = min<uint32_t>(b, 255);
|
||||
}
|
||||
|
||||
lightarray[x] = MAKEARGB(a, r, g, b);
|
||||
|
@ -327,7 +327,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
uint32_t g = thread->scanline.vColorG[x];
|
||||
uint32_t b = thread->scanline.vColorB[x];
|
||||
|
||||
float fogdist = MAX(16.0f, w[x]);
|
||||
float fogdist = max(16.0f, w[x]);
|
||||
float fogfactor = std::exp2(constants->uFogDensity * fogdist);
|
||||
|
||||
// brightening around the player for light mode 2:
|
||||
|
@ -365,9 +365,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
|
||||
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
|
||||
|
||||
r = MIN<uint32_t>(r, 255);
|
||||
g = MIN<uint32_t>(g, 255);
|
||||
b = MIN<uint32_t>(b, 255);
|
||||
r = min<uint32_t>(r, 255);
|
||||
g = min<uint32_t>(g, 255);
|
||||
b = min<uint32_t>(b, 255);
|
||||
}
|
||||
|
||||
lightarray[x] = MAKEARGB(a, r, g, b);
|
||||
|
|
|
@ -291,9 +291,9 @@ static void FuncNormal_AddColor(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
uint32_t texel = fragcolor[x];
|
||||
fragcolor[x] = MAKEARGB(
|
||||
APART(texel),
|
||||
MIN(r + RPART(texel), (uint32_t)255),
|
||||
MIN(g + GPART(texel), (uint32_t)255),
|
||||
MIN(b + BPART(texel), (uint32_t)255));
|
||||
min(r + RPART(texel), (uint32_t)255),
|
||||
min(g + GPART(texel), (uint32_t)255),
|
||||
min(b + BPART(texel), (uint32_t)255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,9 +309,9 @@ static void FuncNormal_AddObjectColor(int x0, int x1, PolyTriangleThreadData* th
|
|||
uint32_t texel = fragcolor[x];
|
||||
fragcolor[x] = MAKEARGB(
|
||||
APART(texel),
|
||||
MIN((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
min((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
min((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
min((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,9 +331,9 @@ static void FuncNormal_AddObjectColor2(int x0, int x1, PolyTriangleThreadData* t
|
|||
uint32_t texel = fragcolor[x];
|
||||
fragcolor[x] = MAKEARGB(
|
||||
APART(texel),
|
||||
MIN((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
min((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
min((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
min((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ static void GetLightColor(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
mulG += mulG >> 7;
|
||||
mulB += mulB >> 7;
|
||||
|
||||
float fogdist = MAX(16.0f, w[x]);
|
||||
float fogdist = max(16.0f, w[x]);
|
||||
float fogfactor = std::exp2(uFogDensity * fogdist);
|
||||
|
||||
uint32_t a = (APART(fg) * mulA + 127) >> 8;
|
||||
|
@ -512,7 +512,7 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
float fogfactor = 0.0f;
|
||||
if (constants->uFogEnabled != 0)
|
||||
{
|
||||
fogdist = MAX(16.0f, w[x]);
|
||||
fogdist = max(16.0f, w[x]);
|
||||
fogfactor = std::exp2(constants->uFogDensity * fogdist);
|
||||
}
|
||||
frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * vColor.a);*/
|
||||
|
@ -594,9 +594,9 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
b = (BPART(fragcolor[x]) * b + 127) >> 8;
|
||||
|
||||
// frag.rgb = frag.rgb + uFogColor.rgb;
|
||||
r = MIN(r + fogR, (uint32_t)255);
|
||||
g = MIN(g + fogG, (uint32_t)255);
|
||||
b = MIN(b + fogB, (uint32_t)255);
|
||||
r = min(r + fogR, (uint32_t)255);
|
||||
g = min(g + fogG, (uint32_t)255);
|
||||
b = min(b + fogB, (uint32_t)255);
|
||||
|
||||
fragcolor[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
|
|
@ -207,17 +207,17 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs* args, PolyTriangleThreadDat
|
|||
SortVertices(args, sortedVertices);
|
||||
|
||||
int clipleft = thread->clip.left;
|
||||
int cliptop = MAX(thread->clip.top, thread->numa_start_y);
|
||||
int cliptop = max(thread->clip.top, thread->numa_start_y);
|
||||
int clipright = thread->clip.right;
|
||||
int clipbottom = MIN(thread->clip.bottom, thread->numa_end_y);
|
||||
int clipbottom = min(thread->clip.bottom, thread->numa_end_y);
|
||||
|
||||
int topY = (int)(sortedVertices[0]->y + 0.5f);
|
||||
int midY = (int)(sortedVertices[1]->y + 0.5f);
|
||||
int bottomY = (int)(sortedVertices[2]->y + 0.5f);
|
||||
|
||||
topY = MAX(topY, cliptop);
|
||||
midY = MIN(midY, clipbottom);
|
||||
bottomY = MIN(bottomY, clipbottom);
|
||||
topY = max(topY, cliptop);
|
||||
midY = min(midY, clipbottom);
|
||||
bottomY = min(bottomY, clipbottom);
|
||||
|
||||
if (topY >= bottomY)
|
||||
return;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue