From ee63d2c0703bbd4cdeaa72d7809c3639c3f4554c Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 12 Apr 2018 21:02:31 +0000 Subject: [PATCH] Beginnings of baselayer.cpp/.h refactor. This is 99.9% renames. git-svn-id: https://svn.eduke32.com/eduke32@6827 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/baselayer.h | 115 +++++----- source/build/include/build.h | 11 - source/build/include/palette.h | 12 ++ source/build/src/baselayer.cpp | 357 ++++++++++++------------------- source/build/src/build.cpp | 54 ++--- source/build/src/config.cpp | 10 +- source/build/src/defs.cpp | 16 +- source/build/src/engine.cpp | 4 +- source/build/src/osd.cpp | 7 +- source/build/src/palette.cpp | 33 +++ source/build/src/rawinput.cpp | 84 ++++---- source/build/src/sdlayer.cpp | 211 +++++++++--------- source/build/src/sdlayer12.cpp | 44 ++-- source/build/src/winlayer.cpp | 133 ++++++------ source/duke3d/src/astub.cpp | 106 ++++----- source/duke3d/src/game.cpp | 6 +- source/duke3d/src/gamedef.cpp | 4 +- source/duke3d/src/input.cpp | 4 +- source/duke3d/src/menus.cpp | 70 +++--- source/duke3d/src/osdfuncs.cpp | 2 +- source/duke3d/src/screens.cpp | 2 +- source/mact/include/keyboard.h | 10 +- source/mact/include/mouse.h | 12 +- source/mact/src/control.cpp | 8 +- source/mact/src/joystick.cpp | 34 +-- 25 files changed, 641 insertions(+), 708 deletions(-) diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index b56b7520c..1e6ce125e 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -51,8 +51,6 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx); #ifdef USE_OPENGL extern int32_t (*baselayer_osdcmd_vidmode_func)(osdfuncparm_t const * const parm); - -void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f); extern int32_t osdcmd_glinfo(osdfuncparm_t const * const parm); struct glinfo_t { @@ -89,40 +87,60 @@ struct glinfo_t { extern struct glinfo_t glinfo; #endif extern int32_t setvsync(int32_t newSync); +extern vec2_t const g_defaultVideoModes[]; + extern char inputdevices; // keys #define NUMKEYS 256 -#define KEYSTATUSSIZ 256 #define KEYFIFOSIZ 64 -extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ]; -extern uint8_t keyasciififoplc, keyasciififoend, keyfifoplc, keyfifoend; -extern char scantoasc[128], keyremap[KEYSTATUSSIZ], key_names[NUMKEYS][24]; -extern int32_t keyremapinit; +extern char const g_keyAsciiTable[128]; -extern int32_t defaultres[][2]; +extern char keystatus[NUMKEYS]; +extern char g_keyFIFO[KEYFIFOSIZ]; +extern char g_keyAsciiFIFO[KEYFIFOSIZ]; +extern uint8_t g_keyAsciiPos; +extern uint8_t g_keyAsciiEnd; +extern uint8_t g_keyFIFOend; +extern char g_keyRemapTable[NUMKEYS]; +extern char g_keyNameTable[NUMKEYS][24]; -extern int32_t GetKey(int32_t key); -extern void SetKey(int32_t key, int32_t state); +extern int32_t keyGetState(int32_t key); +extern void keySetState(int32_t key, int32_t state); // mouse -extern int32_t mousex, mousey, mouseb; -extern vec2_t mouseabs; -extern uint8_t mousepressstate; -extern uint8_t mousegrab, moustat, mouseinwindow, AppMouseGrab; +extern vec2_t g_mousePos; +extern vec2_t g_mouseAbs; +extern int32_t g_mouseBits; +extern uint8_t g_mouseClickState; +extern bool g_mouseGrabbed; +extern bool g_mouseEnabled; +extern bool g_mouseInsideWindow; +extern bool g_mouseLockedToWindow; + enum { - Mouse_Idle = 0, - Mouse_Pressed = 1, - Mouse_Held = 2, - Mouse_Released = 3, + MOUSE_IDLE = 0, + MOUSE_PRESSED, + MOUSE_HELD, + MOUSE_RELEASED, }; -extern int32_t mousepressstateadvance(void); +extern int32_t mouseAdvanceClickState(void); // joystick -extern int32_t *joyaxis, *joyhat, joyb; -extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats; -extern int32_t joyaxespresent; + +typedef struct +{ + int32_t *pAxis; + int32_t *pHat; + void (*pCallback)(int32_t, int32_t); + int32_t bits; + int32_t numAxes; + int32_t numButtons; + int32_t numHats; +} controllerinput_t; + +extern controllerinput_t joystick; extern int32_t qsetmode; @@ -132,7 +150,7 @@ int32_t initsystem(void); void uninitsystem(void); void system_getcvars(void); -extern int32_t flushlogwindow; +extern int32_t g_logFlushWindow; void initputs(const char *); #define buildputs initputs void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2))); @@ -143,44 +161,43 @@ int32_t handleevents(void); int32_t handleevents_peekkeys(void); extern void (*keypresscallback)(int32_t,int32_t); -extern void (*mousepresscallback)(int32_t,int32_t); -extern void (*joypresscallback)(int32_t,int32_t); +extern void (*g_mouseCallback)(int32_t,int32_t); int32_t initinput(void); void uninitinput(void); -void releaseallbuttons(void); -void setkeypresscallback(void (*callback)(int32_t,int32_t)); -void setmousepresscallback(void (*callback)(int32_t,int32_t)); -void setjoypresscallback(void (*callback)(int32_t,int32_t)); -const char *getkeyname(int32_t num); -const char *getjoyname(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat +void keySetCallback(void (*callback)(int32_t,int32_t)); +void mouseSetCallback(void (*callback)(int32_t,int32_t)); +void joySetCallback(void (*callback)(int32_t,int32_t)); +const char *keyGetName(int32_t num); +const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat -char bgetchar(void); -#define bkbhit() (keyasciififoplc != keyasciififoend) +char keyGetChar(void); +#define keyBufferWaiting() (g_keyAsciiPos != g_keyAsciiEnd) -static FORCE_INLINE int keyascfifo_isfull(void) +static FORCE_INLINE int keyBufferFull(void) { - return ((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc; + return ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1)) == g_keyAsciiPos; } -static FORCE_INLINE void keyascfifo_insert(char code) +static FORCE_INLINE void keyBufferInsert(char code) { - keyasciififo[keyasciififoend] = code; - keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); + g_keyAsciiFIFO[g_keyAsciiEnd] = code; + g_keyAsciiEnd = ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1)); } -void bflushchars(void); +void keyFlushChars(void); -int32_t initmouse(void); -void uninitmouse(void); -void grabmouse(char a); -void AppGrabMouse(char a); -void readmousexy(int32_t *x, int32_t *y); -int32_t readmouseabsxy(vec2_t * const destination, vec2_t const * const source); -void readmousebstatus(int32_t *b); -void readjoybstatus(int32_t *b); -void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur); -void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur); +int32_t mouseInit(void); +void mouseUninit(void); +void mouseGrabInput(char a); +void mouseLockToWindow(char a); +void mouseReadPos(int32_t *x, int32_t *y); +int32_t mouseReadAbs(vec2_t * const destination, vec2_t const * const source); +void mouseReadButtons(int32_t *b); + +void joyReadButtons(int32_t *b); +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; int32_t inittimer(int32_t); diff --git a/source/build/include/build.h b/source/build/include/build.h index 31e9f4524..ae61ec458 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1054,18 +1054,7 @@ int32_t qloadkvx(int32_t voxindex, const char *filename); void vox_undefine(int32_t const); intptr_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz); void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2); -void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); -//void setvgapalette(void); -void setbasepal(int32_t id, uint8_t const *table); -void removebasepal(int32_t id); -void setblendtab(int32_t blend, const char *tab); -void removeblendtab(int32_t blend); -int32_t setpalookup(int32_t palnum, const uint8_t *shtab); -void removepalookup(int32_t palnum); -void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags); -void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset); void squarerotatetile(int16_t tilenume); -void fade_screen_black(int32_t moreopaquep); int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t dabpp); void nextpage(void); diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 43c0c5217..45b995354 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -36,7 +36,19 @@ typedef struct { uint8_t r, g, b; } rgb24_t; extern palette_t curpalette[256], curpalettefaded[256], palfadergb; + extern char palfadedelta; +extern void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f); +extern void fade_screen_black(int32_t moreopaquep); +void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); +void setbasepal(int32_t id, uint8_t const *table); +void removebasepal(int32_t id); +void setblendtab(int32_t blend, const char *tab); +void removeblendtab(int32_t blend); +int32_t setpalookup(int32_t palnum, const uint8_t *shtab); +void removepalookup(int32_t palnum); +void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags); +void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset); extern int32_t realmaxshade; extern float frealmaxshade; diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp index 06bb9823c..8072cf58d 100644 --- a/source/build/src/baselayer.cpp +++ b/source/build/src/baselayer.cpp @@ -9,6 +9,7 @@ #include "polymost.h" #include "cache1d.h" +// video #ifdef _WIN32 extern "C" { @@ -17,145 +18,131 @@ extern "C" } #endif // _WIN32 +vec2_t const g_defaultVideoModes[] += { { 2560, 1440 }, { 2560, 1200 }, { 2560, 1080 }, { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, { 1680, 1050 }, + { 1600, 1200 }, { 1600, 900 }, { 1366, 768 }, { 1280, 1024 }, { 1280, 960 }, { 1280, 720 }, { 1152, 864 }, + { 1024, 768 }, { 1024, 600 }, { 800, 600 }, { 640, 480 }, { 640, 400 }, { 512, 384 }, { 480, 360 }, + { 400, 300 }, { 320, 240 }, { 320, 200 }, { 0, 0 } }; + // input -char inputdevices=0; -char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ]; -uint8_t keyfifoplc, keyfifoend, keyasciififoplc, keyasciififoend; -char keyremap[KEYSTATUSSIZ]; -int32_t keyremapinit=0; -char key_names[NUMKEYS][24]; -int32_t mousex=0,mousey=0,mouseb=0; -vec2_t mouseabs; -uint8_t mousepressstate; -uint8_t moustat = 0, mousegrab = 0, mouseinwindow = 1, AppMouseGrab = 1; +char inputdevices = 0; -int32_t mousepressstateadvance(void) -{ - if (mousepressstate == Mouse_Pressed) - { - mousepressstate = Mouse_Held; - return 1; - } - else if (mousepressstate == Mouse_Released) - { - mousepressstate = Mouse_Idle; - return 1; - } - else if (mousepressstate == Mouse_Held) - return 1; +char keystatus[NUMKEYS]; +char g_keyFIFO[KEYFIFOSIZ]; +char g_keyAsciiFIFO[KEYFIFOSIZ]; +uint8_t g_keyFIFOend; +uint8_t g_keyAsciiPos; +uint8_t g_keyAsciiEnd; +char g_keyRemapTable[NUMKEYS]; +char g_keyNameTable[NUMKEYS][24]; - return 0; -} +void (*keypresscallback)(int32_t, int32_t); -int32_t *joyaxis = NULL, joyb=0, *joyhat = NULL; -char joyisgamepad=0, joynumaxes=0, joynumbuttons=0, joynumhats=0; -int32_t joyaxespresent=0; +void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = callback; } -void(*keypresscallback)(int32_t,int32_t) = 0; -void(*mousepresscallback)(int32_t,int32_t) = 0; -void(*joypresscallback)(int32_t,int32_t) = 0; - -extern int16_t brightness; - -// -// 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; } - -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', +char const g_keyAsciiTable[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, + 0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -int32_t defaultres[][2] -= { { 2560, 1440 }, { 2560, 1200 }, { 2560, 1080 }, { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, { 1680, 1050 }, { 1600, 1200 }, - { 1600, 900 }, { 1366, 768 }, { 1280, 1024 }, { 1280, 960 }, { 1280, 720 }, { 1152, 864 }, { 1024, 768 }, { 1024, 600 }, - { 800, 600 }, { 640, 480 }, { 640, 400 }, { 512, 384 }, { 480, 360 }, { 400, 300 }, { 320, 240 }, { 320, 200 }, - { 0, 0 } }; +int32_t keyGetState(int32_t key) { return keystatus[g_keyRemapTable[key]]; } - -int32_t GetKey(int32_t key) +void keySetState(int32_t key, int32_t state) { - return keystatus[keyremap[key]]; -} - -void SetKey(int32_t key, int32_t state) -{ - keystatus[keyremap[key]] = state; + keystatus[g_keyRemapTable[key]] = state; if (state) { - keyfifo[keyfifoend] = keyremap[key]; - keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; - keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); + g_keyFIFO[g_keyFIFOend] = g_keyRemapTable[key]; + g_keyFIFO[(g_keyFIFOend+1)&(KEYFIFOSIZ-1)] = state; + g_keyFIFOend = ((g_keyFIFOend+2)&(KEYFIFOSIZ-1)); } } // -// bgetchar, bflushchars -- character-based input functions +// character-based input functions // -char bgetchar(void) +char keyGetChar(void) { - if (keyasciififoplc == keyasciififoend) + if (g_keyAsciiPos == g_keyAsciiEnd) return 0; + char const c = g_keyAsciiFIFO[g_keyAsciiPos]; + g_keyAsciiPos = ((g_keyAsciiPos + 1) & (KEYFIFOSIZ - 1)); + + return c; +} + +void keyFlushChars(void) +{ + Bmemset(&g_keyAsciiFIFO,0,sizeof(g_keyAsciiFIFO)); + g_keyAsciiPos = g_keyAsciiEnd = 0; +} + +const char *keyGetName(int32_t num) { return ((unsigned)num >= NUMKEYS) ? NULL : g_keyNameTable[num]; } + +vec2_t g_mousePos; +vec2_t g_mouseAbs; +int32_t g_mouseBits; +uint8_t g_mouseClickState; + +bool g_mouseEnabled; +bool g_mouseGrabbed; +bool g_mouseInsideWindow = 1; +bool g_mouseLockedToWindow = 1; + +void (*g_mouseCallback)(int32_t, int32_t); +void mouseSetCallback(void(*callback)(int32_t, int32_t)) { g_mouseCallback = callback; } + +int32_t mouseAdvanceClickState(void) +{ + switch (g_mouseClickState) { - char c = keyasciififo[keyasciififoplc]; - keyasciififoplc = ((keyasciififoplc+1)&(KEYFIFOSIZ-1)); - return c; + case MOUSE_PRESSED: g_mouseClickState = MOUSE_HELD; return 1; + case MOUSE_RELEASED: g_mouseClickState = MOUSE_IDLE; return 1; + case MOUSE_HELD: return 1; } + return 0; } -void bflushchars(void) +void mouseReadPos(int32_t *x, int32_t *y) { - Bmemset(&keyasciififo,0,sizeof(keyasciififo)); - keyasciififoplc = keyasciififoend = 0; + if (!g_mouseEnabled || !g_mouseGrabbed || !appactive) + { + *x = *y = 0; + return; + } + + *x = g_mousePos.x; + *y = g_mousePos.y; + g_mousePos.x = g_mousePos.y = 0; } -const char *getkeyname(int32_t num) +int32_t mouseReadAbs(vec2_t * const pResult, vec2_t const * const pInput) { - return ((unsigned)num >= 256) ? NULL : key_names[num]; -} - -void readmousexy(int32_t *x, int32_t *y) -{ - if (!moustat || !mousegrab || !appactive) { *x = *y = 0; return; } - *x = mousex; - *y = mousey; - mousex = mousey = 0; -} - -int32_t readmouseabsxy(vec2_t * const destination, vec2_t const * const source) -{ - int32_t xwidth; - - if (!moustat || !appactive || !mouseinwindow || (osd && osd->flags & OSD_CAPTURE)) + if (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE)) return 0; - xwidth = max(scale(240<<16, xdim, ydim), 320<<16); + int32_t const xwidth = max(scale(240<<16, xdim, ydim), 320<<16); - destination->x = scale(source->x, xwidth, xdim) - ((xwidth>>1) - (320<<15)); - destination->y = scale(source->y, 200<<16, ydim); + pResult->x = scale(pInput->x, xwidth, xdim) - ((xwidth>>1) - (320<<15)); + pResult->y = scale(pInput->y, 200<<16, ydim); return 1; } -void readmousebstatus(int32_t *b) +void mouseReadButtons(int32_t *pResult) { - if (!moustat || !appactive || !mouseinwindow || (osd && osd->flags & OSD_CAPTURE)) { *b = 0; return; } - *b = mouseb; + *pResult = (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE)) ? 0 : g_mouseBits; } -void readjoybstatus(int32_t *b) -{ - if (!appactive) { *b = 0; return; } - *b = joyb; -} +controllerinput_t joystick; + +void joySetCallback(void (*callback)(int32_t, int32_t)) { joystick.pCallback = callback; } +void joyReadButtons(int32_t *pResult) { *pResult = appactive ? joystick.bits : 0; } #if defined __linux || defined EDUKE32_BSD || defined __APPLE__ # include @@ -259,41 +246,9 @@ void makeasmwriteable(void) } int32_t vsync=0; +int32_t g_logFlushWindow = 1; #ifdef USE_OPENGL -extern int32_t nofog; - -void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f) -{ - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDisable(GL_TEXTURE_2D); - polymost_setFogEnabled(false); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glColor4ub(r, g, b, f); - - polymost_useColorOnly(true); - glBegin(GL_TRIANGLES); - glVertex2f(-2.5f, 1.f); - glVertex2f(2.5f, 1.f); - glVertex2f(.0f, -2.5f); - glEnd(); - polymost_useColorOnly(false); - - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); -} - struct glinfo_t glinfo = { "Unknown", // vendor @@ -325,11 +280,7 @@ struct glinfo_t glinfo = 0, // Sync 0, // GL info dumped }; -#endif -int32_t flushlogwindow = 1; - -#ifdef USE_OPENGL // Used to register the game's / editor's osdcmd_vidmode() functions here. int32_t (*baselayer_osdcmd_vidmode_func)(osdfuncparm_t const * const parm); @@ -393,7 +344,7 @@ static int32_t osdfunc_setrendermode(osdfuncparm_t const * const parm) return OSDCMD_OK; } -#if defined(USE_OPENGL) + #ifdef DEBUGGINGAIDS static int32_t osdcmd_hicsetpalettetint(osdfuncparm_t const * const parm) { @@ -416,8 +367,6 @@ static int32_t osdcmd_hicsetpalettetint(osdfuncparm_t const * const parm) int32_t osdcmd_glinfo(osdfuncparm_t const * const UNUSED(parm)) { - char *s,*t,*u,i; - UNREFERENCED_CONST_PARAMETER(parm); if (bpp == 8) @@ -432,83 +381,41 @@ int32_t osdcmd_glinfo(osdfuncparm_t const * const UNUSED(parm)) if (!glinfo.dumped) return OSDCMD_OK; - initprintf( - " BGRA textures: %s\n" - " Non-power-of-2 textures: %s\n" - " Clamp-to-edge: %s\n" - " Multitexturing: %s\n" - " Frame Buffer Objects: %s\n" -#ifndef EDUKE32_GLES - " Texture compression: %s\n" - " Multisampling: %s\n" - " NVIDIA multisample hint: %s\n" - " ARBfp fragment programs: %s\n" - " Depth textures: %s\n" - " Shadow textures: %s\n" - " Rectangle textures: %s\n" - " env_combine: %s\n" - " Vertex Buffer Objects: %s\n" - " Shader Model 4: %s\n" - " Occlusion queries: %s\n" - " GLSL: %s\n" - " Debug Output: %s\n" - " Buffer Storage: %s\n" - " Sync: %s\n" -#endif - " Maximum anisotropy: %.1f%s\n" - " Extensions:\n", - glinfo.bgra ? "supported": "not supported", - glinfo.texnpot ? "supported": "not supported", - glinfo.clamptoedge ? "supported": "not supported", - glinfo.multitex ? "supported": "not supported", - glinfo.fbos ? "supported": "not supported", -#ifndef EDUKE32_GLES - glinfo.texcompr ? "supported": "not supported", - glinfo.multisample ? "supported": "not supported", - glinfo.nvmultisamplehint ? "supported": "not supported", - glinfo.arbfp ? "supported": "not supported", - glinfo.depthtex ? "supported": "not supported", - glinfo.shadow ? "supported": "not supported", - glinfo.rect ? "supported": "not supported", - glinfo.envcombine ? "supported": "not supported", - glinfo.vbos ? "supported": "not supported", - glinfo.sm4 ? "supported": "not supported", - glinfo.occlusionqueries ? "supported": "not supported", - glinfo.glsl ? "supported": "not supported", - glinfo.debugoutput ? "supported": "not supported", - glinfo.bufferstorage ? "supported" : "not supported", - glinfo.sync ? "supported" : "not supported", -#endif - glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)" - ); + char const *s[] = { "supported", "not supported" }; - s = Bstrdup(glinfo.extensions); - if (!s) initprintf("%s", glinfo.extensions); - else - { - i = 0; t = u = s; - while (*t) - { - if (*t == ' ') - { - if (i&1) - { - *t = 0; - initprintf(" %s\n",u); - u = t+1; - } - i++; - } - t++; - } - if (i&1) initprintf(" %s\n",u); - Bfree(s); - } +#define SUPPORTED(x) (x ? s[0] : s[1]) + + initprintf(" BGRA textures: %s\n", SUPPORTED(glinfo.bgra)); + initprintf(" Non-power-of-2 textures: %s\n", SUPPORTED(glinfo.texnpot)); + initprintf(" Clamp-to-edge: %s\n", SUPPORTED(glinfo.clamptoedge)); + initprintf(" Multi-texturing: %s\n", SUPPORTED(glinfo.multitex)); + initprintf(" Framebuffer objects: %s\n", SUPPORTED(glinfo.fbos)); +#ifndef EDUKE32_GLES + initprintf(" Texture compression: %s\n", SUPPORTED(glinfo.texcompr)); + initprintf(" Multi-sampling: %s\n", SUPPORTED(glinfo.multisample)); + initprintf(" NVIDIA multisample hint: %s\n", SUPPORTED(glinfo.nvmultisamplehint)); + initprintf(" ARBfp fragment programs: %s\n", SUPPORTED(glinfo.arbfp)); + initprintf(" Depth textures: %s\n", SUPPORTED(glinfo.depthtex)); + initprintf(" Shadow textures: %s\n", SUPPORTED(glinfo.shadow)); + initprintf(" Rectangle textures: %s\n", SUPPORTED(glinfo.rect)); + initprintf(" env_combine: %s\n", SUPPORTED(glinfo.envcombine)); + initprintf(" Vertex buffer objects: %s\n", SUPPORTED(glinfo.vbos)); + initprintf(" Shader model 4: %s\n", SUPPORTED(glinfo.sm4)); + initprintf(" Occlusion queries: %s\n", SUPPORTED(glinfo.occlusionqueries)); + initprintf(" GLSL: %s\n", SUPPORTED(glinfo.glsl)); + initprintf(" Debug output: %s\n", SUPPORTED(glinfo.debugoutput)); + initprintf(" Buffer storage: %s\n", SUPPORTED(glinfo.bufferstorage)); + initprintf(" Sync: %s\n", SUPPORTED(glinfo.sync)); +#endif + initprintf(" Maximum anisotropy: %.1f%s\n", glinfo.maxanisotropy, glinfo.maxanisotropy > 1.0 ? "" : " (no anisotropic filtering)"); + +#undef SUPPORTED + + initprintf(" Extensions:\n%s", glinfo.extensions); return OSDCMD_OK; } #endif -#endif static int32_t osdcmd_cvar_set_baselayer(osdfuncparm_t const * const parm) { @@ -528,7 +435,6 @@ static int32_t osdcmd_cvar_set_baselayer(osdfuncparm_t const * const parm) int32_t baselayer_init(void) { - uint32_t i; #ifdef _WIN32 // on Windows, don't save the "r_screenaspect" cvar because the physical screen size is // determined at startup @@ -560,7 +466,7 @@ int32_t baselayer_init(void) #endif }; - for (i=0; i