Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
148bd1ab4d |
No files matched your search
@@ -292,7 +292,6 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
lua_script.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
lua_udatalib.c
|
||||
lua_glib.c
|
||||
)
|
||||
set(SRB2_LUA_HEADERS
|
||||
@@ -302,7 +301,6 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||
lua_profile.h
|
||||
lua_libs.h
|
||||
lua_script.h
|
||||
lua_udatalib.h
|
||||
lua_glib.h
|
||||
)
|
||||
|
||||
|
||||
@@ -97,6 +97,5 @@ lua_playerlib.c
|
||||
lua_script.c
|
||||
lua_skinlib.c
|
||||
lua_thinkerlib.c
|
||||
lua_udatalib.c
|
||||
lua_glib.c
|
||||
lua_profile.cpp
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "../d_main.h"
|
||||
#include "../doomstat.h"
|
||||
#include "../doomdef.h"
|
||||
|
||||
@@ -205,8 +204,7 @@ 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
|
||||
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};
|
||||
consvar_t cv_glframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, 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};
|
||||
@@ -269,8 +267,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
|
||||
if (loaded_config) // dont do this crap on startup, this is handled elsewhere
|
||||
I_CheckDownSampleState(true);
|
||||
|
||||
I_CheckDownSampleState(true);
|
||||
M_UpdateOGLMenu();
|
||||
intermissionbginit = false;
|
||||
}
|
||||
|
||||
@@ -141,56 +141,26 @@ enum
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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
|
||||
GLuint fboobj; // actual Framebuffer Object
|
||||
GLuint rboobj; // Renderbuffer Object
|
||||
GLuint tex; // Framebuffer texture
|
||||
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
|
||||
#ifndef GL_DEPTH_COMPONENT
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
#endif
|
||||
#ifndef GL_DEPTH_ATTACHMENT_EXT
|
||||
#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
|
||||
#endif
|
||||
// this should still give a simple depth only rbo
|
||||
#ifndef GL_DEPTH24_STENCIL8
|
||||
#define GL_DEPTH24_STENCIL8 0x88F0
|
||||
GL_DEPTH24_STENCIL8 GL_DEPTH_COMPONENT_EXT
|
||||
#endif
|
||||
#ifndef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
#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
|
||||
GL_DEPTH_STENCIL_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||
#endif
|
||||
|
||||
static void GL_FBO_DeleteAttachments(void);
|
||||
static void GL_FBO_Resolve(GLbitfield mask);
|
||||
#endif
|
||||
|
||||
// needed for glportals
|
||||
@@ -508,10 +478,6 @@ 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);
|
||||
@@ -933,17 +899,6 @@ 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...
|
||||
@@ -980,21 +935,6 @@ 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");
|
||||
}
|
||||
|
||||
@@ -1515,15 +1455,6 @@ 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
|
||||
@@ -1565,16 +1496,9 @@ 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
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
@@ -3318,7 +3242,7 @@ void GL_SetTransform(FTransform *stransform)
|
||||
#ifdef USE_FBO_OGL
|
||||
static void GL_FBO_DeleteAttachments(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE)
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
|
||||
// Unbind the framebuffer
|
||||
@@ -3331,44 +3255,13 @@ 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;
|
||||
|
||||
@@ -3428,76 +3321,12 @@ 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 probably wouldnt recover and we dont want any more black screens...
|
||||
// this wouldnt recover
|
||||
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);
|
||||
|
||||
@@ -3506,13 +3335,11 @@ static void GL_FBO_Generate(void)
|
||||
|
||||
void GL_FBO_BindMainFrameBuffer(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE)
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
|
||||
|
||||
framebufferobject.bound = false;
|
||||
}
|
||||
|
||||
void GL_FBO_Enable(void)
|
||||
@@ -3526,23 +3353,13 @@ void GL_FBO_Enable(void)
|
||||
if (!framebufferobject.init)
|
||||
return;
|
||||
|
||||
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;
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
|
||||
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
|
||||
}
|
||||
|
||||
void GL_FBO_Disable(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE)
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
return;
|
||||
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
@@ -3553,14 +3370,7 @@ 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
|
||||
|
||||
@@ -3912,19 +3722,10 @@ 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
|
||||
@@ -3958,11 +3759,6 @@ 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)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#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
|
||||
@@ -256,15 +255,6 @@ 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)
|
||||
{
|
||||
|
||||
+767
-734
File diff suppressed because it is too large.
Load diff
+847
-422
File diff suppressed because it is too large.
Load diff
@@ -1,137 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
// 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
@@ -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 support", &cv_glframebuffer, 100},
|
||||
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling 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.\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.",
|
||||
"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.",
|
||||
#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
-3
@@ -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, newdownsamplestate);
|
||||
// needs to be reset before refreshing the gl surface!
|
||||
vid_downsampling = newdownsamplestate;
|
||||
//printf("downsample changed from %d to %d\n", vid_downsampling, curdownsamplestate);
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
}
|
||||
|
||||
vid_downsampling = newdownsamplestate;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ PFNglGetString pglGetString;
|
||||
#ifdef USE_FBO_OGL
|
||||
boolean UseScreenFBO(void)
|
||||
{
|
||||
return (supportFBO && cv_glframebuffer.value && (cv_glscreentextures.value == 2) && (cv_glframebuffer.value == 2 || I_IsDownsampling()));
|
||||
return (supportFBO && cv_glframebuffer.value && I_IsDownsampling() && (cv_glscreentextures.value == 2));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user