2006-04-23 06:44:19 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "osd.h"
|
|
|
|
#include "build.h"
|
|
|
|
#include "baselayer.h"
|
|
|
|
|
|
|
|
#ifdef RENDERTYPEWIN
|
|
|
|
#include "winlayer.h"
|
|
|
|
#endif
|
|
|
|
|
2008-07-02 01:32:53 +00:00
|
|
|
char scantoasc[128] =
|
|
|
|
{
|
|
|
|
0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0,
|
|
|
|
'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s',
|
|
|
|
'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v',
|
|
|
|
'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1',
|
|
|
|
'2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
};
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef USE_OPENGL
|
2007-12-12 17:42:14 +00:00
|
|
|
struct glinfo glinfo =
|
|
|
|
{
|
|
|
|
"Unknown", // vendor
|
|
|
|
"Unknown", // renderer
|
|
|
|
"0.0.0", // version
|
|
|
|
"", // extensions
|
|
|
|
|
|
|
|
1.0, // max anisotropy
|
|
|
|
0, // brga texture format
|
|
|
|
0, // clamp-to-edge support
|
|
|
|
0, // texture compression
|
|
|
|
0, // non-power-of-two textures
|
|
|
|
0, // multisampling
|
|
|
|
0, // nvidia multisampling hint
|
|
|
|
0, // ARBfp
|
|
|
|
0, // depth textures
|
|
|
|
0, // shadow comparison
|
|
|
|
0, // Frame Buffer Objects
|
|
|
|
0, // rectangle textures
|
|
|
|
0, // multitexturing
|
|
|
|
0, // env_combine
|
|
|
|
0, // Vertex Buffer Objects
|
2008-07-22 21:03:09 +00:00
|
|
|
0, // VSync support
|
2008-02-24 00:46:57 +00:00
|
|
|
0, // GL info dumped
|
2007-12-12 17:42:14 +00:00
|
|
|
};
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2008-03-22 10:23:57 +00:00
|
|
|
static void onvideomodechange(int newmode) { UNREFERENCED_PARAMETER(newmode); }
|
2006-04-23 06:44:19 +00:00
|
|
|
void (*baselayer_onvideomodechange)(int) = onvideomodechange;
|
|
|
|
|
2008-07-12 23:44:07 +00:00
|
|
|
#if defined(POLYMOST)
|
2006-04-23 06:44:19 +00:00
|
|
|
static int osdfunc_setrendermode(const osdfuncparm_t *parm)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
int m;
|
|
|
|
char *p;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
char *modestrs[] =
|
|
|
|
{
|
2008-07-09 23:25:38 +00:00
|
|
|
"classic software", "completely broken polygonal flat-shaded software",
|
2007-12-12 17:42:14 +00:00
|
|
|
"polygonal textured software", "polygonal OpenGL", "great justice"
|
|
|
|
};
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
|
|
|
m = Bstrtol(parm->parms[0], &p, 10);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-08-29 01:58:59 +00:00
|
|
|
if (m < 0 || m > 4) return OSDCMD_SHOWHELP;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
setrendermode(m);
|
2007-12-12 17:42:14 +00:00
|
|
|
OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode()]);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return OSDCMD_OK;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
2008-07-12 23:44:07 +00:00
|
|
|
#if defined(USE_OPENGL)
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef DEBUGGINGAIDS
|
|
|
|
static int osdcmd_hicsetpalettetint(const osdfuncparm_t *parm)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
int pal, cols[3], eff;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (parm->numparms != 5) return OSDCMD_SHOWHELP;
|
|
|
|
|
|
|
|
pal = Batol(parm->parms[0]);
|
|
|
|
cols[0] = Batol(parm->parms[1]);
|
|
|
|
cols[1] = Batol(parm->parms[2]);
|
|
|
|
cols[2] = Batol(parm->parms[3]);
|
|
|
|
eff = Batol(parm->parms[4]);
|
|
|
|
|
|
|
|
hicsetpalettetint(pal,cols[0],cols[1],cols[2],eff);
|
|
|
|
|
|
|
|
return OSDCMD_OK;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-24 00:46:57 +00:00
|
|
|
int osdcmd_glinfo(const osdfuncparm_t *parm)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
char *s,*t,*u,i;
|
|
|
|
|
2008-03-22 10:23:57 +00:00
|
|
|
UNREFERENCED_PARAMETER(parm);
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (bpp == 8)
|
|
|
|
{
|
2008-02-24 00:46:57 +00:00
|
|
|
initprintf("glinfo: Not in OpenGL mode.\n");
|
2006-04-24 19:04:22 +00:00
|
|
|
return OSDCMD_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-24 00:46:57 +00:00
|
|
|
initprintf("OpenGL Information:\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
" Version: %s\n"
|
|
|
|
" Vendor: %s\n"
|
2008-07-09 23:25:38 +00:00
|
|
|
" Renderer: %s\n",
|
|
|
|
glinfo.version,
|
|
|
|
glinfo.vendor,
|
|
|
|
glinfo.renderer);
|
|
|
|
|
|
|
|
if (!glinfo.dumped)
|
|
|
|
return OSDCMD_OK;
|
|
|
|
|
|
|
|
initprintf(" Maximum anisotropy: %.1f%s\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
" BGRA textures: %s\n"
|
|
|
|
" Non-x^2 textures: %s\n"
|
|
|
|
" Texure compression: %s\n"
|
|
|
|
" Clamp-to-edge: %s\n"
|
|
|
|
" Multisampling: %s\n"
|
|
|
|
" Nvidia multisample hint: %s\n"
|
2007-01-06 01:29:45 +00:00
|
|
|
" ARBfp fragment programs: %s\n"
|
|
|
|
" Depth textures: %s\n"
|
|
|
|
" Shadow textures: %s\n"
|
|
|
|
" Frame Buffer Objects: %s\n"
|
|
|
|
" Rectangle textures: %s\n"
|
2007-03-08 03:07:10 +00:00
|
|
|
" Multitexturing: %s\n"
|
|
|
|
" env_combine: %s\n"
|
|
|
|
" Vertex Buffer Objects: %s\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
" Extensions:\n",
|
|
|
|
glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)",
|
|
|
|
glinfo.bgra ? "supported": "not supported",
|
|
|
|
glinfo.texnpot ? "supported": "not supported",
|
|
|
|
glinfo.texcompr ? "supported": "not supported",
|
|
|
|
glinfo.clamptoedge ? "supported": "not supported",
|
|
|
|
glinfo.multisample ? "supported": "not supported",
|
2007-01-06 01:29:45 +00:00
|
|
|
glinfo.nvmultisamplehint ? "supported": "not supported",
|
|
|
|
glinfo.arbfp ? "supported": "not supported",
|
|
|
|
glinfo.depthtex ? "supported": "not supported",
|
|
|
|
glinfo.shadow ? "supported": "not supported",
|
|
|
|
glinfo.fbos ? "supported": "not supported",
|
2007-03-08 03:07:10 +00:00
|
|
|
glinfo.rect ? "supported": "not supported",
|
|
|
|
glinfo.multitex ? "supported": "not supported",
|
|
|
|
glinfo.envcombine ? "supported": "not supported",
|
|
|
|
glinfo.vbos ? "supported": "not supported"
|
2006-04-24 19:04:22 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
s = Bstrdup(glinfo.extensions);
|
2008-02-24 00:46:57 +00:00
|
|
|
if (!s) initprintf(glinfo.extensions);
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
i = 0; t = u = s;
|
2007-12-12 17:42:14 +00:00
|
|
|
while (*t)
|
|
|
|
{
|
|
|
|
if (*t == ' ')
|
|
|
|
{
|
|
|
|
if (i&1)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
*t = 0;
|
2008-02-24 00:46:57 +00:00
|
|
|
initprintf(" %s\n",u);
|
2006-04-24 19:04:22 +00:00
|
|
|
u = t+1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
t++;
|
|
|
|
}
|
2008-02-24 00:46:57 +00:00
|
|
|
if (i&1) initprintf(" %s\n",u);
|
2006-04-24 19:04:22 +00:00
|
|
|
Bfree(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OSDCMD_OK;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-07-12 23:44:07 +00:00
|
|
|
#endif
|
2006-04-23 06:44:19 +00:00
|
|
|
|
|
|
|
static int osdcmd_vars(const osdfuncparm_t *parm)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
int showval = (parm->numparms < 1);
|
|
|
|
|
2008-07-03 07:37:41 +00:00
|
|
|
if (!Bstrcasecmp(parm->name, "r_scrcaptureformat"))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2007-01-04 07:15:17 +00:00
|
|
|
const char *fmts[] = {"TGA", "PCX"};
|
2008-07-03 07:37:41 +00:00
|
|
|
if (showval) { OSD_Printf("r_scrcaptureformat is %s\n", fmts[captureformat]); }
|
2007-12-12 17:42:14 +00:00
|
|
|
else
|
|
|
|
{
|
2007-01-04 07:15:17 +00:00
|
|
|
int j;
|
2006-04-24 19:04:22 +00:00
|
|
|
for (j=0; j<2; j++)
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!Bstrcasecmp(parm->parms[0], fmts[j])) break;
|
2006-04-24 19:04:22 +00:00
|
|
|
if (j == 2) return OSDCMD_SHOWHELP;
|
2007-01-04 07:15:17 +00:00
|
|
|
captureformat = j;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
|
|
|
return OSDCMD_OK;
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef SUPERBUILD
|
2008-07-02 04:56:42 +00:00
|
|
|
else if (!Bstrcasecmp(parm->name, "r_novoxmips"))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-07-02 04:56:42 +00:00
|
|
|
if (showval) { OSD_Printf("r_novoxmips is %d\n", novoxmips); }
|
2006-04-24 19:04:22 +00:00
|
|
|
else { novoxmips = (atoi(parm->parms[0]) != 0); }
|
|
|
|
}
|
2008-07-02 04:56:42 +00:00
|
|
|
else if (!Bstrcasecmp(parm->name, "r_voxels"))
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2008-07-02 04:56:42 +00:00
|
|
|
if (showval) { OSD_Printf("r_voxels is %d\n", usevoxels); }
|
2006-04-24 19:04:22 +00:00
|
|
|
else { usevoxels = (atoi(parm->parms[0]) != 0); }
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
return OSDCMD_SHOWHELP;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int baselayer_init(void)
|
|
|
|
{
|
|
|
|
#ifdef POLYMOST
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_RegisterFunction("setrendermode","setrendermode <number>: sets the engine's rendering mode.\n"
|
|
|
|
"Mode numbers are:\n"
|
|
|
|
" 0 - Classic Build software\n"
|
|
|
|
" 1 - Polygonal flat-shaded software\n"
|
|
|
|
" 2 - Polygonal textured software\n"
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef USE_OPENGL
|
2006-04-24 19:04:22 +00:00
|
|
|
" 3 - Polygonal OpenGL\n"
|
2007-01-04 07:15:17 +00:00
|
|
|
// " 4 - great justice renderer\n"
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
,
|
|
|
|
osdfunc_setrendermode);
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2008-07-03 07:37:41 +00:00
|
|
|
OSD_RegisterFunction("r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars);
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef SUPERBUILD
|
2008-07-02 04:56:42 +00:00
|
|
|
OSD_RegisterFunction("r_novoxmips","novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars);
|
|
|
|
OSD_RegisterFunction("r_voxels","usevoxels: enable/disable automatic sprite->voxel rendering",osdcmd_vars);
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
#if defined(POLYMOST) && defined(USE_OPENGL)
|
|
|
|
#ifdef DEBUGGINGAIDS
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint);
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_RegisterFunction("glinfo","glinfo: shows OpenGL information about the current OpenGL mode",osdcmd_glinfo);
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|