Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a100439df | ||
|
|
3b37f85024 | ||
|
|
27a65ef973 | ||
|
|
ffa9b2fa9a | ||
|
|
ab9e0f923e | ||
|
|
8bf3953b4a | ||
|
|
44ef42cf84 | ||
|
|
746035bfea | ||
|
|
70bc9879b3 | ||
|
|
0e6a794a84 | ||
|
|
4eccf40a0a | ||
|
|
e3fd46297a | ||
|
|
4c2e119385 | ||
|
|
229a6a161e | ||
|
|
1b2e4a1acc | ||
|
|
2e6d49fcd6 | ||
|
|
7a8c66781b | ||
|
|
c877226bfe | ||
|
|
ac3c8b1d25 | ||
|
|
feeba45b0d | ||
|
|
06f3d2c91b | ||
|
|
332fadc823 | ||
|
|
39dc1b85e3 | ||
|
|
5b2413444f | ||
|
|
7855b2ed95 | ||
|
|
caebe62ddb | ||
|
|
9de285caac | ||
|
|
9bb4420ad3 | ||
|
|
8dc3d870a1 | ||
|
|
158546bd73 | ||
|
|
b89a3f1017 | ||
|
|
f2e355a5a8 |
No files matched your search
@@ -292,6 +292,7 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
lua_script.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
lua_udatalib.c
|
||||
lua_glib.c
|
||||
)
|
||||
set(SRB2_LUA_HEADERS
|
||||
@@ -301,6 +302,7 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
lua_profile.h
|
||||
lua_libs.h
|
||||
lua_script.h
|
||||
lua_udatalib.h
|
||||
lua_glib.h
|
||||
)
|
||||
|
||||
|
||||
@@ -97,5 +97,6 @@ lua_playerlib.c
|
||||
lua_script.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
lua_udatalib.c
|
||||
lua_glib.c
|
||||
lua_profile.cpp
|
||||
+58
-27
@@ -63,6 +63,7 @@
|
||||
|
||||
// for replay dates
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
|
||||
// menu demo things
|
||||
UINT32 demoDelayTime = 15*TICRATE;
|
||||
@@ -2386,9 +2387,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
|
||||
#if defined (_WIN32)
|
||||
// return the file creation time
|
||||
// useful for demos that were renamed
|
||||
// windows only, as file creation times are
|
||||
// very unreliable (or non existant depending on fs) on linux
|
||||
static time_t G_GetCreationTime(char *filepath)
|
||||
static long G_GetCreationTime(char *filepath)
|
||||
{
|
||||
struct stat fileinfo;
|
||||
|
||||
@@ -2399,24 +2398,35 @@ static time_t G_GetCreationTime(char *filepath)
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *G_GetDemoDate(menudemo_t *pdemo, const char *dateformat)
|
||||
static char *G_GetDemoDate(menudemo_t *pdemo)
|
||||
{
|
||||
char *endPos = NULL;
|
||||
char *datetime;
|
||||
static char datetime[11];
|
||||
time_t file_time = 0;
|
||||
struct tm tm_buf;
|
||||
const char *format = NULL;
|
||||
struct tm *tm_buf = NULL;
|
||||
CLEANUP(pfree) char *filename = NULL;
|
||||
|
||||
// get le filepath
|
||||
filename = strdup(pdemo->filepath);
|
||||
|
||||
if (!filename)
|
||||
{
|
||||
#if defined (_WIN32)
|
||||
// if we cant get a filename try just getting the file creation time
|
||||
file_time = G_GetCreationTime(pdemo->filepath);
|
||||
goto skipfilenametime;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// get the actual filename Zzz...
|
||||
nameonly(filename);
|
||||
|
||||
// the first 10 characters of a replay name is a unix timestamp
|
||||
// the first 10 characters of a replay name usually is a unix timestamp
|
||||
|
||||
// not long enough to contain a valid timestamp
|
||||
if (strlen(filename) < 10)
|
||||
{
|
||||
#if defined (_WIN32)
|
||||
@@ -2448,49 +2458,67 @@ static char *G_GetDemoDate(menudemo_t *pdemo, const char *dateformat)
|
||||
#endif
|
||||
}
|
||||
|
||||
// then throw it into localtime to get an actual human readable format lmao
|
||||
#if defined(_WIN32)
|
||||
#if defined (_WIN32)
|
||||
skipfilenametime:
|
||||
if ((localtime_s(&tm_buf, &file_time) != 0) ||
|
||||
(tm_buf.tm_year <= 110)) // cant believe we ended up in 1970
|
||||
#endif
|
||||
|
||||
// then throw it into localtime to get an actual human readable format lmao
|
||||
tm_buf = localtime(&file_time);
|
||||
|
||||
// cant believe we ended up in 1970
|
||||
if (tm_buf == NULL || tm_buf->tm_year <= 110)
|
||||
{
|
||||
#if defined (_WIN32)
|
||||
// uh ohh, we got an invalid time
|
||||
// try one more time getting the creation time
|
||||
file_time = G_GetCreationTime(pdemo->filepath);
|
||||
tm_buf = localtime(&file_time);
|
||||
|
||||
if ((localtime_s(&tm_buf, &file_time) != 0) ||
|
||||
(tm_buf.tm_year <= 110))
|
||||
if (tm_buf == NULL || tm_buf->tm_year <= 110)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
goto gotcreationtime;
|
||||
#else
|
||||
if ((localtime_r(&file_time, &tm_buf) == NULL) ||
|
||||
(tm_buf.tm_year <= 110)) // cant believe we ended up in 1970
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
datetime = malloc(sizeof(pdemo->date)); // mallocma balls
|
||||
#if defined (_WIN32)
|
||||
gotcreationtime:
|
||||
#endif
|
||||
|
||||
// no mallocma balls... :c
|
||||
if (!datetime)
|
||||
return NULL;
|
||||
// US ppl are special (:
|
||||
if (cv_demodateformat.value == 2)
|
||||
format = "%m.%d.%Y";
|
||||
else if (cv_demodateformat.value == 1)
|
||||
format = "%d.%m.%Y";
|
||||
else
|
||||
{
|
||||
const char *locale = setlocale(LC_TIME, NULL);
|
||||
|
||||
if (strftime(datetime, sizeof(pdemo->date), dateformat, &tm_buf) == 0)
|
||||
if (locale == NULL)
|
||||
format = "%d.%m.%Y"; // fallback to non US format
|
||||
else if (strstr(locale, "en_US"))
|
||||
format = "%m.%d.%Y";
|
||||
else
|
||||
format = "%d.%m.%Y";
|
||||
}
|
||||
|
||||
if (strftime(datetime, sizeof(datetime), format, tm_buf) == 0)
|
||||
{
|
||||
free(datetime);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return datetime;
|
||||
}
|
||||
|
||||
void G_LoadDemoTitle(menudemo_t *pdemo, const char *dateformat)
|
||||
void G_LoadDemoTitle(menudemo_t *pdemo)
|
||||
{
|
||||
UINT8 infobuffer[96], *info_p;
|
||||
UINT16 pdemoversion;
|
||||
char *demodate = NULL;
|
||||
size_t count;
|
||||
|
||||
memset(pdemo->date, 0, sizeof(pdemo->date));
|
||||
|
||||
FILE *handle = fopen(pdemo->filepath, "rb");
|
||||
|
||||
if (!handle)
|
||||
@@ -2518,6 +2546,8 @@ void G_LoadDemoTitle(menudemo_t *pdemo, const char *dateformat)
|
||||
|
||||
pdemoversion = READUINT16(info_p);
|
||||
|
||||
memset(pdemo->date, 0, sizeof(pdemo->date));
|
||||
|
||||
switch (pdemoversion)
|
||||
{
|
||||
case DEMOVERSION: // latest always supported
|
||||
@@ -2525,12 +2555,13 @@ void G_LoadDemoTitle(menudemo_t *pdemo, const char *dateformat)
|
||||
memcpy(pdemo->title, info_p, 64);
|
||||
|
||||
// demo date
|
||||
char *demodate = G_GetDemoDate(pdemo, dateformat);
|
||||
demodate = G_GetDemoDate(pdemo);
|
||||
|
||||
if (demodate)
|
||||
{
|
||||
strlcpy(pdemo->date, demodate, sizeof(pdemo->date));
|
||||
free(demodate);
|
||||
}
|
||||
|
||||
break;
|
||||
#ifdef DEMO_COMPAT_100
|
||||
case 0x0001:
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ void G_SetDemoTime(UINT32 ptime, UINT32 plap);
|
||||
UINT8 G_CmpDemoTime(char *oldname, char *newname);
|
||||
|
||||
void G_LoadDemoInfo(menudemo_t *pdemo);
|
||||
void G_LoadDemoTitle(menudemo_t *pdemo, const char *dateformat); // For use in replay search feature
|
||||
void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature
|
||||
void G_DeferedPlayDemo(const char *demo);
|
||||
|
||||
typedef enum
|
||||
|
||||
+16
-100
@@ -96,7 +96,7 @@ static void HWR_FreePoly(poly_t *poly)
|
||||
// divfrac = how far along partline vector is crossing pt
|
||||
static boolean fracdivline(fdivline_t *partline, polyvertex_t *v1, polyvertex_t *v2)
|
||||
{
|
||||
double frac;
|
||||
double frac1, frac2;
|
||||
double num; // numerator
|
||||
double den; // denominator
|
||||
double v1x, v1y, v1dx, v1dy; // polygon side vector, v1->v2
|
||||
@@ -122,23 +122,24 @@ static boolean fracdivline(fdivline_t *partline, polyvertex_t *v1, polyvertex_t
|
||||
// first check the frac along the polygon segment,
|
||||
// (do not accept hit with the extensions)
|
||||
num = (v3x - v1x)*v3dy + (v1y - v3y)*v3dx;
|
||||
frac = num / den;
|
||||
frac1 = num / den;
|
||||
|
||||
// 0= cross at v1, 1.0= cross at v2
|
||||
if (frac < 0.0 || frac > 1.0) // double
|
||||
if (frac1 < 0.0 || frac1 > 1.0) // double
|
||||
return false; // not within the polygon side
|
||||
|
||||
// now get the frac along the BSP line
|
||||
// which is useful to determine what is left, what is right
|
||||
num = (v3x - v1x)*v1dy + (v1y - v3y)*v1dx;
|
||||
frac2 = num / den;
|
||||
|
||||
partline->divfrac = num / den; // how far along partline vector
|
||||
partline->divfrac = frac2; // how far along partline vector
|
||||
|
||||
// [WDJ] find the interception point along the segment.
|
||||
// It should be slightly more accurate because it is always closer to the
|
||||
// crossing point than arbitrary positions on the partition line.
|
||||
partline->divpt.x = v1x + v1dx*frac;
|
||||
partline->divpt.y = v1y + v1dy*frac;
|
||||
partline->divpt.x = v1x + v1dx*frac1;
|
||||
partline->divpt.y = v1y + v1dy*frac1;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -160,71 +161,6 @@ static boolean SameVertex(polyvertex_t *p1, polyvertex_t *p2)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Adapted from function in prboom.
|
||||
// Point is to rightside of divline when result > 0,
|
||||
// but result is multiplied by length of divline.
|
||||
// Returns near 0, when point is on, or nearly on, the divline.
|
||||
static inline double point_rightside(fdivline_t *dl, polyvertex_t *v4)
|
||||
{
|
||||
// Cross product of dl and vector dl->(x,y) to v4,
|
||||
// is > 0 when v4 is to right side of divline.
|
||||
// Viewed along divline from vertex, looking towards positive dx,dy.
|
||||
// If divline is rotated until dy>0 and dx = 0, then true when rotated
|
||||
// vertex position is to the right of the divline (v4->x > dl->x).
|
||||
return ((((double)(v4->x) - (double)(dl->x)) * (double)(dl->dy))
|
||||
- (((double)(v4->y) - (double)(dl->y)) * (double)(dl->dx)));
|
||||
}
|
||||
|
||||
// [WDJ] The front and back MUST match the BSP determination, else it will assign
|
||||
// this poly to the wrong sector.
|
||||
// May have 1 point on the line, and other points might be very close to the line.
|
||||
// Can only trust a test of a point that is NOT on the line.
|
||||
// Using a tstdist = 0.5f worked, but it might break on very small poly.
|
||||
// Avactor.wad had polys with d = 9.09, 5552, 1.64, 1011, 14252, 0.0136, 0.00634, 14655, 3,
|
||||
// -0.3044, 7, 1.53, etc..,
|
||||
// and one poly with d = -0.023 with the rest of the points d > 0.
|
||||
// One 14 point poly with divline len=8, had to test 9 points to find d = 36.
|
||||
// Typical: divline len=70 d=6828, divline len=1.0 d=35, divline len=1.414 d=5.
|
||||
// The result of point_rightside is proportional to the length of divline.
|
||||
// The divline length can be from 1.414 to 14000.
|
||||
static void UnsplitPoly(fdivline_t *dlnp, poly_t *poly,
|
||||
poly_t **frontpoly, poly_t **backpoly)
|
||||
{
|
||||
int32_t i;
|
||||
double d;
|
||||
const double tstd = hypot((double)dlnp->dx, (double)dlnp->dy) / 2.0;
|
||||
double sumd = 0; // accumulated left or rightness.
|
||||
|
||||
for (i = 0; i < poly->numpts; i++)
|
||||
{
|
||||
// Look for a point that is obviously to the left or right.
|
||||
d = point_rightside(dlnp, &poly->pts[i]); // d > 0 is right
|
||||
sumd += d;
|
||||
|
||||
if (d > tstd)
|
||||
goto poly_rightside;
|
||||
|
||||
if (d < -tstd)
|
||||
goto poly_leftside;
|
||||
}
|
||||
|
||||
// Did not find an obvious left or right point, then
|
||||
if (sumd < 0)
|
||||
goto poly_leftside;
|
||||
|
||||
poly_rightside:
|
||||
// poly is to rightside of divline.
|
||||
*frontpoly = poly;
|
||||
*backpoly = NULL;
|
||||
return;
|
||||
|
||||
poly_leftside:
|
||||
// poly is to leftside of divline.
|
||||
*frontpoly = NULL;
|
||||
*backpoly = poly;
|
||||
return;
|
||||
}
|
||||
|
||||
// split a _CONVEX_ polygon in two convex polygons
|
||||
// outputs:
|
||||
// frontpoly : polygon on right side of bsp line
|
||||
@@ -327,7 +263,10 @@ static void SplitPoly (fdivline_t *dlnp, // splitting parametric line
|
||||
// linedefs where each side point the same sector, that is:
|
||||
// the deep water effect with the original Doom
|
||||
|
||||
UnsplitPoly(dlnp, poly, frontpoly, backpoly);
|
||||
//TODO: make sure front poly is to front of partition line?
|
||||
|
||||
*frontpoly = poly;
|
||||
*backpoly = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -335,14 +274,16 @@ static void SplitPoly (fdivline_t *dlnp, // splitting parametric line
|
||||
if (pe < 0)
|
||||
{
|
||||
//I_Error("SplitPoly: only one point for split line (%d %d)", ps, pe);
|
||||
UnsplitPoly(dlnp, poly, frontpoly, backpoly);
|
||||
*frontpoly = poly;
|
||||
*backpoly = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (pe <= ps)
|
||||
{
|
||||
//I_Error("SplitPoly: invalid splitting line (%d %d)", ps, pe);
|
||||
UnsplitPoly(dlnp, poly, frontpoly, backpoly);
|
||||
*frontpoly = poly;
|
||||
*backpoly = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -447,10 +388,6 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly)
|
||||
vertex_t *v1, *v2;
|
||||
fdivline_t cutseg; // x, y, dx, dy as start of node_t struct
|
||||
|
||||
// empty poly? just save us some time then
|
||||
if (poly->numpts <= 0)
|
||||
return frontpoly;
|
||||
|
||||
// for each seg of the subsector
|
||||
for (; segcount--; lseg++)
|
||||
{
|
||||
@@ -552,23 +489,6 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly)
|
||||
// need 2 points
|
||||
if (pe >= 0)
|
||||
{
|
||||
// Cuts that miss the polygon.
|
||||
if (ps_frac < 0.0 && cutseg.divfrac < 0.0)
|
||||
continue;
|
||||
|
||||
if (ps_frac > 1.0 && cutseg.divfrac > 1.0)
|
||||
continue;
|
||||
#define FRAC_EP 0.01f
|
||||
// Reject cuts that could make the polygon non-convex.
|
||||
|
||||
// Cannot make normal cut, ps_frac end is loose.
|
||||
if ((ps_frac < (0.0 - FRAC_EP)) || (ps_frac > (1.0f + FRAC_EP)))
|
||||
continue;
|
||||
|
||||
// Cannot make normal cut, cutseg.divfrac end is loose.
|
||||
if ((cutseg.divfrac < (0.0 - FRAC_EP)) || (cutseg.divfrac > (1.0f + FRAC_EP)))
|
||||
continue;
|
||||
#undef FRAC_EP
|
||||
// generate FRONT poly
|
||||
frontpoly = HWR_AllocPoly(poly_num_pts);
|
||||
|
||||
@@ -760,11 +680,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
|
||||
memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
// [WDJ] Having no front poly is as likely as no back poly, since
|
||||
// logic in Split Poly was changed to check poly direction.
|
||||
// I_Error("HWR_WalkBSPNode: no front poly, bspnum= %d\n", bspnum);
|
||||
}
|
||||
I_Error("WalkBSPNode: no front poly?");
|
||||
|
||||
// Recursively divide back space.
|
||||
if (backpoly)
|
||||
|
||||
@@ -255,7 +255,6 @@ static void CV_screentextures_OnChange(void)
|
||||
#endif
|
||||
intermissionbginit = false;
|
||||
}
|
||||
|
||||
GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value);
|
||||
M_UpdateOGLMenu();
|
||||
}
|
||||
@@ -264,11 +263,12 @@ static void CV_screentextures_OnChange(void)
|
||||
static void CV_glframebuffer_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
// screen FBO needs screen textures currently
|
||||
if (cv_glframebuffer.value != 0 && ((cv_glscreentextures.value != 2) || !supportFBO))
|
||||
CV_StealthSetValue(&cv_glframebuffer, 0); // dont recursively call this lul
|
||||
if ((cv_glframebuffer.value != 0 && cv_glscreentextures.value != 2)
|
||||
|| (!supportFBO && cv_glframebuffer.value != 0)) // screen FBO needs screen textures
|
||||
CV_SetValue(&cv_glframebuffer, 0);
|
||||
|
||||
I_CheckDownSampleState(true);
|
||||
I_DownSample();
|
||||
RefreshOGLSDLSurface();
|
||||
M_UpdateOGLMenu();
|
||||
intermissionbginit = false;
|
||||
}
|
||||
@@ -5899,7 +5899,7 @@ void HWR_Startup(void)
|
||||
HWR_TogglePaletteRendering();
|
||||
|
||||
if (msaa)
|
||||
GL_SetSpecialState(HWD_SET_MSAA, 1);
|
||||
GL_SetSpecialState(HWD_SET_MSAA, a2c ? 2 : 1);
|
||||
|
||||
HWR_RegisterCommands();
|
||||
}
|
||||
@@ -5987,7 +5987,7 @@ void HWR_Shutdown(void)
|
||||
GL_FlushScreenTextures();
|
||||
HWR_ClearAllTextures();
|
||||
#ifdef USE_FBO_OGL
|
||||
GL_FBO_Disable();
|
||||
GL_Framebuffer_Disable();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ void HWR_Startup(void);
|
||||
void HWR_Shutdown(void);
|
||||
|
||||
extern unsigned msaa;
|
||||
extern boolean a2c;
|
||||
|
||||
extern FTransform atransform;
|
||||
extern float gl_viewsin, gl_viewcos;
|
||||
|
||||
@@ -193,6 +193,26 @@
|
||||
"}\n" \
|
||||
"#endif\0"
|
||||
|
||||
#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \
|
||||
"uniform sampler2D tex;\n" \
|
||||
"uniform vec4 poly_color;\n" \
|
||||
"uniform vec4 tint_color;\n" \
|
||||
"uniform vec4 fade_color;\n" \
|
||||
"uniform float lighting;\n" \
|
||||
"uniform float fade_start;\n" \
|
||||
"uniform float fade_end;\n" \
|
||||
GLSL_DOOM_COLORMAP \
|
||||
GLSL_DOOM_LIGHT_EQUATION \
|
||||
"void main(void) {\n" \
|
||||
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
|
||||
"vec4 base_color = texel * poly_color;\n" \
|
||||
"vec4 final_color = base_color;\n" \
|
||||
GLSL_SOFTWARE_TINT_EQUATION \
|
||||
GLSL_SOFTWARE_FADE_EQUATION \
|
||||
"final_color.a = texel.a * poly_color.a;\n" \
|
||||
"gl_FragColor = final_color;\n" \
|
||||
"}\n" \
|
||||
|
||||
// hand tuned adjustments for light level calculation
|
||||
#define GLSL_FLOOR_FUDGES \
|
||||
"#define STARTMAP_FUDGE 1.06\n" \
|
||||
|
||||
@@ -136,7 +136,8 @@ enum
|
||||
{
|
||||
FBO_NONE,
|
||||
FBO_ARB,
|
||||
FBO_EXT
|
||||
FBO_EXT,
|
||||
FBO_EXT_STENCIL // supports stencil attachment
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -160,7 +161,7 @@ GL_DEPTH24_STENCIL8 GL_DEPTH_COMPONENT_EXT
|
||||
GL_DEPTH_STENCIL_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||
#endif
|
||||
|
||||
static void GL_FBO_DeleteAttachments(void);
|
||||
static void GL_Framebuffer_DeleteAttachments(void);
|
||||
#endif
|
||||
|
||||
// needed for glportals
|
||||
@@ -768,22 +769,28 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
#ifdef USE_FBO_OGL
|
||||
static int GLFramebuffer_CheckExt(void)
|
||||
{
|
||||
// check for the standard arb extensions
|
||||
// these should be there from version 3.0 onwards
|
||||
// in opengl 3.0 and up fbos are standart and always supported
|
||||
if (majorGL >= 3)
|
||||
return FBO_ARB;
|
||||
|
||||
// gl versions from 2.1 may still support framebuffer objects
|
||||
|
||||
// maybe, just maybe, we support the standart extensions
|
||||
if (GL_isExtAvailable("GL_ARB_framebuffer_no_attachments", gl_extensions) &&
|
||||
GL_isExtAvailable("GL_ARB_framebuffer_object", gl_extensions) &&
|
||||
GL_isExtAvailable("GL_ARB_framebuffer_sRGB", gl_extensions))
|
||||
{
|
||||
return FBO_ARB;
|
||||
}
|
||||
|
||||
// gl versions from 2.1 and older may still support framebuffer objects
|
||||
// depending on vendor and driver support
|
||||
// nope, try the older 2.1 extensions
|
||||
if (GL_isExtAvailable("GL_EXT_framebuffer_no_attachments", gl_extensions) &&
|
||||
GL_isExtAvailable("GL_EXT_framebuffer_object", gl_extensions) &&
|
||||
GL_isExtAvailable("GL_EXT_framebuffer_sRGB", gl_extensions) &&
|
||||
GL_isExtAvailable("GL_EXT_packed_depth_stencil", gl_extensions)) // we use the stencil buffer for stuff like portals, so its better to make stencil extension a requirement
|
||||
GL_isExtAvailable("GL_EXT_framebuffer_sRGB", gl_extensions))
|
||||
{
|
||||
// perhaps we may even support a stencil attachment
|
||||
if (GL_isExtAvailable("GL_EXT_packed_depth_stencil", gl_extensions))
|
||||
return FBO_EXT_STENCIL;
|
||||
|
||||
// no stencil support, sad
|
||||
return FBO_EXT;
|
||||
}
|
||||
|
||||
@@ -901,41 +908,36 @@ void SetupGLFunc4(void)
|
||||
|
||||
GL_DBG_Printf("\nFBO: ARB extensions found\n");
|
||||
}
|
||||
else if (fbocheck == FBO_EXT) // uh oh only support old fbo extensions...
|
||||
else if (fbocheck == FBO_EXT || fbocheck == FBO_EXT_STENCIL) // uh oh only support for EXT prefix fbos...
|
||||
{
|
||||
GetGLfunc(glGenFramebuffersEXT);
|
||||
GetGLfunc(glBindFramebufferEXT);
|
||||
GetGLfunc(glDeleteFramebuffersEXT);
|
||||
GetGLfunc(glFramebufferTexture2DEXT);
|
||||
GetGLfunc(glCheckFramebufferStatusEXT);
|
||||
GetGLfunc(glGenRenderbuffersEXT);
|
||||
GetGLfunc(glBindRenderbufferEXT);
|
||||
GetGLfunc(glDeleteRenderbuffersEXT);
|
||||
GetGLfunc(glRenderbufferStorageEXT);
|
||||
GetGLfunc(glFramebufferRenderbufferEXT);
|
||||
|
||||
// remapping galore huehue
|
||||
// do this so we dont have to dupe half our code
|
||||
GetGLfunc(glGenFramebuffersEXT);
|
||||
pglGenFramebuffers = pglGenFramebuffersEXT;
|
||||
|
||||
GetGLfunc(glBindFramebufferEXT);
|
||||
pglBindFramebuffer = pglBindFramebufferEXT;
|
||||
|
||||
GetGLfunc(glDeleteFramebuffersEXT);
|
||||
pglDeleteFramebuffers = pglDeleteFramebuffersEXT;
|
||||
|
||||
GetGLfunc(glFramebufferTexture2DEXT);
|
||||
pglFramebufferTexture2D = pglFramebufferTexture2DEXT;
|
||||
|
||||
GetGLfunc(glCheckFramebufferStatusEXT);
|
||||
pglCheckFramebufferStatus = pglCheckFramebufferStatusEXT;
|
||||
|
||||
GetGLfunc(glGenRenderbuffersEXT);
|
||||
pglGenRenderbuffers = pglGenRenderbuffersEXT;
|
||||
|
||||
GetGLfunc(glBindRenderbufferEXT);
|
||||
pglBindRenderbuffer = pglBindRenderbufferEXT;
|
||||
|
||||
GetGLfunc(glDeleteRenderbuffersEXT);
|
||||
pglDeleteRenderbuffers = pglDeleteRenderbuffersEXT;
|
||||
|
||||
GetGLfunc(glRenderbufferStorageEXT);
|
||||
pglRenderbufferStorage = pglRenderbufferStorageEXT;
|
||||
|
||||
GetGLfunc(glFramebufferRenderbufferEXT);
|
||||
pglFramebufferRenderbuffer = pglFramebufferRenderbufferEXT;
|
||||
|
||||
GL_DBG_Printf("\nFBO: EXT extensions with packed depth-stencil\n");
|
||||
if (fbocheck == FBO_EXT)
|
||||
GL_DBG_Printf("\nFBO: EXT extensions found, no stencil\n");
|
||||
else if (fbocheck == FBO_EXT_STENCIL)
|
||||
GL_DBG_Printf("\nFBO: EXT extensions with packed depth-stencil\n");
|
||||
}
|
||||
|
||||
supportFBO = fbocheck;
|
||||
@@ -1149,7 +1151,7 @@ void GL_SetModelView(GLint w, GLint h)
|
||||
GL_FlushScreenTextures();
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
GL_FBO_DeleteAttachments();
|
||||
GL_Framebuffer_DeleteAttachments();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2639,7 +2641,11 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value)
|
||||
|
||||
case HWD_SET_MSAA:
|
||||
if (Value)
|
||||
{
|
||||
pglEnable(GL_MULTISAMPLE);
|
||||
if (Value == 2)
|
||||
pglEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
}
|
||||
break;
|
||||
|
||||
case HWD_SET_TEXTUREANISOTROPICMODE:
|
||||
@@ -3240,7 +3246,7 @@ void GL_SetTransform(FTransform *stransform)
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
static void GL_FBO_DeleteAttachments(void)
|
||||
static void GL_Framebuffer_DeleteAttachments(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
@@ -3260,9 +3266,9 @@ static void GL_FBO_DeleteAttachments(void)
|
||||
framebufferobject.init = false;
|
||||
}
|
||||
|
||||
static void GL_FBO_Generate(void)
|
||||
static void GL_Framebuffer_Generate(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE || framebufferobject.init)
|
||||
if (supportFBO == FBO_NONE || framebufferobject.init || !UseScreenFBO())
|
||||
return;
|
||||
|
||||
// Generate the framebuffer
|
||||
@@ -3277,7 +3283,7 @@ static void GL_FBO_Generate(void)
|
||||
{
|
||||
pglGenTextures(1, &framebufferobject.tex);
|
||||
pglBindTexture(GL_TEXTURE_2D, framebufferobject.tex);
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, screen_width, screen_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, screen_width, screen_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
Clamp2D(GL_TEXTURE_WRAP_S);
|
||||
@@ -3300,13 +3306,18 @@ static void GL_FBO_Generate(void)
|
||||
pglRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8, screen_width, screen_height);
|
||||
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
|
||||
}
|
||||
else if (supportFBO == FBO_EXT)
|
||||
else if (supportFBO == FBO_EXT || supportFBO == FBO_EXT_STENCIL)
|
||||
{
|
||||
pglRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, screen_width, screen_height);
|
||||
// attach the renderbuffer to depth attachment point
|
||||
pglRenderbufferStorage(GL_RENDERBUFFER_EXT, (supportFBO == FBO_EXT_STENCIL) ? GL_DEPTH_STENCIL_EXT : GL_DEPTH_COMPONENT, screen_width, screen_height);
|
||||
|
||||
// attach a renderbuffer to depth attachment point
|
||||
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
|
||||
// attach the renderbuffer to stencil attachment point
|
||||
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
|
||||
|
||||
if (supportFBO == FBO_EXT_STENCIL)
|
||||
{
|
||||
// attach a renderbuffer to stencil attachment point
|
||||
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the renderbuffer
|
||||
@@ -3318,7 +3329,7 @@ static void GL_FBO_Generate(void)
|
||||
if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
{
|
||||
//pglGetError(); TODO:implement this or smth
|
||||
GL_MSG_Error("GL_FBO_Generate: Failed to create Framebuffer Object");
|
||||
GL_MSG_Error("GL_Framebuffer_Generate: Failed to create Framebuffer Object");
|
||||
|
||||
// if this fails, dont retry it a gazillion times
|
||||
// this wouldnt recover
|
||||
@@ -3333,7 +3344,7 @@ static void GL_FBO_Generate(void)
|
||||
framebufferobject.init = true;
|
||||
}
|
||||
|
||||
void GL_FBO_BindMainFrameBuffer(void)
|
||||
void GL_Framebuffer_Unbind(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
@@ -3342,22 +3353,22 @@ void GL_FBO_BindMainFrameBuffer(void)
|
||||
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
|
||||
}
|
||||
|
||||
void GL_FBO_Enable(void)
|
||||
void GL_Framebuffer_Enable(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE)
|
||||
if (supportFBO == FBO_NONE || !UseScreenFBO())
|
||||
return;
|
||||
|
||||
GL_FBO_Generate();
|
||||
GL_Framebuffer_Generate();
|
||||
|
||||
// failed
|
||||
if (!framebufferobject.init)
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
|
||||
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
|
||||
}
|
||||
|
||||
void GL_FBO_Disable(void)
|
||||
void GL_Framebuffer_Disable(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
@@ -3370,7 +3381,7 @@ void GL_FBO_Disable(void)
|
||||
pglDeleteFramebuffers(1, &framebufferobject.fboobj);
|
||||
framebufferobject.fboobj = 0;
|
||||
|
||||
GL_FBO_DeleteAttachments();
|
||||
GL_Framebuffer_DeleteAttachments();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3721,7 +3732,6 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
void GL_MakeScreenTexture(int tex)
|
||||
{
|
||||
boolean firstTime;
|
||||
static GLint lastfiltermode[NUMSCREENTEXTURES] = {-1, -1, -1, -1, -1};
|
||||
|
||||
if (!gl_enable_screen_textures)
|
||||
return;
|
||||
@@ -3734,29 +3744,16 @@ void GL_MakeScreenTexture(int tex)
|
||||
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
|
||||
|
||||
// if were downsampling, choose to do that with linear filter instead of nearest neighbor
|
||||
// otherwise well get ugly mixels
|
||||
GLint filtermode = I_IsDownsampling() ? GL_LINEAR : GL_NEAREST;
|
||||
|
||||
// avoid redundant calls to this, prob doesent really matter tbh
|
||||
if (filtermode != lastfiltermode[tex] || firstTime)
|
||||
{
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtermode);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtermode);
|
||||
|
||||
lastfiltermode[tex] = filtermode;
|
||||
}
|
||||
|
||||
if (firstTime)
|
||||
{
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
Clamp2D(GL_TEXTURE_WRAP_S);
|
||||
Clamp2D(GL_TEXTURE_WRAP_T);
|
||||
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, screen_texsizew, screen_texsizeh, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, screen_texsizew, screen_texsizeh);
|
||||
}
|
||||
|
||||
tex_downloaded = screenTextures[tex];
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ extern PFNglGetString pglGetString;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
void GL_FBO_BindMainFrameBuffer(void);
|
||||
void GL_FBO_Enable(void);
|
||||
void GL_FBO_Disable(void);
|
||||
void GL_Framebuffer_Unbind(void);
|
||||
void GL_Framebuffer_Enable(void);
|
||||
void GL_Framebuffer_Disable(void);
|
||||
extern int supportFBO;
|
||||
#endif
|
||||
|
||||
|
||||
+34
-4
@@ -752,9 +752,14 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
|
||||
|
||||
static void SOCK_Send(void)
|
||||
{
|
||||
ssize_t c = ERRSOCKET;
|
||||
int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
|
||||
size_t i, j;
|
||||
int retrycount = 0;
|
||||
ssize_t c;
|
||||
int e; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
|
||||
|
||||
retry:
|
||||
c = ERRSOCKET;
|
||||
e = 0;
|
||||
|
||||
if (doomcom->remotenode < 0 || !nodeconnected[doomcom->remotenode])
|
||||
return;
|
||||
@@ -808,10 +813,35 @@ static void SOCK_Send(void)
|
||||
|
||||
if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found
|
||||
{
|
||||
if (!ALLOWEDERROR(e))
|
||||
I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
|
||||
if (ALLOWEDERROR(e))
|
||||
return;
|
||||
|
||||
//if (!ALLOWEDERROR(e))
|
||||
//I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
|
||||
//SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
||||
|
||||
// no need to spam this on retries
|
||||
if (retrycount == 0)
|
||||
CONS_Alert(CONS_ERROR, "SOCK_Send, error sending to node %d (%s) #%u, %s\n", doomcom->remotenode,
|
||||
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
||||
|
||||
// retry sending it
|
||||
if (retrycount <= 3)
|
||||
{
|
||||
CONS_Printf("SOCK_Send: retrying... Attempt %d\n", retrycount+1);
|
||||
retrycount++;
|
||||
// wait quarter of a second or smth
|
||||
I_Sleep(250);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
// no recovery, guess we die
|
||||
I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
|
||||
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
||||
}
|
||||
|
||||
if (retrycount > 0)
|
||||
CONS_Alert(CONS_NOTICE, "SOCK_Send: successfully reconnected on Attempt %d\n", retrycount);
|
||||
}
|
||||
#undef ALLOWEDERROR
|
||||
|
||||
|
||||
+4
-2
@@ -126,9 +126,11 @@ boolean I_CheckNativeRes(void);
|
||||
void I_SetBorderlessWindow(void);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
void I_CheckDownSampleState(boolean forcerefresh);
|
||||
boolean I_IsDownsampling(void);
|
||||
|
||||
void RefreshOGLSDLSurface(void);
|
||||
void I_DownSample(void);
|
||||
boolean UseScreenFBO(void);
|
||||
extern boolean downsample;
|
||||
#endif
|
||||
|
||||
// So we can call this from i_video event loop
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "p_slopes.h"
|
||||
#include "r_main.h"
|
||||
|
||||
#include "lua_udatalib.h"
|
||||
#include "lua_script.h"
|
||||
#include "lua_libs.h"
|
||||
#include "lua_hud.h" // hud_running errors
|
||||
@@ -255,6 +256,15 @@ static const char *const vector_opt[] = {
|
||||
static const char *const array_opt[] ={"iterate",NULL};
|
||||
static const char *const valid_opt[] ={"valid",NULL};
|
||||
|
||||
#define pushsubsector(L, subsector) LUA_PushUserdata(L, subsector, META_SUBSECTOR)
|
||||
int udatalib_getter_subsector(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(subsector_t*, pushsubsector)
|
||||
#undef pushsubsector
|
||||
|
||||
#define pushslope(L, slope) LUA_PushUserdata(L, slope, META_SLOPE)
|
||||
int udatalib_getter_slope(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(pslope_t*, pushslope)
|
||||
#undef pushslope
|
||||
// iterates through a sector's thinglist!
|
||||
static int lib_iterateSectorThinglist(lua_State *L)
|
||||
{
|
||||
|
||||
+734
-767
File diff suppressed because it is too large.
Load diff
+422
-847
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,137 @@
|
||||
// SONIC ROBO BLAST 2 KART SATURN
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2025 by Indev.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file lua_udatalib.c
|
||||
/// \brief Implementation of lua userdata object metatables based on getter/setter functions
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "m_fixed.h"
|
||||
#include "lua_udatalib.h"
|
||||
|
||||
// Getters
|
||||
int udatalib_getter_fixed(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(fixed_t, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_angle(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(angle_t, lua_pushangle)
|
||||
|
||||
int udatalib_getter_uint8(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(UINT8, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_sint8(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(SINT8, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_uint16(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(UINT16, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_int16(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(INT16, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_uint32(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(UINT32, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_int32(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(INT32, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_uint64(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(UINT64, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_int64(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(INT64, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_string(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(const char*, lua_pushstring)
|
||||
|
||||
int udatalib_getter_boolean(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(boolean, lua_pushboolean)
|
||||
|
||||
int udatalib_getter_spritenum(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(spritenum_t, lua_pushinteger)
|
||||
|
||||
int udatalib_getter_tic(lua_State *L)
|
||||
UDATALIB_SIMPLE_GETTER(tic_t, lua_pushinteger)
|
||||
|
||||
// Setters
|
||||
int udatalib_setter_fixed(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(fixed_t, luaL_checkfixed)
|
||||
|
||||
int udatalib_setter_angle(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(angle_t, luaL_checkangle)
|
||||
|
||||
int udatalib_setter_uint8(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(UINT8, (UINT8)luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_sint8(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(SINT8, luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_uint16(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(UINT16, (UINT16)luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_int16(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(INT16, luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_uint32(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(UINT32, (UINT32)luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_int32(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(INT32, luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_uint64(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(UINT64, (UINT64)luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_int64(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(INT64, luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_string(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(const char*, luaL_checkstring)
|
||||
|
||||
int udatalib_setter_boolean(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(boolean, luaL_checkboolean)
|
||||
|
||||
// ffs
|
||||
int udatalib_setter_boolean_nocheck(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(boolean, lua_toboolean)
|
||||
|
||||
int udatalib_setter_spritenum(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(spritenum_t, luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_tic(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(tic_t, (tic_t)luaL_checkinteger)
|
||||
|
||||
|
||||
void udatalib_addfield(lua_State *L, int mt, udata_field_t field)
|
||||
{
|
||||
int idx = abs_index(L, mt);
|
||||
|
||||
lua_createtable(L, 2, 0); // Push table
|
||||
|
||||
lua_pushinteger(L, field.offset); // Push offset
|
||||
lua_pushcclosure(L, field.getter, 1); // Pop offset, push closure
|
||||
|
||||
lua_rawseti(L, -2, UDATALIB_GETTER); // Pop closure, add to table
|
||||
|
||||
lua_pushinteger(L, field.offset); // Push offset
|
||||
lua_pushcclosure(L, field.setter, 1); // Pop offset, push closure
|
||||
|
||||
lua_rawseti(L, -2, UDATALIB_SETTER); // Pop closure, add to table
|
||||
|
||||
lua_pushstring(L, field.name); // Push field name
|
||||
lua_pushvalue(L, -2); // Copy table
|
||||
lua_rawset(L, idx); // Pop field name and table, add to metatable
|
||||
|
||||
lua_pop(L, 1); // Pop field table
|
||||
}
|
||||
|
||||
void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[])
|
||||
{
|
||||
for (unsigned i = 0; fields[i].name != NULL; ++i)
|
||||
{
|
||||
udatalib_addfield(L, mt, fields[i]);
|
||||
//CONS_Printf("Add field name=%s, offset=%d, getter=%p, setter=%p\n", fields[i].name, fields[i].offset, fields[i].getter, fields[i].setter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// SONIC ROBO BLAST 2 KART SATURN
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2025 by Indev.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file lua_udatalib.h
|
||||
/// \brief Implementation of lua userdata object metatables based on getter/setter functions
|
||||
|
||||
#ifndef __LUA_UDATALIB_H__
|
||||
#define __LUA_UDATALIB_H__
|
||||
|
||||
#include "doomdef.h"
|
||||
#include "lua_script.h"
|
||||
#include "lua_libs.h"
|
||||
#include "fastcmp.h"
|
||||
|
||||
// Indices in getter/setter tables for fields
|
||||
#define UDATALIB_GETTER 1
|
||||
#define UDATALIB_SETTER 2
|
||||
|
||||
typedef struct udata_field_s {
|
||||
const char *name;
|
||||
size_t offset;
|
||||
lua_CFunction getter;
|
||||
lua_CFunction setter;
|
||||
} udata_field_t;
|
||||
|
||||
// Simple setters and getters, for situations where getter is simply
|
||||
// "return obj.field" and setter is "obj.field = value"
|
||||
int udatalib_getter_fixed(lua_State *L);
|
||||
int udatalib_getter_angle(lua_State *L);
|
||||
int udatalib_getter_uint8(lua_State *L);
|
||||
int udatalib_getter_sint8(lua_State *L);
|
||||
int udatalib_getter_uint16(lua_State *L);
|
||||
int udatalib_getter_int16(lua_State *L);
|
||||
int udatalib_getter_uint32(lua_State *L);
|
||||
int udatalib_getter_int32(lua_State *L);
|
||||
int udatalib_getter_uint64(lua_State *L);
|
||||
int udatalib_getter_int64(lua_State *L);
|
||||
int udatalib_getter_string(lua_State *L);
|
||||
int udatalib_getter_boolean(lua_State *L);
|
||||
int udatalib_getter_spritenum(lua_State *L);
|
||||
int udatalib_getter_mobj(lua_State *L);
|
||||
int udatalib_getter_subsector(lua_State *L);
|
||||
int udatalib_getter_mobjtype(lua_State *L);
|
||||
int udatalib_getter_player(lua_State *L);
|
||||
int udatalib_getter_mapthing(lua_State *L);
|
||||
int udatalib_getter_slope(lua_State *L);
|
||||
int udatalib_getter_cmd(lua_State *L);
|
||||
int udatalib_getter_playerstate(lua_State *L);
|
||||
int udatalib_getter_powers(lua_State *L);
|
||||
int udatalib_getter_kartstuff(lua_State *L);
|
||||
int udatalib_getter_pflags(lua_State *L);
|
||||
int udatalib_getter_panim(lua_State *L);
|
||||
int udatalib_getter_tic(lua_State *L);
|
||||
|
||||
int udatalib_setter_fixed(lua_State *L);
|
||||
int udatalib_setter_angle(lua_State *L);
|
||||
int udatalib_setter_uint8(lua_State *L);
|
||||
int udatalib_setter_sint8(lua_State *L);
|
||||
int udatalib_setter_uint16(lua_State *L);
|
||||
int udatalib_setter_int16(lua_State *L);
|
||||
int udatalib_setter_uint32(lua_State *L);
|
||||
int udatalib_setter_int32(lua_State *L);
|
||||
int udatalib_setter_uint64(lua_State *L);
|
||||
int udatalib_setter_int64(lua_State *L);
|
||||
int udatalib_setter_string(lua_State *L);
|
||||
int udatalib_setter_boolean(lua_State *L);
|
||||
int udatalib_setter_boolean_nocheck(lua_State *L);
|
||||
int udatalib_setter_spritenum(lua_State *L);
|
||||
int udatalib_setter_mobj(lua_State *L);
|
||||
int udatalib_setter_playerstate(lua_State *L);
|
||||
int udatalib_setter_pflags(lua_State *L);
|
||||
int udatalib_setter_panim(lua_State *L);
|
||||
int udatalib_setter_tic(lua_State *L);
|
||||
|
||||
// Adds setter and getter for field and stores it as field.name..".get" and
|
||||
// field.name..".set" in table at index mt. (metatable, usually)
|
||||
void udatalib_addfield(lua_State *L, int mt, udata_field_t field);
|
||||
|
||||
// Convinience function to add array of fields at once.
|
||||
void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]);
|
||||
|
||||
// I miss C++ template functons :(
|
||||
|
||||
// Get pointer to field value within getter or setter
|
||||
#define UDATALIB_GETFIELD(type, field) \
|
||||
{ \
|
||||
size_t offset = lua_tointeger(L, lua_upvalueindex(1)); \
|
||||
field = (type*)((uint8_t*)lua_touserdata(L, 1) + offset); \
|
||||
}
|
||||
|
||||
// Creates implementation for simple getter and setter. Super lazy, yes.
|
||||
// Assumes userdata is a pointer to actual data. Maybe not really safe.
|
||||
#define UDATALIB_SIMPLE_GETTER(type, pushf) \
|
||||
{ \
|
||||
type *field; \
|
||||
UDATALIB_GETFIELD(type, field) \
|
||||
pushf(L, *field); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
#define UDATALIB_SIMPLE_SETTER(type, checkf) \
|
||||
{ \
|
||||
type *field; \
|
||||
UDATALIB_GETFIELD(type, field) \
|
||||
*field = checkf(L, 2); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#endif
|
||||
+2
-1
@@ -14,7 +14,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#define local_for_thread _Thread_local
|
||||
#include <threads.h>
|
||||
#define local_for_thread thread_local
|
||||
#else
|
||||
#define local_for_thread
|
||||
#endif
|
||||
|
||||
+7
-18
@@ -3989,10 +3989,6 @@ boolean replaynamesloaded = false;
|
||||
// If it's not equal, that means we started more than one thread (left and re-entered menu for example)
|
||||
size_t replaythreadnum = 0;
|
||||
|
||||
// for replay dates
|
||||
#include <locale.h>
|
||||
const char *demodateformat = "%d.%m.%Y";
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_mutex replayquerymutex;
|
||||
|
||||
@@ -4029,7 +4025,6 @@ static void ReplayNamesLoadThread(void* userdata)
|
||||
menudemo_t *demolist_all_local = (menudemo_t*)malloc(sizeof(menudemo_t)*demolist_all_size_local);
|
||||
memcpy(demolist_all_local, demolist_all, sizeof(menudemo_t)*demolist_all_size_local);
|
||||
size_t localreplaythreadnum = replaythreadnum;
|
||||
const char *localdemodateformat = demodateformat;
|
||||
|
||||
Unlock_search_state();
|
||||
|
||||
@@ -4037,7 +4032,13 @@ static void ReplayNamesLoadThread(void* userdata)
|
||||
{
|
||||
if (demolist_all_local[i].type != MD_SUBDIR)
|
||||
{
|
||||
G_LoadDemoTitle(&demolist_all_local[i], localdemodateformat);
|
||||
G_LoadDemoTitle(&demolist_all_local[i]);
|
||||
|
||||
// this is fucking horrid, but i wanna be able to search for dates
|
||||
/*if (demolist_all_local[i].date[0] != '\0')
|
||||
{
|
||||
snprintf(demolist_all_local[i].title, sizeof(demolist_all_local[i].title), "%s %s", demolist_all_local[i].title, demolist_all_local[i].date);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4060,18 +4061,6 @@ static void LoadReplayNames(void)
|
||||
Lock_search_state();
|
||||
replaythreadnum++;
|
||||
replaynamesloaded = false;
|
||||
if (cv_demodateformat.value == 2)
|
||||
demodateformat = "%m.%d.%Y";
|
||||
else if (cv_demodateformat.value == 1)
|
||||
demodateformat = "%d.%m.%Y";
|
||||
else
|
||||
{
|
||||
// get the date format here
|
||||
// setlocale reads/writes global state
|
||||
const char *locale = setlocale(LC_TIME, NULL);
|
||||
// US ppl are special (:
|
||||
demodateformat = (locale && strstr(locale, "en_US")) ? "%m.%d.%Y" : "%d.%m.%Y";
|
||||
}
|
||||
Unlock_search_state();
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
||||
+66
-31
@@ -97,9 +97,11 @@ static char vidModeName[33][32]; // allow 33 different modes
|
||||
rendermode_t rendermode = render_none;
|
||||
|
||||
#ifdef HWRENDER
|
||||
unsigned msaa = 0;
|
||||
|
||||
// Eee probably the way i organize it isn't best ><
|
||||
// Just don't know where do i put declaration and "implementation"
|
||||
unsigned msaa = 0;
|
||||
boolean a2c = false;
|
||||
#endif
|
||||
|
||||
static void KeyboardLayout_OnChange(void)
|
||||
@@ -195,6 +197,10 @@ static INT32 custom_height = 0;
|
||||
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
boolean downsample = false;
|
||||
#endif
|
||||
|
||||
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
|
||||
{
|
||||
if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
|
||||
@@ -516,7 +522,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
#ifdef USE_FBO_OGL
|
||||
I_CheckDownSampleState(false);
|
||||
I_DownSample();
|
||||
#endif
|
||||
windowmoved = SDL_FALSE;
|
||||
}
|
||||
@@ -1257,9 +1263,8 @@ static void I_CheckDesktopRes(void)
|
||||
int currentDisplayIndex = -1;
|
||||
SDL_DisplayMode curmode;
|
||||
|
||||
// just fallback to game res ig?
|
||||
desktopwidth = vid.width;
|
||||
desktopheight = vid.height;
|
||||
desktopwidth = 0;
|
||||
desktopheight = 0;
|
||||
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
|
||||
|
||||
@@ -1269,7 +1274,7 @@ static void I_CheckDesktopRes(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) < 0)
|
||||
if (SDL_GetDesktopDisplayMode(currentDisplayIndex, &curmode) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1284,39 +1289,47 @@ boolean I_CheckNativeRes(void)
|
||||
return (vid.width == desktopwidth && vid.height == desktopheight);
|
||||
}
|
||||
|
||||
static boolean I_CheckAboveDesktopRes(INT32 width, INT32 height)
|
||||
{
|
||||
return (width > desktopwidth || height > desktopheight);
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
static boolean vid_downsampling = false;
|
||||
|
||||
boolean I_IsDownsampling(void)
|
||||
void RefreshOGLSDLSurface(void)
|
||||
{
|
||||
return vid_downsampling;
|
||||
if (rendermode == render_opengl)
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
}
|
||||
|
||||
void I_CheckDownSampleState(boolean forcerefresh)
|
||||
void I_DownSample(void)
|
||||
{
|
||||
// no fbo support so we dont care
|
||||
if (!supportFBO)
|
||||
boolean needrefresh = false;
|
||||
|
||||
if (!cv_glframebuffer.value || !supportFBO || (cv_glscreentextures.value == 0)) // no sense to do this crap if we cant benefit from it
|
||||
{
|
||||
vid_downsampling = false;
|
||||
downsample = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// no sense to do this crap if we cant benefit from it
|
||||
const boolean newdownsamplestate = cv_glframebuffer.value && (cv_glscreentextures.value == 2) && I_CheckAboveDesktopRes(vid.width, vid.height);
|
||||
|
||||
// state changed or fbo was toggled
|
||||
if (vid_downsampling != newdownsamplestate || forcerefresh)
|
||||
if (I_CheckNativeRes() && (downsample == true))
|
||||
{
|
||||
//printf("downsample changed from %d to %d\n", vid_downsampling, curdownsamplestate);
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
downsample = false;
|
||||
RefreshOGLSDLSurface();
|
||||
return;
|
||||
}
|
||||
|
||||
vid_downsampling = newdownsamplestate;
|
||||
if ((vid.width > desktopwidth) || (vid.height > desktopheight)) //check if current resolution is higher than current display resolution
|
||||
{
|
||||
downsample = true;
|
||||
needrefresh = true;
|
||||
}
|
||||
else if (downsample == true)
|
||||
{
|
||||
downsample = false;
|
||||
needrefresh = true;
|
||||
}
|
||||
|
||||
if (needrefresh)
|
||||
{
|
||||
RefreshOGLSDLSurface();
|
||||
needrefresh = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1346,11 +1359,10 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
}
|
||||
|
||||
// Reposition window only in windowed mode
|
||||
const int windowpos = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_SetWindowSize(window, width, height);
|
||||
SDL_SetWindowPosition(window,
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(windowpos),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(windowpos)
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1372,7 +1384,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
#ifdef USE_FBO_OGL
|
||||
I_CheckDownSampleState(false);
|
||||
I_DownSample();
|
||||
#endif
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
}
|
||||
@@ -1813,6 +1825,7 @@ void I_StartupGraphics(void)
|
||||
rendermode = render_opengl;
|
||||
|
||||
msaa = 0; boolean msaa_set = false;
|
||||
a2c = false; boolean a2c_set = false;
|
||||
|
||||
// MSAA antialiasing
|
||||
if (M_CheckParm("-msaa") && M_IsNextParm())
|
||||
@@ -1824,6 +1837,16 @@ void I_StartupGraphics(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (M_CheckParm("-a2c"))
|
||||
{
|
||||
a2c = true;
|
||||
a2c_set = true;
|
||||
}
|
||||
else if (M_CheckParm("-noa2c"))
|
||||
{
|
||||
a2c_set = true;
|
||||
}
|
||||
|
||||
{
|
||||
char line[16];
|
||||
char * word;
|
||||
@@ -1867,10 +1890,19 @@ void I_StartupGraphics(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("Using last known MSAA value: %u\n", msaa);
|
||||
CONS_Printf("Using last know MSAA value: %u\n", msaa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!a2c_set)
|
||||
{
|
||||
if (fasticmp(word, "a2c"))
|
||||
{
|
||||
a2c = true;
|
||||
CONS_Printf("Using a2c because it was specified to be used earlier\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
@@ -1905,6 +1937,9 @@ void I_StartupGraphics(void)
|
||||
|
||||
#ifdef HWRENDER
|
||||
fprintf(file, "msaa %u\n", msaa);
|
||||
|
||||
if (a2c)
|
||||
fputs("a2c\n", file);
|
||||
#endif
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
+10
-6
@@ -65,7 +65,7 @@ PFNglGetString pglGetString;
|
||||
#ifdef USE_FBO_OGL
|
||||
boolean UseScreenFBO(void)
|
||||
{
|
||||
return (supportFBO && cv_glframebuffer.value && I_IsDownsampling() && (cv_glscreentextures.value == 2));
|
||||
return (supportFBO && cv_glframebuffer.value && downsample);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -203,9 +203,9 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
if (UseScreenFBO())
|
||||
GL_FBO_Enable();
|
||||
GL_Framebuffer_Enable();
|
||||
else
|
||||
GL_FBO_Disable();
|
||||
GL_Framebuffer_Disable();
|
||||
#endif
|
||||
|
||||
if (!first_init)
|
||||
@@ -235,7 +235,9 @@ void OglSdlFinishUpdate(SDL_Window *window)
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
if (usefbo)
|
||||
GL_FBO_BindMainFrameBuffer();
|
||||
{
|
||||
GL_Framebuffer_Unbind();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
@@ -253,7 +255,9 @@ void OglSdlFinishUpdate(SDL_Window *window)
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
if (usefbo)
|
||||
GL_FBO_Enable();
|
||||
{
|
||||
GL_Framebuffer_Enable();
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
@@ -264,7 +268,7 @@ void OglSdlFinishUpdate(SDL_Window *window)
|
||||
// effects that want to take the old screen can do so after this
|
||||
// well we dont need it on native res it seems
|
||||
#ifdef USE_FBO_OGL
|
||||
if (!usefbo && (!I_CheckNativeRes() || WipeInAction))
|
||||
if ((!I_CheckNativeRes() && !usefbo) || WipeInAction)
|
||||
#else
|
||||
if (!I_CheckNativeRes() || WipeInAction)
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user