Compare commits

..
Author SHA1 Message Date
alufolie91 cfc94c0f9e fix horizonlines on fofs in opengl
not super cool but seems to work just fine
the new subsector flag may even improve performance in some cases since the horizonspecial check seems to mess up the branch predictor often lol
2026-11-11 00:55:41 +01:00
alufolie91 3385df4c7e allow gl fbo to be enabled at all times
not just when downsampling
as this may improve performance in some cases
2026-11-10 17:48:30 +01:00
alufolie91 561f871e61 fix downsample state not refreshing in the right place
needs to be done before refreshing the surface, as OglSdlSurface needs to determine the state to toggle the fbo
2026-11-10 17:48:27 +01:00
alufolie91 bffafa0540 make screen fbo msaa compatible
quite a mess but "works"
the reason this didnt work before was
i mostly tried doing this per multisample textures which you cant really copy from
now we do it per color rbo which you also cant really copy from, but is the recommended way
so now each time we try to copy from the screen (screentextures, screenshots, etc.) we blit the msaa fbo into the normal fbo so we can copy from that
its probably a little slow, but cant really do much about it besides getting rid of screen textures and replacing them with more fbo logic.....
2026-11-10 17:27:11 +01:00
13 changed files with 1948 additions and 1643 deletions

No files matched your search

+2
View File
@@ -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
)
+1
View File
@@ -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
+303 -11
View File
@@ -16,6 +16,7 @@
#include <algorithm>
#include <vector>
#include "../d_main.h"
#include "../doomstat.h"
#include "../doomdef.h"
@@ -120,7 +121,7 @@ ps_metric_t ps_hw_batchdrawtime = {};
static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags);
static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap, subsector_t *subsector);
static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
static void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
@@ -204,7 +205,8 @@ static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 b
consvar_t cv_glscreentextures = {"gr_screentextures", "All", CV_CALL|CV_SAVE, glscreentextures_cons_t, CV_screentextures_OnChange, 0, NULL, NULL, 0, 0, NULL};
#ifdef USE_FBO_OGL
consvar_t cv_glframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_glframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t glframebuffer_cons_t[] = {{0, "Off"}, {1, "Downsample"}, {2, "Always"}, {0, NULL}};
consvar_t cv_glframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL, glframebuffer_cons_t, CV_glframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t cv_glmdls = {"gr_mdls", "Off", CV_SAVE|CV_CALL, CV_OnOff, M_UpdateOGLMenu, 0, NULL, NULL, 0, 0, NULL};
@@ -267,8 +269,8 @@ static void CV_glframebuffer_OnChange(void)
// 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
I_CheckDownSampleState(true);
if (loaded_config) // dont do this crap on startup, this is handled elsewhere
I_CheckDownSampleState(true);
M_UpdateOGLMenu();
intermissionbginit = false;
}
@@ -721,7 +723,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false);
if (gl_maphashorizonlines && subsector && !FOFsector && cv_glhorizonlines.value)
if (gl_maphashorizonlines && subsector && subsector->hashorizon && cv_glhorizonlines.value)
{
// Horizon lines
FOutVector horizonpts[6];
@@ -806,6 +808,268 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
#undef SETUP3DVERT
}
static void HWR_RenderFOFHorizonPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
{
FSurfaceInfo Surf = {};
polyvertex_t *pv;
pslope_t *slope = NULL;
INT32 shader = SHADER_NONE;
size_t nrPlaneVerts;
INT32 i;
float height; // constant y for all points on the convex flat polygon
static float flatxref = 0.0f, flatyref = 0.0f;
static float fflatsize = 64.0f;
static INT32 flatflag = 63;
size_t len;
float tempxsow, tempytow;
float scrollx = 0.0f, scrolly = 0.0f;
float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f;
angle_t angle = 0;
static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0;
poly_t *planepoly = xsub->planepoly;
if (!gl_maphashorizonlines || !cv_glhorizonlines.value)
return;
if (!subsector || !subsector->hashorizon)
return;
// no convex poly were generated for this subsector
if (!planepoly)
return;
nrPlaneVerts = planepoly->numpts;
if (nrPlaneVerts < 3) // not even a triangle ?
return;
const sector_t *sec = FOFsector;
if (!(PolyFlags & PF_NoTexture))
{
HWR_GetFlat(lumpnum, R_NoEncore(FOFsector, !isceiling));
}
// Get the slope pointer to simplify future code
if (!isceiling && sec->f_slope)
slope = sec->f_slope;
else if (isceiling && sec->c_slope)
slope = sec->c_slope;
height = FixedToFloat(fixedheight);
// Allocate plane-vertex buffer if we need to
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
{
numAllocedPlaneVerts = (UINT16)nrPlaneVerts;
Z_Free(planeVerts);
Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts);
}
len = W_LumpLength(lumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
fflatsize = 2048.0f;
flatflag = 2047;
break;
case 1048576: // 1024x1024 lump
fflatsize = 1024.0f;
flatflag = 1023;
break;
case 262144: // 512x512 lump
fflatsize = 512.0f;
flatflag = 511;
break;
case 65536: // 256x256 lump
fflatsize = 256.0f;
flatflag = 255;
break;
case 16384: // 128x128 lump
fflatsize = 128.0f;
flatflag = 127;
break;
case 1024: // 32x32 lump
fflatsize = 32.0f;
flatflag = 31;
break;
default: // 64x64 lump
fflatsize = 64.0f;
flatflag = 63;
break;
}
pv = planepoly->pts;
// reference point for flat texture coord for each vertex around the polygon
flatxref = static_cast<float>(static_cast<fixed_t>(pv->x) & (~flatflag)) / fflatsize;
flatyref = static_cast<float>(static_cast<fixed_t>(pv->y) & (~flatflag)) / fflatsize;
if (!isceiling) // it's a floor
{
scrollx = FixedToFloat(sec->floor_xoffs)/fflatsize;
scrolly = FixedToFloat(sec->floor_yoffs)/fflatsize;
angle = sec->floorpic_angle;
}
else // it's a ceiling
{
scrollx = FixedToFloat(sec->ceiling_xoffs)/fflatsize;
scrolly = FixedToFloat(sec->ceiling_yoffs)/fflatsize;
angle = sec->ceilingpic_angle;
}
if (angle) // Only needs to be done if there's an altered angle
{
// This needs to be done so that it scrolls in a different direction after rotation like software
tempxsow = flatxref;
tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle));
// This needs to be done so everything aligns after rotation
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
cosangf = cosf(anglef);
sinangf = sinf(anglef);
flatxref = (tempxsow * cosangf) - (tempytow * sinangf);
flatyref = (tempxsow * sinangf) + (tempytow * cosangf);
}
#define SETUP3DVERT(vert, vx, vy) {\
/* Hurdler: add scrolling texture on floor/ceiling */\
vert->s = (float)(((vx) / fflatsize) - flatxref + scrollx);\
vert->t = (float)(flatyref - ((vy) / fflatsize) + scrolly);\
\
/* Need to rotate before translate */\
if (angle) /* Only needs to be done if there's an altered angle */\
{\
tempxsow = vert->s;\
tempytow = vert->t;\
vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\
vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\
}\
\
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
height = FixedToFloat(fixedheight);\
}\
\
vert->x = (vx);\
vert->y = height;\
vert->z = (vy);\
\
}
HWR_Lighting(&Surf, lightlevel, planecolormap, false);
if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment))
{
Surf.PolyColor.s.alpha = (UINT8)alpha;
PolyFlags |= PF_Modulated;
}
else
PolyFlags |= PF_Masked|PF_Modulated;
if (HWR_UseShader())
{
if (PolyFlags & PF_Fog)
shader = SHADER_FOG;
else if (cv_ripplewater.value && (PolyFlags & PF_Ripple))
shader = SHADER_WATER;
else
shader = SHADER_FLOOR;
PolyFlags |= PF_ColorMapped;
}
// Horizon lines
FOutVector horizonpts[6];
float dist, vx, vy;
float x1, y1, xd, yd;
UINT8 numplanes, j;
vertex_t v; // For determining the closest distance from the line to the camera, to split render planes for minimum distortion;
static constexpr float renderdist = 27000.0f; // How far out to properly render the plane
static constexpr float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion
const seg_t *line = &segs[subsector->firstline];
for (i = 0; i < subsector->numlines; i++, line++)
{
if (line->polyseg)
continue;
line_t* ld = line->linedef;
if (LIKELY(ld->special != HORIZONSPECIAL))
continue;
if (R_PointOnSegSide(viewx, viewy, line) != 0)
continue;
P_ClosestPointOnLine(viewx, viewy, ld, &v);
dist = FixedToFloat(R_PointToDist(v.x, v.y));
x1 = (line->fv1.x);
y1 = (line->fv1.y);
xd = (line->fv2.x) - x1;
yd = (line->fv2.y) - y1;
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
if (dist > 100.0f)
numplanes = 100;
else
numplanes = (UINT8)dist + 1;
for (j = 0; j < numplanes; j++)
{
// Left side
vx = x1 + xd * j / numplanes;
vy = y1 + yd * j / numplanes;
SETUP3DVERT((&horizonpts[1]), vx, vy);
dist = sqrtf(powf(vx - gl_viewx, 2) + powf(vy - gl_viewy, 2));
vx = (vx - gl_viewx) * renderdist / dist + gl_viewx;
vy = (vy - gl_viewy) * renderdist / dist + gl_viewy;
SETUP3DVERT((&horizonpts[0]), vx, vy);
// Right side
vx = x1 + xd * (j+1) / numplanes;
vy = y1 + yd * (j+1) / numplanes;
SETUP3DVERT((&horizonpts[2]), vx, vy);
dist = sqrtf(powf(vx - gl_viewx, 2) + powf(vy - gl_viewy, 2));
vx = (vx - gl_viewx) * renderdist / dist + gl_viewx;
vy = (vy - gl_viewy) * renderdist / dist + gl_viewy;
SETUP3DVERT((&horizonpts[3]), vx, vy);
// Horizon fills
vx = (horizonpts[0].x - gl_viewx) * farrenderdist / renderdist + gl_viewx;
vy = (horizonpts[0].z - gl_viewy) * farrenderdist / renderdist + gl_viewy;
SETUP3DVERT((&horizonpts[5]), vx, vy);
horizonpts[5].y = gl_viewz;
vx = (horizonpts[3].x - gl_viewx) * farrenderdist / renderdist + gl_viewx;
vy = (horizonpts[3].z - gl_viewy) * farrenderdist / renderdist + gl_viewy;
SETUP3DVERT((&horizonpts[4]), vx, vy);
horizonpts[4].y = gl_viewz;
// Draw
HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true);
}
}
#undef SETUP3DVERT
}
#ifdef WALLSPLATS
static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
{
@@ -2960,16 +3224,14 @@ static void HWR_Subsector(size_t num)
UINT8 alpha;
light = R_GetPlaneLight(gl_frontsector, centerHeight, underside);
alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap);
HWR_AddTransparentFloor(0,
&extrasubsectors[num],
!bottom,
roverheight,
*gl_frontsector->lightlist[light].lightlevel,
alpha, rover->master->frontsector, PF_Fog|PF_NoTexture,
true, rover->master->frontsector->extra_colormap);
true, rover->master->frontsector->extra_colormap, sub);
}
else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient
{
@@ -2981,13 +3243,12 @@ static void HWR_Subsector(size_t num)
roverheight,
*gl_frontsector->lightlist[light].lightlevel,
CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast<FBITFIELD>(PF_Translucent)),
false, gl_frontsector->lightlist[light].extra_colormap);
false, gl_frontsector->lightlist[light].extra_colormap, sub);
}
else
{
HWR_GetFlat(flatlump, R_NoEncore(rover->master->frontsector, bottom));
light = R_GetPlaneLight(gl_frontsector, centerHeight, underside);
HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump,
rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap);
}
@@ -4191,7 +4452,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I
wallinfo->wallcolormap = wallcolormap;
}
static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap, subsector_t *subsector)
{
planeinfo_t *planeinfo = static_cast<planeinfo_t*>(HWR_CreateDrawNode(DRAWNODE_PLANE));
@@ -4205,6 +4466,9 @@ static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, b
planeinfo->blend = blend;
planeinfo->fogplane = fogplane;
planeinfo->planecolormap = planecolormap;
// horizonplanes need to be drawn BEFORE skywalls, so lets hope this works without too many issues....
HWR_RenderFOFHorizonPlane(subsector, planeinfo->xsub, planeinfo->isceiling, planeinfo->fixedheight, planeinfo->blend, planeinfo->lightlevel, planeinfo->lumpnum, planeinfo->FOFSector, (UINT8)planeinfo->alpha, planeinfo->planecolormap);
}
// Adding this for now until I can create extrasubsector info for polyobjects
@@ -5776,9 +6040,37 @@ void HWR_RenderPlayerView(void)
GL_GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
}
// go through subsectors and check if they contain atleast one horizonline
// this is purely for performance reasons
static void HWR_CheckHorizonSubsectors(void)
{
size_t i;
INT32 j;
// not sure if we really need this anymore now
if (!gl_maphashorizonlines)
return;
for (i = 0; i < numsubsectors; ++i)
{
subsector_t *sub = &subsectors[i];
const seg_t *seg = &segs[sub->firstline];
for (j = 0; j < sub->numlines; ++j, ++seg)
{
if (!seg->polyseg && seg->linedef && seg->linedef->special == HORIZONSPECIAL)
{
sub->hashorizon = true;
break;
}
}
}
}
void HWR_LoadLevel(void)
{
HWR_CreatePlanePolygons((INT32)numnodes - 1);
HWR_CheckHorizonSubsectors();
// Build the sky dome
HWR_ClearSkyDome();
+216 -12
View File
@@ -141,26 +141,56 @@ enum
typedef struct
{
GLuint fboobj; // actual Framebuffer Object
GLuint rboobj; // Renderbuffer Object
GLuint tex; // Framebuffer texture
GLuint fboobj; // normal single sample fbo
GLuint rboobj; // normal single sample rbo for depth and stencil stuff
GLuint tex; // fbo texture for color
GLuint msaa_fboobj; // msaa fbo
GLuint msaa_rboobj; // msaa rbo for color this time
GLuint msaa_depthrboobj; // msaa rbo for depth and stencil stuff
boolean init;
boolean msaa; // true if the msaa fbo is the render target ugh
boolean bound; // true if the fbo is currently bound as the framebuffer
} fboobj_t;
// this is a little messy but less messy than having two of those tbh
static fboobj_t framebufferobject = {};
int supportFBO = FBO_NONE;
// older gl versions might not have these, so prevent compile errors
// this should still give a simple depth only rbo
#ifndef GL_DEPTH_COMPONENT
#define GL_DEPTH_COMPONENT 0x1902
#endif
#ifndef GL_DEPTH_ATTACHMENT_EXT
#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
#endif
#ifndef GL_DEPTH24_STENCIL8
GL_DEPTH24_STENCIL8 GL_DEPTH_COMPONENT_EXT
#define GL_DEPTH24_STENCIL8 0x88F0
#endif
#ifndef GL_DEPTH_STENCIL_ATTACHMENT
GL_DEPTH_STENCIL_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
#endif
#ifndef GL_COLOR_ATTACHMENT0_EXT
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
#endif
#ifndef GL_READ_FRAMEBUFFER_EXT
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
#endif
#ifndef GL_DRAW_FRAMEBUFFER_EXT
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
#endif
#ifndef GL_FRAMEBUFFER_EXT
#define GL_FRAMEBUFFER_EXT 0x8D40
#endif
#ifndef GL_RENDERBUFFER_EXT
#define GL_RENDERBUFFER_EXT 0x8D41
#endif
#ifndef GL_FRAMEBUFFER_COMPLETE_EXT
#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
#endif
static void GL_FBO_DeleteAttachments(void);
static void GL_FBO_Resolve(GLbitfield mask);
#endif
// needed for glportals
@@ -478,6 +508,10 @@ typedef void (APIENTRY * PFNglRenderbufferStorage) (GLenum target, GLenum intern
static PFNglRenderbufferStorage pglRenderbufferStorage;
typedef void (APIENTRY * PFNglFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLenum renderbuffer);
static PFNglFramebufferRenderbuffer pglFramebufferRenderbuffer;
typedef void (APIENTRY * PFNglRenderbufferStorageMultisample) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
static PFNglRenderbufferStorageMultisample pglRenderbufferStorageMultisample;
typedef void (APIENTRY * PFNglBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
static PFNglBlitFramebuffer pglBlitFramebuffer;
/* 2.1 extension functions for framebuffers and renderbuffers */
typedef void (APIENTRY * PFNglGenFramebuffersEXT) (GLsizei n, GLuint *ids);
@@ -899,6 +933,17 @@ void SetupGLFunc4(void)
GetGLfunc(glRenderbufferStorage);
GetGLfunc(glFramebufferRenderbuffer);
// multisample support, this should be in core per gl 3.0 and newer
pglRenderbufferStorageMultisample = GetGLFunc("glRenderbufferStorageMultisample");
pglBlitFramebuffer = GetGLFunc("glBlitFramebuffer");
if (!pglRenderbufferStorageMultisample || !pglBlitFramebuffer)
{
pglRenderbufferStorageMultisample = NULL;
pglBlitFramebuffer = NULL;
GL_DBG_Printf("\nFBO: No multisample support\n");
}
GL_DBG_Printf("\nFBO: ARB extensions found\n");
}
else if (fbocheck == FBO_EXT) // uh oh only support old fbo extensions...
@@ -935,6 +980,21 @@ void SetupGLFunc4(void)
GetGLfunc(glFramebufferRenderbufferEXT);
pglFramebufferRenderbuffer = pglFramebufferRenderbufferEXT;
// multisample support needs the EXT multisample and blit extensions
if (GL_isExtAvailable("GL_EXT_framebuffer_multisample", gl_extensions) &&
GL_isExtAvailable("GL_EXT_framebuffer_blit", gl_extensions))
{
pglRenderbufferStorageMultisample = GetGLFunc("glRenderbufferStorageMultisampleEXT");
pglBlitFramebuffer = GetGLFunc("glBlitFramebufferEXT");
}
if (!pglRenderbufferStorageMultisample || !pglBlitFramebuffer)
{
pglRenderbufferStorageMultisample = NULL;
pglBlitFramebuffer = NULL;
GL_DBG_Printf("\nFBO: No multisample support\n");
}
GL_DBG_Printf("\nFBO: EXT extensions with packed depth-stencil\n");
}
@@ -1455,6 +1515,15 @@ void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale)
const INT32 stride = (screen_width/scale)*3;
INT32 scanlines = screen_height;
GLubyte * restrict image;
#ifdef USE_FBO_OGL
const boolean msaa_fbo = (framebufferobject.bound && framebufferobject.msaa);
#endif
#ifdef USE_FBO_OGL
// cant read from the msaa fbo, so gotta blit it first into either the single sample fbo or the screen framebuffer....
if (msaa_fbo)
GL_FBO_Resolve(GL_COLOR_BUFFER_BIT);
#endif
// at the time this function is called, generic2 can be found drawn on the framebuffer
// if some other screen texture is needed, draw it to the framebuffer
@@ -1496,9 +1565,16 @@ void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale)
memcpy(dest + i, image + i*scale, 3);
dest += stride;
}
// this probably could be done with fbos, might mess around with that some time :3
// ...yet still, restrict doesn't make the inner loop any faster
free(image - ((screen_height % scale) * screen_width*3));
#ifdef USE_FBO_OGL
// this´ll reenable the msaa fbo....
if (msaa_fbo)
GL_FBO_Enable();
#endif
}
// -----------------+
@@ -3242,7 +3318,7 @@ void GL_SetTransform(FTransform *stransform)
#ifdef USE_FBO_OGL
static void GL_FBO_DeleteAttachments(void)
{
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (supportFBO == FBO_NONE)
return;
// Unbind the framebuffer
@@ -3255,13 +3331,44 @@ static void GL_FBO_DeleteAttachments(void)
if (framebufferobject.rboobj)
pglDeleteRenderbuffers(1, &framebufferobject.rboobj);
if (framebufferobject.msaa_rboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_rboobj);
if (framebufferobject.msaa_depthrboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_depthrboobj);
framebufferobject.tex = 0;
framebufferobject.rboobj = 0;
framebufferobject.msaa_rboobj = 0;
framebufferobject.msaa_depthrboobj = 0;
framebufferobject.init = false;
framebufferobject.bound = false;
}
// blit the msaa fbo into the normal single sample fbo
// so we can use it to copy from and stuff
static void GL_FBO_Resolve(GLbitfield mask)
{
if (supportFBO == FBO_NONE || !framebufferobject.init || !framebufferobject.msaa)
return;
if (!pglBlitFramebuffer)
return;
pglBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, framebufferobject.msaa_fboobj);
pglBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, framebufferobject.fboobj);
pglBlitFramebuffer(0, 0, screen_width, screen_height,
0, 0, screen_width, screen_height,
mask, GL_NEAREST);
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
}
static void GL_FBO_Generate(void)
{
GLint msaasamples;
if (supportFBO == FBO_NONE || framebufferobject.init)
return;
@@ -3321,12 +3428,76 @@ static void GL_FBO_Generate(void)
GL_MSG_Error("GL_FBO_Generate: Failed to create Framebuffer Object");
// if this fails, dont retry it a gazillion times
// this wouldnt recover
// this probably wouldnt recover and we dont want any more black screens...
supportFBO = FBO_NONE;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
return;
}
// Try to set up a multisampled render target for MSAA
framebufferobject.msaa = false;
msaasamples = (GLint)msaa;
// maybe should just make more "supportFBO" cases or smth but :chaosleep:
if (msaasamples > 1 && pglRenderbufferStorageMultisample && pglBlitFramebuffer)
{
if (!framebufferobject.msaa_fboobj)
pglGenFramebuffers(1, &framebufferobject.msaa_fboobj);
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.msaa_fboobj);
// Generate the multisampled color renderbuffer
if (!framebufferobject.msaa_rboobj)
{
pglGenRenderbuffers(1, &framebufferobject.msaa_rboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.msaa_rboobj);
pglRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaasamples, GL_RGBA8, screen_width, screen_height);
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_rboobj);
}
// Generate the multisampled depth/stencil renderbuffer
if (!framebufferobject.msaa_depthrboobj)
{
pglGenRenderbuffers(1, &framebufferobject.msaa_depthrboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
if (supportFBO == FBO_ARB)
{
pglRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaasamples, GL_DEPTH24_STENCIL8, screen_width, screen_height);
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
}
else if (supportFBO == FBO_EXT)
{
pglRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaasamples, GL_DEPTH_STENCIL_EXT, screen_width, screen_height);
// attach a renderbuffer to depth attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
// attach a renderbuffer to stencil attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
}
}
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT)
{
framebufferobject.msaa = true;
GL_ClearBuffer(true, true, true, NULL);
GL_DBG_Printf("\nGL_FBO_Generate: Multisampled framebuffer created with %d samples\n", msaasamples);
}
else
{
GL_MSG_Warning("GL_FBO_Generate: Failed to create multisampled Framebuffer Object, falling back to no MSAA");
if (framebufferobject.msaa_rboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_rboobj);
if (framebufferobject.msaa_depthrboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_depthrboobj);
framebufferobject.msaa_rboobj = 0;
framebufferobject.msaa_depthrboobj = 0;
}
}
// Unbind the framebuffer
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
@@ -3335,11 +3506,13 @@ static void GL_FBO_Generate(void)
void GL_FBO_BindMainFrameBuffer(void)
{
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (supportFBO == FBO_NONE)
return;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
framebufferobject.bound = false;
}
void GL_FBO_Enable(void)
@@ -3353,13 +3526,23 @@ void GL_FBO_Enable(void)
if (!framebufferobject.init)
return;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
if (framebufferobject.msaa)
{
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.msaa_fboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.msaa_rboobj);
}
else
{
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
}
framebufferobject.bound = true;
}
void GL_FBO_Disable(void)
{
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (supportFBO == FBO_NONE)
return;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
@@ -3370,7 +3553,14 @@ void GL_FBO_Disable(void)
pglDeleteFramebuffers(1, &framebufferobject.fboobj);
framebufferobject.fboobj = 0;
if (framebufferobject.msaa_fboobj)
pglDeleteFramebuffers(1, &framebufferobject.msaa_fboobj);
framebufferobject.msaa_fboobj = 0;
GL_FBO_DeleteAttachments();
framebufferobject.msaa = false;
framebufferobject.bound = false;
}
#endif
@@ -3722,10 +3912,19 @@ void GL_MakeScreenTexture(int tex)
{
boolean firstTime;
static GLint lastfiltermode[NUMSCREENTEXTURES] = {-1, -1, -1, -1, -1};
#ifdef USE_FBO_OGL
const boolean msaa_fbo = (framebufferobject.bound && framebufferobject.msaa);
#endif
if (!gl_enable_screen_textures)
return;
#ifdef USE_FBO_OGL
// cant read from the msaa fbo, so gotta blit it first into either the single sample fbo or the screen framebuffer....
if (msaa_fbo)
GL_FBO_Resolve(GL_COLOR_BUFFER_BIT);
#endif
firstTime = (screenTextures[tex] == 0);
// Create screen texture
@@ -3759,6 +3958,11 @@ void GL_MakeScreenTexture(int tex)
}
tex_downloaded = screenTextures[tex];
#ifdef USE_FBO_OGL
if (msaa_fbo)
GL_FBO_Enable();
#endif
}
void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height)
+10
View File
@@ -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
View File
File diff suppressed because it is too large. Load diff
+422 -847
View File
File diff suppressed because it is too large. Load diff
+137
View File
@@ -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);
}
}
+114
View File
@@ -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 -2
View File
@@ -1004,7 +1004,7 @@ static menuitem_t OP_ExpOptionsMenu[] =
#ifdef HWRENDER
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 95},
#ifdef USE_FBO_OGL
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 100},
{IT_STRING | IT_CVAR, NULL, "FBO support", &cv_glframebuffer, 100},
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 110},
{IT_DISABLED, NULL, "", NULL, 120}, // dummy text
#else
@@ -1030,7 +1030,7 @@ static const char* OP_ExpTooltips[] =
#ifdef HWRENDER
"Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!",
#ifdef USE_FBO_OGL
"Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.",
"Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nThis can be set to automatically enable if the game resolution\nis higher than the current Display Resolution\nor enabled at all times.\nThis may improve performance in some cases.\nRequires a GPU with atleast OpenGL 2.1 support.",
#endif
"Change the bit depth of the Lookup Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.",
#endif
+3
View File
@@ -504,6 +504,9 @@ typedef struct subsector_s
void *splats; // floorsplat_t list
#endif
size_t validcount;
#ifdef HWRENDER
boolean hashorizon; // not really needed for software, this stuff works differently there
#endif
} subsector_t;
// Sector list node showing all sectors an object appears in.
+3 -3
View File
@@ -1312,11 +1312,11 @@ void I_CheckDownSampleState(boolean forcerefresh)
// state changed or fbo was toggled
if (vid_downsampling != newdownsamplestate || forcerefresh)
{
//printf("downsample changed from %d to %d\n", vid_downsampling, curdownsamplestate);
//printf("downsample changed from %d to %d\n", vid_downsampling, newdownsamplestate);
// needs to be reset before refreshing the gl surface!
vid_downsampling = newdownsamplestate;
OglSdlSurface(vid.width, vid.height);
}
vid_downsampling = newdownsamplestate;
}
#endif
+1 -1
View File
@@ -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 && (cv_glscreentextures.value == 2) && (cv_glframebuffer.value == 2 || I_IsDownsampling()));
}
#endif