Subversion Repositories eduke32

Rev

Rev 8065 | Rev 8147 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
99 terminx 1
#include "compat.h"
2
#include "osd.h"
3
#include "build.h"
4
#include "baselayer.h"
5
 
3221 hendricks2 6
#include "renderlayer.h"
99 terminx 7
 
3291 helixhorne 8
#include "a.h"
1488 terminx 9
#include "polymost.h"
6807 terminx 10
#include "cache1d.h"
8094 hendricks2 11
#include "communityapi.h"
1488 terminx 12
 
6827 terminx 13
// video
6826 terminx 14
#ifdef _WIN32
15
extern "C"
16
{
17
    __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 0x00000001;
18
    __declspec(dllexport) DWORD NvOptimusEnablement                = 0x00000001;
19
}
20
#endif // _WIN32
21
 
8031 terminx 22
int32_t swapcomplete=0;
8060 terminx 23
int32_t g_borderless=2;
6827 terminx 24
 
1652 terminx 25
// input
6827 terminx 26
char    inputdevices = 0;
4853 hendricks2 27
 
6827 terminx 28
char    keystatus[NUMKEYS];
29
char    g_keyFIFO[KEYFIFOSIZ];
30
char    g_keyAsciiFIFO[KEYFIFOSIZ];
31
uint8_t g_keyFIFOend;
32
uint8_t g_keyAsciiPos;
33
uint8_t g_keyAsciiEnd;
34
char    g_keyRemapTable[NUMKEYS];
35
char    g_keyNameTable[NUMKEYS][24];
4853 hendricks2 36
 
6827 terminx 37
void (*keypresscallback)(int32_t, int32_t);
4853 hendricks2 38
 
6827 terminx 39
void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; }
1652 terminx 40
 
6827 terminx 41
int32_t keyGetState(int32_t key) { return keystatus[g_keyRemapTable[key]]; }
1819 plagman 42
 
6827 terminx 43
void keySetState(int32_t key, int32_t state)
4269 hendricks2 44
{
6827 terminx 45
    keystatus[g_keyRemapTable[key]] = state;
4749 terminx 46
 
1762 terminx 47
    if (state)
1652 terminx 48
    {
6827 terminx 49
        g_keyFIFO[g_keyFIFOend] = g_keyRemapTable[key];
50
        g_keyFIFO[(g_keyFIFOend+1)&(KEYFIFOSIZ-1)] = state;
51
        g_keyFIFOend = ((g_keyFIFOend+2)&(KEYFIFOSIZ-1));
1652 terminx 52
    }
53
}
54
 
55
//
6827 terminx 56
// character-based input functions
1652 terminx 57
//
6827 terminx 58
char keyGetChar(void)
1652 terminx 59
{
6827 terminx 60
    if (g_keyAsciiPos == g_keyAsciiEnd)
1652 terminx 61
        return 0;
62
 
6827 terminx 63
    char const c    = g_keyAsciiFIFO[g_keyAsciiPos];
64
    g_keyAsciiPos = ((g_keyAsciiPos + 1) & (KEYFIFOSIZ - 1));
65
 
66
    return c;
1652 terminx 67
}
68
 
6827 terminx 69
void keyFlushChars(void)
1652 terminx 70
{
6827 terminx 71
    Bmemset(&g_keyAsciiFIFO,0,sizeof(g_keyAsciiFIFO));
72
    g_keyAsciiPos = g_keyAsciiEnd = 0;
1652 terminx 73
}
74
 
6827 terminx 75
const char *keyGetName(int32_t num) { return ((unsigned)num >= NUMKEYS) ? NULL : g_keyNameTable[num]; }
76
 
77
vec2_t  g_mousePos;
78
vec2_t  g_mouseAbs;
79
int32_t g_mouseBits;
80
uint8_t g_mouseClickState;
81
 
82
bool g_mouseEnabled;
83
bool g_mouseGrabbed;
84
bool g_mouseInsideWindow   = 1;
85
bool g_mouseLockedToWindow = 1;
86
 
87
void (*g_mouseCallback)(int32_t, int32_t);
88
void mouseSetCallback(void(*callback)(int32_t, int32_t)) { g_mouseCallback = callback; }
89
 
90
int32_t mouseAdvanceClickState(void)
1652 terminx 91
{
6827 terminx 92
    switch (g_mouseClickState)
93
    {
94
        case MOUSE_PRESSED: g_mouseClickState  = MOUSE_HELD; return 1;
95
        case MOUSE_RELEASED: g_mouseClickState = MOUSE_IDLE; return 1;
96
        case MOUSE_HELD: return 1;
97
    }
98
    return 0;
1652 terminx 99
}
100
 
6827 terminx 101
void mouseReadPos(int32_t *x, int32_t *y)
1857 terminx 102
{
6827 terminx 103
    if (!g_mouseEnabled || !g_mouseGrabbed || !appactive)
104
    {
105
        *x = *y = 0;
106
        return;
107
    }
108
 
109
    *x = g_mousePos.x;
110
    *y = g_mousePos.y;
111
    g_mousePos.x = g_mousePos.y = 0;
1857 terminx 112
}
113
 
6827 terminx 114
int32_t mouseReadAbs(vec2_t * const pResult, vec2_t const * const pInput)
2623 helixhorne 115
{
6827 terminx 116
    if (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE))
4738 hendricks2 117
        return 0;
118
 
6827 terminx 119
    int32_t const xwidth = max(scale(240<<16, xdim, ydim), 320<<16);
4738 hendricks2 120
 
6939 pogokeen 121
    pResult->x = scale(pInput->x, xwidth, xres) - ((xwidth>>1) - (320<<15));
122
    pResult->y = scale(pInput->y, 200<<16, yres);
4738 hendricks2 123
 
7321 terminx 124
    pResult->y = divscale16(pResult->y - (200<<15), rotatesprite_yxaspect) + (200<<15) - rotatesprite_y_offset;
125
 
4738 hendricks2 126
    return 1;
2623 helixhorne 127
}
128
 
7181 terminx 129
int32_t mouseReadButtons(void)
1857 terminx 130
{
7181 terminx 131
    return (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE)) ? 0 : g_mouseBits;
1857 terminx 132
}
133
 
6827 terminx 134
controllerinput_t joystick;
2728 hendricks2 135
 
6827 terminx 136
void joySetCallback(void (*callback)(int32_t, int32_t)) { joystick.pCallback = callback; }
137
void joyReadButtons(int32_t *pResult) { *pResult = appactive ? joystick.bits : 0; }
138
 
6065 hendricks2 139
#if defined __linux || defined EDUKE32_BSD || defined __APPLE__
4719 terminx 140
# include <sys/mman.h>
141
#endif
142
 
143
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
144
#ifdef __cplusplus
145
extern "C" {
146
#endif
147
    extern intptr_t dep_begin, dep_end;
148
#ifdef __cplusplus
4766 hendricks2 149
}
4719 terminx 150
#endif
151
#endif
152
 
4723 terminx 153
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
5760 hendricks2 154
static int32_t nx_unprotect(intptr_t beg, intptr_t end, int prot)
4719 terminx 155
{
156
# if defined _WIN32
5760 hendricks2 157
#  define B_PROT_RW PAGE_READWRITE
158
#  define B_PROT_RX PAGE_EXECUTE_READ
159
#  define B_PROT_RWX PAGE_EXECUTE_READWRITE
160
 
4719 terminx 161
    DWORD oldprot;
162
 
5760 hendricks2 163
    if (!VirtualProtect((LPVOID) beg, (SIZE_T)end - (SIZE_T)beg, prot, &oldprot))
4719 terminx 164
    {
165
        initprintf("VirtualProtect() error! Crashing in 3... 2... 1...\n");
166
        return 1;
167
    }
5037 hendricks2 168
# elif defined __linux || defined EDUKE32_BSD || defined __APPLE__
5760 hendricks2 169
#  define B_PROT_RW (PROT_READ|PROT_WRITE)
170
#  define B_PROT_RX (PROT_READ|PROT_EXEC)
171
#  define B_PROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC)
172
 
4719 terminx 173
    int32_t pagesize;
174
    size_t dep_begin_page;
175
    pagesize = sysconf(_SC_PAGE_SIZE);
176
    if (pagesize == -1)
177
    {
178
        initprintf("Error getting system page size\n");
179
        return 1;
180
    }
181
    dep_begin_page = ((size_t)beg) & ~(pagesize-1);
5760 hendricks2 182
    if (mprotect((void *) dep_begin_page, (size_t)end - dep_begin_page, prot) < 0)
4719 terminx 183
    {
184
        initprintf("Error making code writeable (errno=%d)\n", errno);
185
        return 1;
186
    }
187
# else
188
#  error "Don't know how to unprotect the self-modifying assembly on this platform!"
189
# endif
190
 
191
    return 0;
192
}
4723 terminx 193
#endif
4719 terminx 194
 
195
 
3291 helixhorne 196
// Calculate ylookup[] and call setvlinebpl()
197
void calc_ylookup(int32_t bpl, int32_t lastyidx)
198
{
199
    int32_t i, j=0;
4724 helixhorne 200
    static int32_t ylookupsiz;
3291 helixhorne 201
 
4724 helixhorne 202
    Bassert(lastyidx <= MAXYDIM);
203
 
4719 terminx 204
    lastyidx++;
205
 
4695 terminx 206
    if (lastyidx > ylookupsiz)
3291 helixhorne 207
    {
7705 terminx 208
        Xaligned_free(ylookup);
4695 terminx 209
 
210
        ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t));
211
        ylookupsiz = lastyidx;
212
    }
213
 
214
    for (i=0; i<=lastyidx-4; i+=4)
215
    {
3291 helixhorne 216
        ylookup[i] = j;
4695 terminx 217
        ylookup[i + 1] = j + bpl;
218
        ylookup[i + 2] = j + (bpl << 1);
219
        ylookup[i + 3] = j + (bpl * 3);
220
        j += (bpl << 2);
221
    }
222
 
4724 helixhorne 223
    for (; i<lastyidx; i++)
4695 terminx 224
    {
225
        ylookup[i] = j;
3291 helixhorne 226
        j += bpl;
227
    }
228
 
229
    setvlinebpl(bpl);
230
}
231
 
4719 terminx 232
 
233
void makeasmwriteable(void)
234
{
235
#if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__)
5760 hendricks2 236
    nx_unprotect((intptr_t)&dep_begin, (intptr_t)&dep_end, B_PROT_RWX);
4719 terminx 237
#endif
238
}
239
 
5938 terminx 240
int32_t vsync=0;
6827 terminx 241
int32_t g_logFlushWindow = 1;
5938 terminx 242
 
99 terminx 243
#ifdef USE_OPENGL
1625 terminx 244
struct glinfo_t glinfo =
584 terminx 245
{
1506 plagman 246
    "Unknown",  // vendor
247
    "Unknown",  // renderer
248
    "0.0.0",    // version
249
    "",         // extensions
109 terminx 250
 
1506 plagman 251
    1.0,        // max anisotropy
252
    0,          // brga texture format
253
    0,          // clamp-to-edge support
254
    0,          // texture compression
255
    0,          // non-power-of-two textures
256
    0,          // multisampling
257
    0,          // nvidia multisampling hint
258
    0,          // ARBfp
259
    0,          // depth textures
260
    0,          // shadow comparison
261
    0,          // Frame Buffer Objects
262
    0,          // rectangle textures
263
    0,          // multitexturing
264
    0,          // env_combine
265
    0,          // Vertex Buffer Objects
266
    0,          // VSync support
267
    0,          // Shader Model 4 support
268
    0,          // Occlusion Queries
269
    0,          // GLSL
2056 plagman 270
    0,          // Debug Output
5309 helixhorne 271
    0,          // Buffer storage
6662 pogokeen 272
    0,          // Sync
7753 pogokeen 273
    0,          // Depth Clamp
274
    0,          // Clip Control
1506 plagman 275
    0,          // GL info dumped
584 terminx 276
};
99 terminx 277
 
4015 helixhorne 278
// Used to register the game's / editor's osdcmd_vidmode() functions here.
7154 terminx 279
int32_t (*baselayer_osdcmd_vidmode_func)(osdcmdptr_t parm);
4015 helixhorne 280
 
7154 terminx 281
static int osdfunc_setrendermode(osdcmdptr_t parm)
99 terminx 282
{
4015 helixhorne 283
    if (parm->numparms != 1)
284
        return OSDCMD_SHOWHELP;
285
 
5547 terminx 286
    char *p;
287
    int32_t m = Bstrtol(parm->parms[0], &p, 10);
99 terminx 288
 
4015 helixhorne 289
    if (m != REND_CLASSIC && m != REND_POLYMOST && m != REND_POLYMER)
290
        return OSDCMD_SHOWHELP;
99 terminx 291
 
4015 helixhorne 292
    if ((m==REND_CLASSIC) != (bpp==8) && baselayer_osdcmd_vidmode_func)
293
    {
294
        // Mismatch between video mode and requested renderer, do auto switch.
295
        osdfuncparm_t parm;
296
        char arg[4];
297
 
298
        const char *ptrptr[1];
299
        ptrptr[0] = arg;
300
 
301
        Bmemset(&parm, 0, sizeof(parm));
302
 
303
        if (m==REND_CLASSIC)
304
            Bmemcpy(&arg, "8", 2);
305
        else
306
            Bmemcpy(&arg, "32", 3);
307
 
308
        // CAUTION: we assume that the osdcmd_vidmode function doesn't use any
309
        // other member!
310
        parm.numparms = 1;
311
        parm.parms = ptrptr;
312
 
313
        baselayer_osdcmd_vidmode_func(&parm);
314
    }
315
 
6831 terminx 316
    videoSetRenderMode(m);
99 terminx 317
 
7020 terminx 318
    char const *renderer = "other";
5547 terminx 319
 
6829 terminx 320
    switch (videoGetRenderMode())
3347 terminx 321
    {
322
    case REND_CLASSIC:
7020 terminx 323
#ifdef NOASM
324
        renderer = "classic software (C)";
325
#else
326
        renderer = "classic software (ASM)";
327
#endif
3347 terminx 328
        break;
329
    case REND_POLYMOST:
5547 terminx 330
        renderer = "polygonal OpenGL";
3347 terminx 331
        break;
5663 terminx 332
#ifdef POLYMER
3347 terminx 333
    case REND_POLYMER:
5547 terminx 334
        renderer = "great justice (Polymer)";
3347 terminx 335
        break;
5663 terminx 336
#endif
3347 terminx 337
    }
338
 
5547 terminx 339
    OSD_Printf("Rendering method changed to %s\n", renderer);
3347 terminx 340
 
109 terminx 341
    return OSDCMD_OK;
99 terminx 342
}
6827 terminx 343
 
99 terminx 344
#ifdef DEBUGGINGAIDS
7154 terminx 345
static int osdcmd_hicsetpalettetint(osdcmdptr_t parm)
99 terminx 346
{
6557 hendricks2 347
    int32_t parms[8];
109 terminx 348
 
6557 hendricks2 349
    if (parm->numparms < 1 || (int32_t)ARRAY_SIZE(parms) < parm->numparms) return OSDCMD_SHOWHELP;
109 terminx 350
 
6557 hendricks2 351
    size_t i;
352
    for (i = 0; (int32_t)i < parm->numparms; ++i)
353
        parms[i] = Batol(parm->parms[i]);
354
    for (; i < ARRAY_SIZE(parms); ++i)
355
        parms[i] = 0;
109 terminx 356
 
6557 hendricks2 357
    // order is intentional
358
    hicsetpalettetint(parms[0],parms[1],parms[2],parms[3],parms[5],parms[6],parms[7],parms[4]);
109 terminx 359
 
360
    return OSDCMD_OK;
99 terminx 361
}
362
#endif
363
 
7154 terminx 364
int osdcmd_glinfo(osdcmdptr_t UNUSED(parm))
99 terminx 365
{
6297 terminx 366
    UNREFERENCED_CONST_PARAMETER(parm);
654 terminx 367
 
584 terminx 368
    if (bpp == 8)
369
    {
5001 terminx 370
        initprintf("glinfo: not in OpenGL mode!\n");
109 terminx 371
        return OSDCMD_OK;
372
    }
373
 
5001 terminx 374
    initprintf("OpenGL information\n %s %s %s\n",
375
               glinfo.vendor, glinfo.renderer, glinfo.version);
848 terminx 376
 
377
    if (!glinfo.dumped)
378
        return OSDCMD_OK;
379
 
6827 terminx 380
    char const *s[] = { "supported", "not supported" };
381
 
382
#define SUPPORTED(x) (x ? s[0] : s[1])
383
 
384
    initprintf(" BGRA textures:           %s\n", SUPPORTED(glinfo.bgra));
385
    initprintf(" Non-power-of-2 textures: %s\n", SUPPORTED(glinfo.texnpot));
386
    initprintf(" Clamp-to-edge:           %s\n", SUPPORTED(glinfo.clamptoedge));
387
    initprintf(" Multi-texturing:         %s\n", SUPPORTED(glinfo.multitex));
388
    initprintf(" Framebuffer objects:     %s\n", SUPPORTED(glinfo.fbos));
5001 terminx 389
#ifndef EDUKE32_GLES
6827 terminx 390
    initprintf(" Texture compression:     %s\n", SUPPORTED(glinfo.texcompr));
391
    initprintf(" Multi-sampling:          %s\n", SUPPORTED(glinfo.multisample));
392
    initprintf(" NVIDIA multisample hint: %s\n", SUPPORTED(glinfo.nvmultisamplehint));
393
    initprintf(" ARBfp fragment programs: %s\n", SUPPORTED(glinfo.arbfp));
394
    initprintf(" Depth textures:          %s\n", SUPPORTED(glinfo.depthtex));
395
    initprintf(" Shadow textures:         %s\n", SUPPORTED(glinfo.shadow));
396
    initprintf(" Rectangle textures:      %s\n", SUPPORTED(glinfo.rect));
397
    initprintf(" env_combine:             %s\n", SUPPORTED(glinfo.envcombine));
398
    initprintf(" Vertex buffer objects:   %s\n", SUPPORTED(glinfo.vbos));
399
    initprintf(" Shader model 4:          %s\n", SUPPORTED(glinfo.sm4));
400
    initprintf(" Occlusion queries:       %s\n", SUPPORTED(glinfo.occlusionqueries));
401
    initprintf(" GLSL:                    %s\n", SUPPORTED(glinfo.glsl));
402
    initprintf(" Debug output:            %s\n", SUPPORTED(glinfo.debugoutput));
403
    initprintf(" Buffer storage:          %s\n", SUPPORTED(glinfo.bufferstorage));
404
    initprintf(" Sync:                    %s\n", SUPPORTED(glinfo.sync));
5001 terminx 405
#endif
6827 terminx 406
    initprintf(" Maximum anisotropy:      %.1f%s\n", glinfo.maxanisotropy, glinfo.maxanisotropy > 1.0 ? "" : " (no anisotropic filtering)");
109 terminx 407
 
6827 terminx 408
#undef SUPPORTED
109 terminx 409
 
6827 terminx 410
    initprintf(" Extensions:\n%s", glinfo.extensions);
411
 
109 terminx 412
    return OSDCMD_OK;
99 terminx 413
}
414
#endif
415
 
7154 terminx 416
static int osdcmd_cvar_set_baselayer(osdcmdptr_t parm)
99 terminx 417
{
1665 terminx 418
    int32_t r = osdcmd_cvar_set(parm);
109 terminx 419
 
1665 terminx 420
    if (r != OSDCMD_OK) return r;
421
 
422
    if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
423
    {
6829 terminx 424
        videoSetPalette(GAMMA_CALC,0,0);
1665 terminx 425
 
426
        return r;
109 terminx 427
    }
1665 terminx 428
 
429
    return r;
99 terminx 430
}
431
 
1205 terminx 432
int32_t baselayer_init(void)
99 terminx 433
{
2601 helixhorne 434
#ifdef _WIN32
435
// on Windows, don't save the "r_screenaspect" cvar because the physical screen size is
436
// determined at startup
437
# define SCREENASPECT_CVAR_TYPE (CVAR_UINT|CVAR_NOSAVE)
438
#else
439
# define SCREENASPECT_CVAR_TYPE (CVAR_UINT)
440
#endif
6297 terminx 441
    static osdcvardata_t cvars_engine[] =
1352 terminx 442
    {
6807 terminx 443
        { "lz4compressionlevel","adjust LZ4 compression level used for savegames",(void *) &lz4CompressionLevel, CVAR_INT, 1, 32 },
8065 terminx 444
        { "r_borderless", "borderless windowed mode: 0: never  1: always  2: if resolution matches desktop", (void *) &r_borderless, CVAR_INT|CVAR_RESTARTVID, 0, 2 },
445
        { "r_displayindex","index of output display",(void *)&r_displayindex, CVAR_INT|CVAR_RESTARTVID, 0, 10 },
3783 terminx 446
        { "r_usenewaspect","enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 },
447
        { "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",
2959 helixhorne 448
          (void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 },
7755 terminx 449
        { "r_fpgrouscan","use floating-point numbers for slope rendering",(void *) &r_fpgrouscan, CVAR_BOOL, 0, 1 },
3783 terminx 450
        { "r_novoxmips","turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 },
451
        { "r_voxels","enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 },
2024 helixhorne 452
#ifdef YAX_ENABLE
3783 terminx 453
        { "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 },
2024 helixhorne 454
#endif
4327 terminx 455
        { "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 },
6828 terminx 456
        { "vid_gamma","adjusts gamma component of gamma ramp",(void *) &g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
457
        { "vid_contrast","adjusts contrast component of gamma ramp",(void *) &g_videoContrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
458
        { "vid_brightness","adjusts brightness component of gamma ramp",(void *) &g_videoBrightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 },
3349 terminx 459
#ifdef DEBUGGINGAIDS
1762 terminx 460
        { "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 },
461
        { "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 },
3349 terminx 462
#endif
4261 helixhorne 463
#ifdef DEBUG_MASK_DRAWING
4264 helixhorne 464
        { "debug_maskdrawmode", "Show mask draw orders", (void *)&g_maskDrawMode, CVAR_BOOL, 0, 1 },
4261 helixhorne 465
#endif
1352 terminx 466
    };
467
 
7130 terminx 468
    for (auto & i : cvars_engine)
469
        OSD_RegisterCvar(&i, (i.flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set);
1625 terminx 470
 
1820 terminx 471
#ifdef USE_OPENGL
109 terminx 472
    OSD_RegisterFunction("setrendermode","setrendermode <number>: sets the engine's rendering mode.\n"
473
                         "Mode numbers are:\n"
474
                         "   0 - Classic Build software\n"
475
                         "   3 - Polygonal OpenGL\n"
5663 terminx 476
#ifdef POLYMER
1652 terminx 477
                         "   4 - Great justice renderer (Polymer)\n"
5663 terminx 478
#endif
109 terminx 479
                         ,
480
                         osdfunc_setrendermode);
5419 hendricks2 481
 
1564 plagman 482
# ifdef DEBUGGINGAIDS
109 terminx 483
    OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint);
1564 plagman 484
# endif
5419 hendricks2 485
 
109 terminx 486
    OSD_RegisterFunction("glinfo","glinfo: shows OpenGL information about the current OpenGL mode",osdcmd_glinfo);
5419 hendricks2 487
 
1352 terminx 488
    polymost_initosdfuncs();
99 terminx 489
#endif
1352 terminx 490
 
6827 terminx 491
    for (native_t i = 0; i < NUMKEYS; i++) g_keyRemapTable[i] = i;
492
 
8094 hendricks2 493
    communityapiInit();
494
 
109 terminx 495
    return 0;
99 terminx 496
}
497
 
3377 helixhorne 498
void maybe_redirect_outputs(void)
499
{
500
#if !(defined __APPLE__ && defined __BIG_ENDIAN__)
501
    char *argp;
502
 
503
    // pipe standard outputs to files
6827 terminx 504
    if ((argp = Bgetenv("BUILD_LOGSTDOUT")) == NULL || Bstrcasecmp(argp, "TRUE"))
505
        return;
3377 helixhorne 506
 
6827 terminx 507
    FILE *fp = freopen("stdout.txt", "w", stdout);
3377 helixhorne 508
 
6827 terminx 509
    if (!fp)
510
        fp = fopen("stdout.txt", "w");
511
 
512
    if (fp)
513
    {
514
        setvbuf(fp, 0, _IONBF, 0);
515
        *stdout = *fp;
516
        *stderr = *fp;
517
    }
3377 helixhorne 518
#endif
519
}