- all non-shader related GL calls are gone from the main code base.

This commit is contained in:
Christoph Oelckers 2019-10-04 21:13:04 +02:00
parent f992aebf33
commit ae1e090716
20 changed files with 160 additions and 169 deletions

View file

@ -3450,17 +3450,20 @@ RORHACK:
{
if (videoGetRenderMode() == REND_POLYMOST && gDeliriumBlur)
{
// todo: Implement using modern techniques instead of relying on deprecated old stuff that isn't well supported anymore.
/* names broken up so that searching for GL keywords won't find them anymore
if (!bDeliriumOld)
{
glAccum(GL_LOAD, 1.f);
g lAccum(GL_LOAD, 1.f);
}
else
{
const float fBlur = pow(1.f/3.f, 30.f/g_frameRate);
glAccum(GL_MULT, fBlur);
glAccum(GL_ACCUM, 1.f-fBlur);
glAccum(GL_RETURN, 1.f);
g lAccum(GL _MULT, fBlur);
g lAccum(GL _ACCUM, 1.f-fBlur);
g lAccum(GL _RETURN, 1.f);
}
*/
}
}
#endif

View file

@ -78,20 +78,7 @@ extern float g_videoGamma, g_videoContrast, g_videoBrightness;
extern int32_t (*baselayer_osdcmd_vidmode_func)(osdcmdptr_t parm);
extern int osdcmd_glinfo(osdcmdptr_t parm);
struct glinfo_t {
const char *vendor;
const char *renderer;
const char *version;
const char *extensions;
float maxanisotropy;
char debugoutput;
char bufferstorage;
char sync;
char dumped;
};
extern struct glinfo_t glinfo;
#endif
vec2_t CONSTEXPR const g_defaultVideoModes []
@ -231,6 +218,9 @@ void joySetDeadZone(int32_t axis, uint16_t dead, uint16_t satur);
void joyGetDeadZone(int32_t axis, uint16_t *dead, uint16_t *satur);
extern int32_t inputchecked;
void getScreen(uint8_t* imgBuf);
int32_t wm_msgbox(const char *name, const char *fmt, ...) ATTRIBUTE((format(printf,2,3)));
int32_t wm_ynbox(const char *name, const char *fmt, ...) ATTRIBUTE((format(printf,2,3)));
void wm_setapptitle(const char *name);

View file

@ -50,7 +50,7 @@ static void drawlinegl(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t
if (y1 > wy2) x1 += scale(wy2-y1, dx, dy), y1 = wy2;
}
glViewport(0, 0, xdim, ydim);
GLInterface.SetViewport(0, 0, xdim, ydim);
VSMatrix proj(0);
proj.ortho(0, xdim, ydim, 0, -1, 1);
GLInterface.SetMatrix(Matrix_Projection, &proj);
@ -115,7 +115,7 @@ void polymostSet2dView(void)
#ifdef USE_OPENGL
if (videoGetRenderMode() < REND_POLYMOST) return;
glViewport(0, 0, xdim, ydim);
GLInterface.SetViewport(0, 0, xdim, ydim);
VSMatrix proj(0);
proj.ortho(0, xdim, ydim, 0, -1, 1);

View file

@ -412,7 +412,7 @@ void animvpx_setup_glstate(int32_t animvpx_flags)
////////// GL STATE //////////
//Force fullscreen (glox1=-1 forces it to restore afterwards)
glViewport(0,0,xdim,ydim); glox1 = -1;
GLInterface.SetViewport(0,0,xdim,ydim); glox1 = -1;
VSMatrix identity(0);
GLInterface.SetMatrix(Matrix_ModelView, &identity);
@ -439,8 +439,7 @@ void animvpx_setup_glstate(int32_t animvpx_flags)
texuploaded = 0;
////////////////////
glClearColor(0.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
GLInterface.ClearScreen(0, 0, 0, true);
}
void animvpx_restore_glstate(void)

View file

@ -8,6 +8,7 @@
#include "a.h"
#include "polymost.h"
#include "cache1d.h"
#include "../../glbackend/glbackend.h"
// video
#ifdef _WIN32
@ -304,21 +305,8 @@ int osdcmd_glinfo(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
if (bpp == 8)
{
initprintf("glinfo: not in OpenGL mode!\n");
return OSDCMD_OK;
}
initprintf("OpenGL information\n %s %s %s\n",
glinfo.vendor, glinfo.renderer, glinfo.version);
if (!glinfo.dumped)
return OSDCMD_OK;
char const *s[] = { "supported", "not supported" };
initprintf(" Extensions:\n%s", glinfo.extensions);
GLInterface.glinfo.vendor, GLInterface.glinfo.renderer, GLInterface.glinfo.version);
return OSDCMD_OK;
}

View file

@ -249,29 +249,36 @@ int32_t FindDistance3D(int32_t x, int32_t y, int32_t z)
// Clear OSD background
void COMMON_doclearbackground(int numcols, int height)
{
UNREFERENCED_PARAMETER(numcols);
polymost_setFogEnabled(false);
polymost_useColorOnly(true);
# ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST && in3dmode())
{
polymost_setFogEnabled(false);
polymost_useColorOnly(true);
polymostSet2dView();
polymostSet2dView();
GLInterface.SetColor(0.f, 0.f, 0.f, 0.67f);
GLInterface.EnableBlend(true);
glRecti(0, 0, xdim, height);
GLInterface.SetColor(0.f, 0.f, 0.f, 1.f);
glRecti(0, height-4, xdim, height);
VSMatrix identity(0);
GLInterface.SetMatrix(Matrix_ModelView, &identity);
auto vert = GLInterface.AllocVertices(8);
auto vt = vert.second;
polymost_useColorOnly(false);
polymost_setFogEnabled(true);
auto h4 = height - 4;
return;
}
# endif
GLInterface.EnableBlend(true);
CLEARLINES2D(0, min(ydim, height), editorcolors[16]);
vt[0].Set(0, 0); //top-left
vt[1].Set(0, h4); //bottom-left
vt[2].Set(xdim, 0); //top-right
vt[3].Set(xdim, h4); //bottom-right
GLInterface.SetColor(0.f, 0.f, 0.f, 0.67f);
GLInterface.Draw(DT_TRIANGLE_STRIP, vert.first, 4);
vt[0].Set(0, h4); //top-left
vt[1].Set(0, height); //bottom-left
vt[2].Set(xdim, h4); //top-right
vt[3].Set(xdim, height); //bottom-right
GLInterface.SetColor(0.f, 0.f, 0.f, 1.f);
GLInterface.Draw(DT_TRIANGLE_STRIP, vert.first+4, 4);
polymost_useColorOnly(false);
polymost_setFogEnabled(true);
}
void COMMON_clearbackground(int numcols, int numrows)

View file

@ -1002,8 +1002,8 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t,int32_
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
{
glClear(GL_DEPTH_BUFFER_BIT);
yax_polymostclearzbuffer = 0;
GLInterface.ClearScreen(0, 0, 0, true);
yax_polymostclearzbuffer = 0;
}
#endif
@ -12081,11 +12081,10 @@ void videoClearViewableArea(int32_t dacol)
{
palette_t const p = paletteGetColor(dacol);
glClearColor((float)p.r * (1.f/255.f),
GLInterface.ClearScreen((float)p.r * (1.f/255.f),
(float)p.g * (1.f/255.f),
(float)p.b * (1.f/255.f),
0);
glClear(GL_COLOR_BUFFER_BIT);
false);
return;
}
#endif
@ -12119,12 +12118,11 @@ void videoClearScreen(int32_t dacol)
{
palette_t const p = paletteGetColor(dacol);
glViewport(0,0,xdim,ydim); glox1 = -1;
glClearColor((float)p.r * (1.f/255.f),
GLInterface.SetViewport(0,0,xdim,ydim); glox1 = -1;
GLInterface.ClearScreen((float)p.r * (1.f/255.f),
(float)p.g * (1.f/255.f),
(float)p.b * (1.f/255.f),
0);
glClear(GL_COLOR_BUFFER_BIT);
false);
return;
}
#endif

View file

@ -59,8 +59,6 @@ bool glsurface_initialize(vec2_t bufferResolution)
if (buffer)
glsurface_destroy();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
bufferRes = bufferResolution;
buffer = Xaligned_alloc(16, bufferRes.x * bufferRes.y);

View file

@ -1992,8 +1992,8 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
GLInterface.SetDepthFunc(Depth_LessEqual);
}
if ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0)) glFrontFace(GL_CW); else glFrontFace(GL_CCW);
GLInterface.SetCull(Cull_Back);
int winding = ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0))? Winding_CW : Winding_CCW;
GLInterface.SetCull(Cull_Back, winding);
// tinting
pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades;
@ -2022,7 +2022,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
al=alphahackarray[globalpicnum] * (1.f/255.f);
GLInterface.EnableBlend(true);
GLInterface.EnableAlphaTest(true);
glAlphaFunc(GL_GREATER,al);
GLInterface.SetAlphaThreshold(al);
}
else
{

View file

@ -49,8 +49,6 @@ static float dxb1[MAXWALLSB], dxb2[MAXWALLSB];
float shadescale = 1.0f;
int32_t shadescale_unbounded = 0;
int32_t r_polymostDebug = 0;
int32_t r_enablepolymost2 = 0;
int32_t r_pogoDebug = 0;
int32_t r_usenewshading = 4;
int32_t r_npotwallmode = 2;
@ -228,25 +226,6 @@ hitdata_t polymost_hitdata;
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...)
{
static char msg[8192];
va_list vArgs;
if (!glinfo.debugoutput ||
r_polymostDebug < severity)
{
return;
}
va_start(vArgs, format);
Bvsnprintf(msg, sizeof(msg), format, vArgs);
va_end(vArgs);
glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB,
GL_DEBUG_TYPE_OTHER_ARB,
0,
GL_DEBUG_SEVERITY_HIGH_ARB+severity-1,
-1,
msg);
}
void gltexinvalidate(int32_t dapicnum, int32_t dapalnum, int32_t dameth)
@ -296,10 +275,10 @@ void gltexapplyprops(void)
if (videoGetRenderMode() == REND_CLASSIC)
return;
if (glinfo.maxanisotropy > 1.f)
if (GLInterface.glinfo.maxanisotropy > 1.f)
{
if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy)
glanisotropy = (int32_t)glinfo.maxanisotropy;
if (glanisotropy <= 0 || glanisotropy > GLInterface.glinfo.maxanisotropy)
glanisotropy = (int32_t)GLInterface.glinfo.maxanisotropy;
}
@ -1029,21 +1008,11 @@ static void resizeglcheck(void)
if (lastglpolygonmode != r_polygonmode)
{
lastglpolygonmode = r_polygonmode;
switch (r_polygonmode)
{
default:
case 0:
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); break;
case 1:
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); break;
case 2:
glPolygonMode(GL_FRONT_AND_BACK,GL_POINT); break;
}
GLInterface.SetWireframe(r_polygonmode == 1);
}
if (r_polygonmode) //FUK
{
glClearColor(1.0,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
GLInterface.ClearScreen(1, 1, 1, true);
}
if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y) || (gloxyaspect != gxyaspect) || (gloyxscale != gyxscale) || (glohoriz2 != ghoriz2) || (glohorizcorrect != ghorizcorrect) || (glotang != gtang))
@ -1057,7 +1026,7 @@ static void resizeglcheck(void)
glox1 = (float)windowxy1.x; gloy1 = (float)windowxy1.y;
glox2 = (float)windowxy2.x; gloy2 = (float)windowxy2.y;
glViewport(windowxy1.x-(fovcorrect/2), ydim-(windowxy2.y+1),
GLInterface.SetViewport(windowxy1.x-(fovcorrect/2), ydim-(windowxy2.y+1),
ourxdimen+fovcorrect, windowxy2.y-windowxy1.y+1);
float m[4][4];
@ -2152,7 +2121,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
float const al = alphahackarray[globalpicnum] != 0 ? alphahackarray[globalpicnum] * (1.f/255.f) :
(pth->hicr && pth->hicr->alphacut >= 0.f ? pth->hicr->alphacut : 0.f);
glAlphaFunc(GL_GREATER, al);
GLInterface.SetAlphaThreshold(al);
handle_blend((method & DAMETH_MASKPROPS) > DAMETH_MASK, drawpoly_blend, (method & DAMETH_MASKPROPS) == DAMETH_TRANS2);
}
@ -5252,10 +5221,11 @@ void polymost_drawrooms()
frameoffset = frameplace + windowxy1.y*bytesperline + windowxy1.x;
#ifdef YAX_ENABLE
if (yax_polymostclearzbuffer)
if (yax_polymostclearzbuffer)
#endif
glClear(GL_DEPTH_BUFFER_BIT);
{
GLInterface.ClearDepth();
}
GLInterface.EnableBlend(false);
GLInterface.EnableAlphaTest(false);
GLInterface.EnableDepthTest(true);
@ -6653,12 +6623,12 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
if ((dastat&(RS_AUTO|RS_NOCLIP)) == RS_AUTO)
{
glViewport(windowxy1.x, ydim-(windowxy2.y+1), windowxy2.x-windowxy1.x+1, windowxy2.y-windowxy1.y+1);
GLInterface.SetViewport(windowxy1.x, ydim-(windowxy2.y+1), windowxy2.x-windowxy1.x+1, windowxy2.y-windowxy1.y+1);
glox1 = -1;
}
else
{
glViewport(0, 0, xdim, ydim);
GLInterface.SetViewport(0, 0, xdim, ydim);
glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
}
@ -6706,8 +6676,8 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
if (onumframes != numframes)
{
onumframes = numframes;
glClear(GL_DEPTH_BUFFER_BIT);
}
GLInterface.ClearDepth();
}
}
spriteext[tspr.owner].alpha = daalpha * (1.0f / 255.0f);
@ -6746,7 +6716,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
polymost_outputGLDebugMessage(3, "polymost_dorotatesprite(sx:%d, sy:%d, z:%d, a:%hd, picnum:%hd, dashade:%hhd, dapalnum:%hhu, dastat:%d, daalpha:%hhu, dablend:%hhu, cx1:%d, cy1:%d, cx2:%d, cy2:%d, uniqid:%d)",
sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, cx1, cy1, cx2, cy2, uniqid);
glViewport(0,0,xdim,ydim); glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
GLInterface.SetViewport(0,0,xdim,ydim); glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
auto oldproj = GLInterface.GetMatrix(Matrix_Projection);
auto oldmv = GLInterface.GetMatrix(Matrix_ModelView);
@ -7295,8 +7265,8 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
// XXX: Don't fogify the OSD text in Mapster32 with r_usenewshading >= 2.
polymost_setFogEnabled(false);
// We want to have readable text in wireframe mode, too:
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
lastglpolygonmode = 0;
GLInterface.SetWireframe(false);
lastglpolygonmode = 0;
if (backcol >= 0)
{
@ -7481,7 +7451,6 @@ void polymost_initosdfuncs(void)
static osdcvardata_t cvars_polymost[] =
{
{ "r_polymostDebug","Set the verbosity of Polymost GL debug messages",(void *) &r_polymostDebug, CVAR_INT, 0, 3 },
#ifdef USE_GLEXT
{ "r_detailmapping","enable/disable detail mapping",(void *) &r_detailmapping, CVAR_BOOL, 0, 1 },
{ "r_glowmapping","enable/disable glow mapping",(void *) &r_glowmapping, CVAR_BOOL, 0, 1 },

View file

@ -5,6 +5,7 @@
#include "pngwrite.h"
#include "vfs.h"
#include "../../glbackend/glbackend.h"
//
// screencapture
@ -54,6 +55,11 @@ static void screencapture_end(char *fn, buildvfs_FILE * filptr)
# define HICOLOR 0
# endif
void getScreen(uint8_t* imgBuf)
{
GLInterface.ReadPixels(xdim, ydim, imgBuf);
}
int videoCaptureScreen(const char *filename, char inverseit)
{
char *fn = Xstrdup(filename);
@ -72,7 +78,7 @@ int videoCaptureScreen(const char *filename, char inverseit)
#ifdef USE_OPENGL
if (HICOLOR)
{
glReadPixels(0, 0, xdim, ydim, GL_RGB, GL_UNSIGNED_BYTE, imgBuf);
getScreen(imgBuf);
int const bytesPerLine = xdim * 3;
if (inverseit)
@ -200,7 +206,7 @@ int videoCaptureScreenTGA(const char *filename, char inverseit)
int const size = xdim * ydim * 3;
uint8_t *inversebuf = (uint8_t *) Xmalloc(size);
glReadPixels(0, 0, xdim, ydim, GL_RGB, GL_UNSIGNED_BYTE, inversebuf);
getScreen(inversebuf);
for (i = 0; i < size; i += 3)
swapchar(&inversebuf[i], &inversebuf[i + 2]);

View file

@ -1323,39 +1323,6 @@ void sdlayer_setvideomode_opengl(void)
glsurface_destroy();
polymost_glreset();
glinfo.vendor = (const char *) glGetString(GL_VENDOR);
glinfo.renderer = (const char *) glGetString(GL_RENDERER);
glinfo.version = (const char *) glGetString(GL_VERSION);
glinfo.extensions = (const char *) glGetString(GL_EXTENSIONS);
// process the extensions string and flag stuff we recognize
glinfo.debugoutput = !!Bstrstr(glinfo.extensions, "GL_ARB_debug_output");
glinfo.bufferstorage = !!Bstrstr(glinfo.extensions, "GL_ARB_buffer_storage");
glinfo.sync = !!Bstrstr(glinfo.extensions, "GL_ARB_sync");
if (Bstrstr(glinfo.extensions, "WGL_3DFX_gamma_control"))
{
static int32_t warnonce;
// 3dfx cards have issues with fog
nofog = 1;
if (!(warnonce & 1))
initprintf("3dfx card detected: OpenGL fog disabled\n");
warnonce |= 1;
}
// if (Bstrstr(glinfo.extensions, "GL_EXT_texture_filter_anisotropic"))
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy);
if (!glinfo.dumped)
{
int32_t oldbpp = bpp;
bpp = 32;
osdcmd_glinfo(NULL);
glinfo.dumped = 1;
bpp = oldbpp;
}
GLInterface.Deinit();
GLInterface.Init();
GLInterface.InitGLState(r_usenewshading, glmultisample);

View file

@ -13,7 +13,6 @@
#include "vfs.h"
#define CLEAR_GL_ERRORS() while(glGetError() != GL_NO_ERROR) { }
#define TEXCACHE_FREEBUFS() { Xfree(pic), Xfree(packbuf), Xfree(midbuf); }
globaltexcache texcache;

View file

@ -1085,12 +1085,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
}
if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0))
glFrontFace(GL_CW);
else
glFrontFace(GL_CCW);
GLInterface.SetCull(Cull_Back);
int winding = ((grhalfxdown10x >= 0) ^ ((globalorientation & 8) != 0) ^ ((globalorientation & 4) != 0)) ? Winding_CW : Winding_CCW;
GLInterface.SetCull(Cull_Back, winding);
float pc[4];

View file

@ -713,7 +713,6 @@ static void G_ClearGotMirror()
static void G_ReadGLFrame(void)
{
// Save OpenGL screenshot with Duke3D palette
// NOTE: maybe need to move this to the engine...
palette_t *const frame = (palette_t *)Xcalloc(xdim * ydim, sizeof(palette_t));
char *const pic = (char *) waloff[TILE_SAVESHOT];
@ -731,8 +730,8 @@ static void G_ReadGLFrame(void)
}
videoBeginDrawing();
glReadPixels(0, 0, xdim, ydim, GL_RGBA, GL_UNSIGNED_BYTE, frame);
videoEndDrawing();
getScreen((uint8_t*)frame);
videoEndDrawing();
for (y = 0; y < 200; y++)
{

View file

@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "osdcmds.h"
#include "savegame.h"
#include "xxhash.h"
#include "../../glbackend/glbackend.h"
BEGIN_DUKE_NS
@ -2041,7 +2042,7 @@ static void Menu_Pre(MenuID_t cm)
for (i = (int32_t) ARRAY_SIZE(MEOSV_DISPLAYSETUP_ANISOTROPY) - 1; i >= 0; --i)
{
if (MEOSV_DISPLAYSETUP_ANISOTROPY[i] <= glinfo.maxanisotropy)
if (MEOSV_DISPLAYSETUP_ANISOTROPY[i] <= GLInterface.glinfo.maxanisotropy)
{
MEOS_DISPLAYSETUP_ANISOTROPY.numOptions = i + 1;
break;

View file

@ -2,6 +2,7 @@
#include "glad/glad.h"
#include "gl_samplers.h"
#include "baselayer.h"
GLInstance GLInterface;
@ -12,12 +13,24 @@ void GLInstance::Init()
mSamplers = new FSamplerManager;
memset(LastBoundTextures, 0, sizeof(LastBoundTextures));
}
glinfo.vendor = (const char*)glGetString(GL_VENDOR);
glinfo.renderer = (const char*)glGetString(GL_RENDERER);
glinfo.version = (const char*)glGetString(GL_VERSION);
glinfo.extensions = (const char*)glGetString(GL_EXTENSIONS);
glinfo.bufferstorage = !!strstr(glinfo.extensions, "GL_ARB_buffer_storage");
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy);
if (!glinfo.dumped)
{
osdcmd_glinfo(NULL);
glinfo.dumped = 1;
}
}
void GLInstance::InitGLState(int fogmode, int multisample)
{
glShadeModel(GL_SMOOTH); // GL_FLAT
glClearColor(0, 0, 0, 1.0); // Black Background
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDisable(GL_DITHER);
glEnable(GL_TEXTURE_2D);
@ -178,7 +191,7 @@ void GLInstance::DisableStencil()
glDisable(GL_STENCIL_TEST);
}
void GLInstance::SetCull(int type)
void GLInstance::SetCull(int type, int winding)
{
if (type == Cull_None)
{
@ -186,11 +199,13 @@ void GLInstance::SetCull(int type)
}
else if (type == Cull_Front)
{
glFrontFace(winding == Winding_CW ? GL_CW : GL_CCW);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
}
else if (type == Cull_Back)
{
glFrontFace(winding == Winding_CW ? GL_CW : GL_CCW);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
}
@ -245,3 +260,34 @@ void GLInstance::SetBlendOp(int op)
{
glBlendEquation(renderops[op]);
}
void GLInstance::ClearScreen(float r, float g, float b, bool depth)
{
glClearColor(r, g, b, 1.f);
glClear(depth ? GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT : GL_COLOR_BUFFER_BIT);
}
void GLInstance::ClearDepth()
{
glClear(GL_DEPTH_BUFFER_BIT);
}
void GLInstance::SetAlphaThreshold(float al)
{
glAlphaFunc(GL_GREATER, al);
}
void GLInstance::SetViewport(int x, int y, int w, int h)
{
glViewport(x, y, w, h);
}
void GLInstance::SetWireframe(bool on)
{
glPolygonMode(GL_FRONT_AND_BACK,on? GL_LINE : GL_FILL);
}
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
{
glReadPixels(0, 0, xdim, ydim, GL_RGB, GL_UNSIGNED_BYTE, buffer);
}

View file

@ -9,6 +9,17 @@
class FSamplerManager;
struct glinfo_t {
const char* vendor;
const char* renderer;
const char* version;
const char* extensions;
float maxanisotropy;
char bufferstorage;
char dumped;
};
struct BaseVertex
{
float x, y, z;
@ -97,6 +108,12 @@ enum ERenderOp
STYLEOP_Sub, // Subtract source from destination
STYLEOP_RevSub, // Subtract destination from source
};
enum EWinding
{
Winding_CCW,
Winding_CW
};
class GLInstance
{
enum
@ -114,6 +131,7 @@ class GLInstance
public:
glinfo_t glinfo;
FSamplerManager *mSamplers;
void Init();
@ -147,7 +165,7 @@ public:
{
SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
}
void SetCull(int type);
void SetCull(int type, int winding = Winding_CCW);
void EnableStencilWrite(int value);
void EnableStencilTest(int value);
@ -165,6 +183,13 @@ public:
void SetDepthMask(bool on);
void SetBlendFunc(int src, int dst);
void SetBlendOp(int op);
void ClearScreen(float r, float g, float b, bool depth);
void ClearDepth();
void SetViewport(int x, int y, int w, int h);
void SetAlphaThreshold(float al);
void SetWireframe(bool on);
void ReadPixels(int w, int h, uint8_t* buffer);
};
extern GLInstance GLInterface;

View file

@ -915,7 +915,6 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz
static void G_ReadGLFrame(void)
{
// Save OpenGL screenshot with Duke3D palette
// NOTE: maybe need to move this to the engine...
palette_t *const frame = (palette_t *)Xcalloc(xdim * ydim, sizeof(palette_t));
char *const pic = (char *) waloff[TILE_SAVESHOT];
@ -933,7 +932,7 @@ static void G_ReadGLFrame(void)
}
videoBeginDrawing();
glReadPixels(0, 0, xdim, ydim, GL_RGBA, GL_UNSIGNED_BYTE, frame);
getScreen((uint8_t*)frame);
videoEndDrawing();
for (y = 0; y < 200; y++)

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "input.h"
#include "menus.h"
#include "cheats.h"
#include "../../glbackend/glbackend.h"
BEGIN_RR_NS
@ -2012,7 +2013,7 @@ static void Menu_Pre(MenuID_t cm)
for (i = (int32_t) ARRAY_SIZE(MEOSV_DISPLAYSETUP_ANISOTROPY) - 1; i >= 0; --i)
{
if (MEOSV_DISPLAYSETUP_ANISOTROPY[i] <= glinfo.maxanisotropy)
if (MEOSV_DISPLAYSETUP_ANISOTROPY[i] <= GLInterface.glinfo.maxanisotropy)
{
MEOS_DISPLAYSETUP_ANISOTROPY.numOptions = i + 1;
break;