2006-04-23 06:44:19 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "osd.h"
|
|
|
|
#include "build.h"
|
|
|
|
#include "baselayer.h"
|
|
|
|
|
2012-11-25 04:26:37 +00:00
|
|
|
#include "renderlayer.h"
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2012-12-14 19:28:17 +00:00
|
|
|
#include "a.h"
|
2009-08-09 05:32:17 +00:00
|
|
|
#include "polymost.h"
|
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
// input
|
|
|
|
char inputdevices=0;
|
2014-10-29 17:05:15 +00:00
|
|
|
char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ];
|
|
|
|
uint8_t keyfifoplc, keyfifoend, keyasciififoplc, keyasciififoend;
|
2014-12-09 23:56:54 +00:00
|
|
|
char keyremap[KEYSTATUSSIZ];
|
|
|
|
int32_t keyremapinit=0;
|
2014-05-17 12:36:40 +00:00
|
|
|
char key_names[NUMKEYS][24];
|
2014-12-27 18:36:43 +00:00
|
|
|
int32_t mousex=0,mousey=0,mouseb=0;
|
|
|
|
vec2_t mouseabs;
|
|
|
|
uint8_t mousepressstate;
|
2014-11-17 07:39:12 +00:00
|
|
|
uint8_t moustat = 0, mousegrab = 0, mouseinwindow = 1, AppMouseGrab = 1;
|
2014-12-27 18:36:43 +00:00
|
|
|
|
|
|
|
int32_t mousepressstateadvance(void)
|
|
|
|
{
|
|
|
|
if (mousepressstate == Mouse_Pressed)
|
|
|
|
{
|
|
|
|
mousepressstate = Mouse_Held;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (mousepressstate == Mouse_Released)
|
|
|
|
{
|
|
|
|
mousepressstate = Mouse_Idle;
|
|
|
|
return 1;
|
|
|
|
}
|
2015-01-15 06:45:14 +00:00
|
|
|
else if (mousepressstate == Mouse_Held)
|
|
|
|
return 1;
|
2014-12-27 18:36:43 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL;
|
|
|
|
char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0;
|
|
|
|
int32_t joyaxespresent=0;
|
|
|
|
|
|
|
|
void(*keypresscallback)(int32_t,int32_t) = 0;
|
|
|
|
void(*mousepresscallback)(int32_t,int32_t) = 0;
|
|
|
|
void(*joypresscallback)(int32_t,int32_t) = 0;
|
|
|
|
|
2010-07-03 08:53:57 +00:00
|
|
|
extern int16_t brightness;
|
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
//
|
|
|
|
// set{key|mouse|joy}presscallback() -- sets a callback which gets notified when keys are pressed
|
|
|
|
//
|
|
|
|
void setkeypresscallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
|
|
|
|
void setmousepresscallback(void (*callback)(int32_t, int32_t)) { mousepresscallback = callback; }
|
|
|
|
void setjoypresscallback(void (*callback)(int32_t, int32_t)) { joypresscallback = callback; }
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2011-03-04 07:04:42 +00:00
|
|
|
int32_t defaultres[][2] =
|
|
|
|
{
|
2013-05-20 19:31:18 +00:00
|
|
|
{1920, 1440}, {1920, 1200}, {1920, 1080}, {1680, 1050}, {1600, 1200}, {1600, 900}, {1366, 768}, {1280, 1024},
|
2011-03-04 10:09:12 +00:00
|
|
|
{1280, 960}, {1152, 864}, {1024, 768}, {1024, 600}, {800, 600}, {640, 480}, {640, 400},
|
|
|
|
{512, 384}, {480, 360}, {400, 300}, {320, 240}, {320, 200}, {0, 0}
|
2011-03-04 07:04:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-27 10:30:25 +00:00
|
|
|
int32_t GetKey(int32_t key)
|
|
|
|
{
|
2014-12-09 23:56:54 +00:00
|
|
|
return keystatus[keyremap[key]];
|
2014-01-27 10:30:25 +00:00
|
|
|
}
|
2014-11-22 12:33:47 +00:00
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
void SetKey(int32_t key, int32_t state)
|
|
|
|
{
|
2014-12-09 23:56:54 +00:00
|
|
|
keystatus[keyremap[key]] = state;
|
2010-05-25 10:56:00 +00:00
|
|
|
|
2011-01-16 02:50:27 +00:00
|
|
|
if (state)
|
2010-05-25 10:56:00 +00:00
|
|
|
{
|
2014-12-09 23:56:54 +00:00
|
|
|
keyfifo[keyfifoend] = keyremap[key];
|
2010-05-25 10:56:00 +00:00
|
|
|
keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state;
|
|
|
|
keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// bgetchar, bflushchars -- character-based input functions
|
|
|
|
//
|
|
|
|
char bgetchar(void)
|
|
|
|
{
|
|
|
|
if (keyasciififoplc == keyasciififoend)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
{
|
|
|
|
char c = keyasciififo[keyasciififoplc];
|
|
|
|
keyasciififoplc = ((keyasciififoplc+1)&(KEYFIFOSIZ-1));
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bflushchars(void)
|
|
|
|
{
|
|
|
|
Bmemset(&keyasciififo,0,sizeof(keyasciififo));
|
|
|
|
keyasciififoplc = keyasciififoend = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *getkeyname(int32_t num)
|
|
|
|
{
|
|
|
|
return ((unsigned)num >= 256) ? NULL : key_names[num];
|
|
|
|
}
|
|
|
|
|
2011-04-07 01:16:29 +00:00
|
|
|
void readmousexy(int32_t *x, int32_t *y)
|
|
|
|
{
|
|
|
|
if (!moustat || !mousegrab || !appactive) { *x = *y = 0; return; }
|
|
|
|
*x = mousex;
|
|
|
|
*y = mousey;
|
|
|
|
mousex = mousey = 0;
|
|
|
|
}
|
|
|
|
|
2014-12-27 18:36:43 +00:00
|
|
|
int32_t readmouseabsxy(vec2_t * const destination, vec2_t const * const source)
|
2012-05-01 12:38:14 +00:00
|
|
|
{
|
2014-11-17 07:39:12 +00:00
|
|
|
int32_t xwidth;
|
|
|
|
|
2015-01-12 01:54:50 +00:00
|
|
|
if (!moustat || !appactive || !mouseinwindow || (osd && osd->flags & OSD_CAPTURE))
|
2014-11-17 07:39:12 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
xwidth = max(scale(240<<16, xdim, ydim), 320<<16);
|
|
|
|
|
2014-12-27 18:36:43 +00:00
|
|
|
destination->x = scale(source->x, xwidth, xdim) - ((xwidth>>1) - (320<<15));
|
|
|
|
destination->y = scale(source->y, 200<<16, ydim);
|
2014-11-17 07:39:12 +00:00
|
|
|
|
|
|
|
return 1;
|
2012-05-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 01:16:29 +00:00
|
|
|
void readmousebstatus(int32_t *b)
|
|
|
|
{
|
2015-01-12 01:54:50 +00:00
|
|
|
if (!moustat || !appactive || !mouseinwindow || (osd && osd->flags & OSD_CAPTURE)) { *b = 0; return; }
|
2011-04-07 01:16:29 +00:00
|
|
|
*b = mouseb;
|
|
|
|
}
|
|
|
|
|
2012-06-03 16:11:22 +00:00
|
|
|
void readjoybstatus(int32_t *b)
|
|
|
|
{
|
|
|
|
if (!appactive) { *b = 0; return; }
|
|
|
|
*b = joyb;
|
|
|
|
}
|
|
|
|
|
2014-11-02 05:36:28 +00:00
|
|
|
#if defined _WIN32
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
# include <windows.h>
|
2015-03-02 07:54:24 +00:00
|
|
|
#elif defined __linux || defined EDUKE32_BSD || defined __APPLE__
|
2014-11-02 05:36:28 +00:00
|
|
|
# include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
extern intptr_t dep_begin, dep_end;
|
|
|
|
#ifdef __cplusplus
|
2014-11-26 04:39:23 +00:00
|
|
|
}
|
2014-11-02 05:36:28 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-11-02 05:44:27 +00:00
|
|
|
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
2014-11-02 05:36:28 +00:00
|
|
|
int32_t nx_unprotect(intptr_t beg, intptr_t end)
|
|
|
|
{
|
|
|
|
# if defined _WIN32
|
|
|
|
DWORD oldprot;
|
|
|
|
|
|
|
|
if (!VirtualProtect((LPVOID) beg, (SIZE_T)end - (SIZE_T)beg, PAGE_EXECUTE_READWRITE, &oldprot))
|
|
|
|
{
|
|
|
|
initprintf("VirtualProtect() error! Crashing in 3... 2... 1...\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2015-03-02 07:54:24 +00:00
|
|
|
# elif defined __linux || defined EDUKE32_BSD || defined __APPLE__
|
2014-11-02 05:36:28 +00:00
|
|
|
int32_t pagesize;
|
|
|
|
size_t dep_begin_page;
|
|
|
|
pagesize = sysconf(_SC_PAGE_SIZE);
|
|
|
|
if (pagesize == -1)
|
|
|
|
{
|
|
|
|
initprintf("Error getting system page size\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
dep_begin_page = ((size_t)beg) & ~(pagesize-1);
|
|
|
|
if (mprotect((void *) dep_begin_page, (size_t)end - dep_begin_page, PROT_READ|PROT_WRITE) < 0)
|
|
|
|
{
|
|
|
|
initprintf("Error making code writeable (errno=%d)\n", errno);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
# error "Don't know how to unprotect the self-modifying assembly on this platform!"
|
|
|
|
# endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-11-02 05:44:27 +00:00
|
|
|
#endif
|
2014-11-02 05:36:28 +00:00
|
|
|
|
|
|
|
|
2012-12-14 19:28:17 +00:00
|
|
|
// Calculate ylookup[] and call setvlinebpl()
|
|
|
|
void calc_ylookup(int32_t bpl, int32_t lastyidx)
|
|
|
|
{
|
|
|
|
int32_t i, j=0;
|
2014-11-06 23:43:47 +00:00
|
|
|
static int32_t ylookupsiz;
|
2014-11-02 05:36:28 +00:00
|
|
|
|
2012-12-14 19:28:17 +00:00
|
|
|
Bassert(lastyidx <= MAXYDIM);
|
|
|
|
|
2014-11-06 23:43:47 +00:00
|
|
|
lastyidx++;
|
|
|
|
|
2014-10-29 17:04:28 +00:00
|
|
|
if (lastyidx > ylookupsiz)
|
|
|
|
{
|
2014-11-06 23:43:47 +00:00
|
|
|
Baligned_free(ylookup);
|
2014-10-29 17:04:28 +00:00
|
|
|
|
|
|
|
ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t));
|
2014-11-02 05:36:28 +00:00
|
|
|
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
|
|
|
nx_unprotect((intptr_t)ylookup, (intptr_t)ylookup + (lastyidx * sizeof(intptr_t)));
|
|
|
|
#endif
|
2014-10-29 17:04:28 +00:00
|
|
|
ylookupsiz = lastyidx;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<=lastyidx-4; i+=4)
|
|
|
|
{
|
|
|
|
ylookup[i] = j;
|
|
|
|
ylookup[i + 1] = j + bpl;
|
|
|
|
ylookup[i + 2] = j + (bpl << 1);
|
|
|
|
ylookup[i + 3] = j + (bpl * 3);
|
|
|
|
j += (bpl << 2);
|
|
|
|
}
|
|
|
|
|
2014-11-06 23:43:47 +00:00
|
|
|
for (; i<lastyidx; i++)
|
2012-12-14 19:28:17 +00:00
|
|
|
{
|
|
|
|
ylookup[i] = j;
|
|
|
|
j += bpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
setvlinebpl(bpl);
|
|
|
|
}
|
|
|
|
|
2014-11-02 05:36:28 +00:00
|
|
|
|
|
|
|
void makeasmwriteable(void)
|
|
|
|
{
|
|
|
|
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
|
|
|
|
nx_unprotect((intptr_t)&dep_begin, (intptr_t)&dep_end);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-02-11 05:23:04 +00:00
|
|
|
extern int32_t nofog;
|
|
|
|
|
2012-12-10 18:17:44 +00:00
|
|
|
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
|
|
|
|
{
|
|
|
|
bglMatrixMode(GL_PROJECTION);
|
|
|
|
bglPushMatrix();
|
|
|
|
bglLoadIdentity();
|
|
|
|
bglMatrixMode(GL_MODELVIEW);
|
|
|
|
bglPushMatrix();
|
|
|
|
bglLoadIdentity();
|
|
|
|
|
|
|
|
bglDisable(GL_DEPTH_TEST);
|
|
|
|
bglDisable(GL_ALPHA_TEST);
|
|
|
|
bglDisable(GL_TEXTURE_2D);
|
2013-11-22 19:26:54 +00:00
|
|
|
bglDisable(GL_FOG);
|
2012-12-10 18:17:44 +00:00
|
|
|
|
2014-09-30 04:11:50 +00:00
|
|
|
bglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2012-12-10 18:17:44 +00:00
|
|
|
bglEnable(GL_BLEND);
|
|
|
|
bglColor4ub(r, g, b, f);
|
|
|
|
|
|
|
|
bglBegin(GL_TRIANGLES);
|
|
|
|
bglVertex2f(-2.5f, 1.f);
|
|
|
|
bglVertex2f(2.5f, 1.f);
|
|
|
|
bglVertex2f(.0f, -2.5f);
|
|
|
|
bglEnd();
|
|
|
|
|
|
|
|
bglPopMatrix();
|
|
|
|
bglMatrixMode(GL_PROJECTION);
|
|
|
|
bglPopMatrix();
|
|
|
|
}
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
struct glinfo_t glinfo =
|
2007-12-12 17:42:14 +00:00
|
|
|
{
|
2009-09-30 01:26:13 +00:00
|
|
|
"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
|
|
|
|
0, // VSync support
|
|
|
|
0, // Shader Model 4 support
|
|
|
|
0, // Occlusion Queries
|
|
|
|
0, // GLSL
|
2011-10-02 05:56:35 +00:00
|
|
|
0, // Debug Output
|
2015-07-25 17:23:17 +00:00
|
|
|
0, // Buffer storage
|
2009-09-30 01:26:13 +00:00
|
|
|
0, // GL info dumped
|
2007-12-12 17:42:14 +00:00
|
|
|
};
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2009-06-13 21:06:45 +00:00
|
|
|
int32_t flushlogwindow = 1;
|
2009-01-06 06:59:18 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2013-08-12 15:18:19 +00:00
|
|
|
// Used to register the game's / editor's osdcmd_vidmode() functions here.
|
|
|
|
int32_t (*baselayer_osdcmd_vidmode_func)(const osdfuncparm_t *parm);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t osdfunc_setrendermode(const osdfuncparm_t *parm)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2013-08-12 15:18:19 +00:00
|
|
|
if (parm->numparms != 1)
|
|
|
|
return OSDCMD_SHOWHELP;
|
|
|
|
|
2016-01-11 05:06:10 +00:00
|
|
|
char *p;
|
|
|
|
int32_t m = Bstrtol(parm->parms[0], &p, 10);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2013-08-12 15:18:19 +00:00
|
|
|
if (m != REND_CLASSIC && m != REND_POLYMOST && m != REND_POLYMER)
|
|
|
|
return OSDCMD_SHOWHELP;
|
|
|
|
|
|
|
|
if ((m==REND_CLASSIC) != (bpp==8) && baselayer_osdcmd_vidmode_func)
|
|
|
|
{
|
|
|
|
// Mismatch between video mode and requested renderer, do auto switch.
|
|
|
|
osdfuncparm_t parm;
|
|
|
|
char arg[4];
|
|
|
|
|
|
|
|
const char *ptrptr[1];
|
|
|
|
ptrptr[0] = arg;
|
|
|
|
|
|
|
|
Bmemset(&parm, 0, sizeof(parm));
|
|
|
|
|
|
|
|
if (m==REND_CLASSIC)
|
|
|
|
Bmemcpy(&arg, "8", 2);
|
|
|
|
else
|
|
|
|
Bmemcpy(&arg, "32", 3);
|
|
|
|
|
|
|
|
// CAUTION: we assume that the osdcmd_vidmode function doesn't use any
|
|
|
|
// other member!
|
|
|
|
parm.numparms = 1;
|
|
|
|
parm.parms = ptrptr;
|
|
|
|
|
|
|
|
baselayer_osdcmd_vidmode_func(&parm);
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
setrendermode(m);
|
2012-12-30 20:34:55 +00:00
|
|
|
|
2016-01-11 05:06:10 +00:00
|
|
|
char const *renderer;
|
|
|
|
|
2013-08-12 15:18:19 +00:00
|
|
|
switch (getrendermode())
|
2012-12-30 20:34:55 +00:00
|
|
|
{
|
|
|
|
case REND_CLASSIC:
|
2016-01-11 05:06:10 +00:00
|
|
|
renderer = "classic software";
|
2012-12-30 20:34:55 +00:00
|
|
|
break;
|
|
|
|
case REND_POLYMOST:
|
2016-01-11 05:06:10 +00:00
|
|
|
renderer = "polygonal OpenGL";
|
2012-12-30 20:34:55 +00:00
|
|
|
break;
|
|
|
|
case REND_POLYMER:
|
2016-01-11 05:06:10 +00:00
|
|
|
renderer = "great justice (Polymer)";
|
2012-12-30 20:34:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-01-11 05:06:10 +00:00
|
|
|
OSD_Printf("Rendering method changed to %s\n", renderer);
|
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
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t osdcmd_hicsetpalettetint(const osdfuncparm_t *parm)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t 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
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t 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)
|
|
|
|
{
|
2015-02-11 05:23:04 +00:00
|
|
|
initprintf("glinfo: not in OpenGL mode!\n");
|
2006-04-24 19:04:22 +00:00
|
|
|
return OSDCMD_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-11 05:23:04 +00:00
|
|
|
initprintf("OpenGL information\n %s %s %s\n",
|
|
|
|
glinfo.vendor, glinfo.renderer, glinfo.version);
|
2008-07-09 23:25:38 +00:00
|
|
|
|
|
|
|
if (!glinfo.dumped)
|
|
|
|
return OSDCMD_OK;
|
|
|
|
|
|
|
|
initprintf(" Maximum anisotropy: %.1f%s\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
" BGRA textures: %s\n"
|
2009-09-30 01:26:13 +00:00
|
|
|
" Non-power-of-2 textures: %s\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
" Clamp-to-edge: %s\n"
|
2015-02-11 05:23:04 +00:00
|
|
|
" Multitexturing: %s\n"
|
|
|
|
" Frame Buffer Objects: %s\n"
|
|
|
|
" Texure compression: %s\n"
|
|
|
|
#ifndef EDUKE32_GLES
|
2006-04-24 19:04:22 +00:00
|
|
|
" Multisampling: %s\n"
|
2015-02-11 05:23:04 +00:00
|
|
|
" 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"
|
|
|
|
" Rectangle textures: %s\n"
|
2007-03-08 03:07:10 +00:00
|
|
|
" env_combine: %s\n"
|
|
|
|
" Vertex Buffer Objects: %s\n"
|
2009-02-05 08:56:59 +00:00
|
|
|
" Shader Model 4: %s\n"
|
2009-09-30 01:26:13 +00:00
|
|
|
" Occlusion queries: %s\n"
|
|
|
|
" GLSL: %s\n"
|
2011-10-02 05:56:35 +00:00
|
|
|
" Debug Output: %s\n"
|
2015-07-15 08:23:00 +00:00
|
|
|
" Buffer Storage: %s\n"
|
2015-02-11 05:23:04 +00:00
|
|
|
#endif
|
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.clamptoedge ? "supported": "not supported",
|
2015-02-11 05:23:04 +00:00
|
|
|
glinfo.multitex ? "supported": "not supported",
|
|
|
|
glinfo.fbos ? "supported": "not supported",
|
|
|
|
glinfo.texcompr ? "supported": "not supported"
|
|
|
|
#ifndef EDUKE32_GLES
|
|
|
|
,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",
|
2007-03-08 03:07:10 +00:00
|
|
|
glinfo.rect ? "supported": "not supported",
|
|
|
|
glinfo.envcombine ? "supported": "not supported",
|
2009-02-05 08:56:59 +00:00
|
|
|
glinfo.vbos ? "supported": "not supported",
|
2009-09-30 01:26:13 +00:00
|
|
|
glinfo.sm4 ? "supported": "not supported",
|
|
|
|
glinfo.occlusionqueries ? "supported": "not supported",
|
2011-10-02 05:56:35 +00:00
|
|
|
glinfo.glsl ? "supported": "not supported",
|
2015-07-15 08:23:00 +00:00
|
|
|
glinfo.debugoutput ? "supported": "not supported",
|
|
|
|
glinfo.bufferstorage ? "supported" : "not supported"
|
2015-02-11 05:23:04 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
s = Bstrdup(glinfo.extensions);
|
2010-12-19 22:47:10 +00:00
|
|
|
if (!s) initprintf("%s", 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
|
|
|
|
2010-07-03 08:53:57 +00:00
|
|
|
static int32_t osdcmd_cvar_set_baselayer(const osdfuncparm_t *parm)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2010-07-03 08:53:57 +00:00
|
|
|
int32_t r = osdcmd_cvar_set(parm);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2010-07-03 08:53:57 +00:00
|
|
|
if (r != OSDCMD_OK) return r;
|
|
|
|
|
|
|
|
if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
|
|
|
|
{
|
2011-01-27 06:35:52 +00:00
|
|
|
setbrightness(GAMMA_CALC,0,0);
|
2010-07-03 08:53:57 +00:00
|
|
|
|
|
|
|
return r;
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2010-07-03 08:53:57 +00:00
|
|
|
|
|
|
|
return r;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t baselayer_init(void)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2009-04-29 06:20:07 +00:00
|
|
|
uint32_t i;
|
2012-04-09 19:22:00 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
// on Windows, don't save the "r_screenaspect" cvar because the physical screen size is
|
|
|
|
// determined at startup
|
|
|
|
# define SCREENASPECT_CVAR_TYPE (CVAR_UINT|CVAR_NOSAVE)
|
|
|
|
#else
|
|
|
|
# define SCREENASPECT_CVAR_TYPE (CVAR_UINT)
|
|
|
|
#endif
|
2009-04-29 06:20:07 +00:00
|
|
|
cvar_t cvars_engine[] =
|
|
|
|
{
|
2013-05-17 03:43:20 +00:00
|
|
|
{ "r_usenewaspect","enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 },
|
|
|
|
{ "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",
|
2012-08-24 18:51:49 +00:00
|
|
|
(void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 },
|
2013-05-17 03:43:20 +00:00
|
|
|
{ "r_novoxmips","turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 },
|
|
|
|
{ "r_voxels","enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 },
|
Support for drawing 'island sectors' for TROR/classic (and with limited
functionality, Polymost).
The new feature can be enabled/disabled with the 'r_tror_nomaskpass' cvar.
The basic idea is that when drawing lower or upper levels, a first pass
is performed that ignores all red walls for which the TROR nextwall link
'towards' the viewer arrives at a red wall. Thus, in the worst case, there
can be up to twice as many rendering passes now (when it is discovered that
the no-mask-pass isn't different that what would be drawn with the ordinary
one, the latter is skipped, since we've already drawn all needed geometry).
Hovever, this kind of multi-pass splitting is only suitable for simple scenes,
like the upper subway in the TROR test map. In particular, multiple islands
shouldn't 'see' each other.
Two issues are worth mentioning: first, care needs to be taken for translucent
ceilings or floors, since drawing them twice isn't the same as drawing them
once. This is done for classic, but not for Polymost. Second, sprites (which
are always drawn _after_ the geometry for a given pass) are still clipped to
the geometry of the ordinary pass, resulting in their disappearance from
certain angles.
--
Additionaly, a change made it into this commit that fixes redundant collection
of sprites in TROR:classic/Polymost.
git-svn-id: https://svn.eduke32.com/eduke32@2024 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:04:14 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2013-05-17 03:43:20 +00:00
|
|
|
{ "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 },
|
Support for drawing 'island sectors' for TROR/classic (and with limited
functionality, Polymost).
The new feature can be enabled/disabled with the 'r_tror_nomaskpass' cvar.
The basic idea is that when drawing lower or upper levels, a first pass
is performed that ignores all red walls for which the TROR nextwall link
'towards' the viewer arrives at a red wall. Thus, in the worst case, there
can be up to twice as many rendering passes now (when it is discovered that
the no-mask-pass isn't different that what would be drawn with the ordinary
one, the latter is skipped, since we've already drawn all needed geometry).
Hovever, this kind of multi-pass splitting is only suitable for simple scenes,
like the upper subway in the TROR test map. In particular, multiple islands
shouldn't 'see' each other.
Two issues are worth mentioning: first, care needs to be taken for translucent
ceilings or floors, since drawing them twice isn't the same as drawing them
once. This is done for classic, but not for Polymost. Second, sprites (which
are always drawn _after_ the geometry for a given pass) are still clipped to
the geometry of the ordinary pass, resulting in their disappearance from
certain angles.
--
Additionaly, a change made it into this commit that fixes redundant collection
of sprites in TROR:classic/Polymost.
git-svn-id: https://svn.eduke32.com/eduke32@2024 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:04:14 +00:00
|
|
|
#endif
|
2014-02-11 17:55:45 +00:00
|
|
|
{ "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 },
|
2014-10-25 03:31:27 +00:00
|
|
|
{ "vid_gamma","adjusts gamma component of gamma ramp",(void *) &vid_gamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
|
|
|
|
{ "vid_contrast","adjusts contrast component of gamma ramp",(void *) &vid_contrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
|
|
|
|
{ "vid_brightness","adjusts brightness component of gamma ramp",(void *) &vid_brightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
|
2012-12-31 01:50:45 +00:00
|
|
|
#ifdef DEBUGGINGAIDS
|
2011-01-16 02:50:27 +00:00
|
|
|
{ "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 },
|
|
|
|
{ "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 },
|
2014-01-19 20:17:14 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_MASK_DRAWING
|
2014-01-24 21:39:02 +00:00
|
|
|
{ "debug_maskdrawmode", "Show mask draw orders", (void *)&g_maskDrawMode, CVAR_BOOL, 0, 1 },
|
2012-12-31 01:50:45 +00:00
|
|
|
#endif
|
2009-04-29 06:20:07 +00:00
|
|
|
};
|
|
|
|
|
2014-03-22 09:25:15 +00:00
|
|
|
for (i=0; i<ARRAY_SIZE(cvars_engine); i++)
|
2009-04-29 06:20:07 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +00:00
|
|
|
if (OSD_RegisterCvar(&cvars_engine[i]))
|
|
|
|
continue;
|
|
|
|
|
2011-04-07 01:16:29 +00:00
|
|
|
OSD_RegisterFunction(cvars_engine[i].name, cvars_engine[i].desc,
|
2011-01-16 02:50:27 +00:00
|
|
|
(cvars_engine[i].type & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set);
|
2009-04-29 06:20:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
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"
|
|
|
|
" 3 - Polygonal OpenGL\n"
|
2010-05-25 10:56:00 +00:00
|
|
|
" 4 - Great justice renderer (Polymer)\n"
|
2006-04-24 19:04:22 +00:00
|
|
|
,
|
|
|
|
osdfunc_setrendermode);
|
2015-11-02 17:07:54 +00:00
|
|
|
|
2009-12-13 01:23:44 +00:00
|
|
|
# ifdef DEBUGGINGAIDS
|
|
|
|
OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint);
|
|
|
|
# endif
|
2015-11-02 17:07:54 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
OSD_RegisterFunction("glinfo","glinfo: shows OpenGL information about the current OpenGL mode",osdcmd_glinfo);
|
2015-11-02 17:07:54 +00:00
|
|
|
|
2009-04-29 06:20:07 +00:00
|
|
|
polymost_initosdfuncs();
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2009-04-29 06:20:07 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 18:56:29 +00:00
|
|
|
void maybe_redirect_outputs(void)
|
|
|
|
{
|
|
|
|
#if !(defined __APPLE__ && defined __BIG_ENDIAN__)
|
|
|
|
char *argp;
|
|
|
|
|
|
|
|
// pipe standard outputs to files
|
|
|
|
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL)
|
|
|
|
if (!Bstrcasecmp(argp, "TRUE"))
|
|
|
|
{
|
|
|
|
FILE *fp = freopen("stdout.txt", "w", stdout);
|
|
|
|
|
|
|
|
if (!fp)
|
|
|
|
fp = fopen("stdout.txt", "w");
|
|
|
|
|
|
|
|
if (fp)
|
|
|
|
{
|
|
|
|
setvbuf(fp, 0, _IONBF, 0);
|
|
|
|
*stdout = *fp;
|
|
|
|
*stderr = *fp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|