Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Sryder13 2014-11-14 22:21:07 +00:00
commit 3f1bb6359f
11 changed files with 345 additions and 280 deletions

View file

@ -84,6 +84,8 @@ EXPORT void HWRAPI(EndScreenWipe) (void);
EXPORT void HWRAPI(DoScreenWipe) (float alpha); EXPORT void HWRAPI(DoScreenWipe) (float alpha);
EXPORT void HWRAPI(DrawIntermissionBG) (void); EXPORT void HWRAPI(DrawIntermissionBG) (void);
EXPORT void HWRAPI(MakeScreenTexture) (void); EXPORT void HWRAPI(MakeScreenTexture) (void);
EXPORT void HWRAPI(MakeScreenFinalTexture) (void);
EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height);
// ========================================================================== // ==========================================================================
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM // HWR DRIVER OBJECT, FOR CLIENT PROGRAM
// ========================================================================== // ==========================================================================
@ -127,6 +129,8 @@ struct hwdriver_s
DoScreenWipe pfnDoScreenWipe; DoScreenWipe pfnDoScreenWipe;
DrawIntermissionBG pfnDrawIntermissionBG; DrawIntermissionBG pfnDrawIntermissionBG;
MakeScreenTexture pfnMakeScreenTexture; MakeScreenTexture pfnMakeScreenTexture;
MakeScreenFinalTexture pfnMakeScreenFinalTexture;
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
}; };
extern struct hwdriver_s hwdriver; extern struct hwdriver_s hwdriver;

View file

@ -5936,4 +5936,14 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum)
HWRWipeCounter = 1.0f; HWRWipeCounter = 1.0f;
} }
void HWR_MakeScreenFinalTexture(void)
{
HWD.pfnMakeScreenFinalTexture();
}
void HWR_DrawScreenFinalTexture(int width, int height)
{
HWD.pfnDrawScreenFinalTexture(width, height);
}
#endif // HWRENDER #endif // HWRENDER

View file

@ -65,6 +65,8 @@ void HWR_StartScreenWipe(void);
void HWR_EndScreenWipe(void); void HWR_EndScreenWipe(void);
void HWR_DrawIntermissionBG(void); void HWR_DrawIntermissionBG(void);
void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum);
void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(int width, int height);
// This stuff is put here so MD2's can use them // This stuff is put here so MD2's can use them
UINT32 HWR_Lighting(INT32 light, UINT32 color, UINT32 fadecolor, boolean fogblockpoly, boolean plane); UINT32 HWR_Lighting(INT32 light, UINT32 color, UINT32 fadecolor, boolean fogblockpoly, boolean plane);

View file

@ -110,6 +110,7 @@ static GLint viewport[4];
static GLuint screentexture = 60000; static GLuint screentexture = 60000;
static GLuint startScreenWipe = 60001; static GLuint startScreenWipe = 60001;
static GLuint endScreenWipe = 60002; static GLuint endScreenWipe = 60002;
static GLuint finalScreenTexture = 60003;
#if 0 #if 0
GLuint screentexture = FIRST_TEX_AVAIL; GLuint screentexture = FIRST_TEX_AVAIL;
#endif #endif
@ -269,8 +270,8 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#endif #endif
#ifndef MINI_GL_COMPATIBILITY #ifndef MINI_GL_COMPATIBILITY
/* 1.3 functions for multitexturing */ /* 1.3 functions for multitexturing */
#define pglActiveTexture, glActiveTexture; #define pglActiveTexture glActiveTexture
#define pglMultiTexCoord2f, glMultiTexCoord2f; #define pglMultiTexCoord2f glMultiTexCoord2f
#endif #endif
#else //!STATIC_OPENGL #else //!STATIC_OPENGL
@ -520,13 +521,44 @@ boolean SetupGLfunc(void)
// This has to be done after the context is created so the version number can be obtained // This has to be done after the context is created so the version number can be obtained
boolean SetupGLFunc13(void) boolean SetupGLFunc13(void)
{ {
const GLubyte *version = pglGetString(GL_VERSION);
int glmajor, glminor;
gl13 = false;
#ifdef MINI_GL_COMPATIBILITY #ifdef MINI_GL_COMPATIBILITY
return false; return false;
#else #else
#ifdef STATIC_OPENGL #ifdef STATIC_OPENGL
gl13 = true; gl13 = true;
#else #else
if (isExtAvailable("GL_ARB_multitexture", gl_extensions))
// Parse the GL version
if (version != NULL)
{
if (sscanf((const char*)version, "%d.%d", &glmajor, &glminor) == 2)
{
// Look, we gotta prepare for the inevitable arrival of GL 2.0 code...
switch (glmajor)
{
case 1:
if (glminor == 3) gl13 = true;
break;
case 2:
case 3:
case 4:
gl13 = true;
default:
break;
}
}
}
if (gl13)
{
pglActiveTexture = GetGLFunc("glActiveTexture");
pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2f");
}
else if (isExtAvailable("GL_ARB_multitexture", gl_extensions))
{ {
// Get the functions // Get the functions
pglActiveTexture = GetGLFunc("glActiveTextureARB"); pglActiveTexture = GetGLFunc("glActiveTextureARB");
@ -2245,6 +2277,7 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
pglActiveTexture(GL_TEXTURE0); pglActiveTexture(GL_TEXTURE0);
pglEnable(GL_TEXTURE_2D); pglEnable(GL_TEXTURE_2D);
pglBindTexture(GL_TEXTURE_2D, endScreenWipe); pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
pglActiveTexture(GL_TEXTURE1); pglActiveTexture(GL_TEXTURE1);
pglEnable(GL_TEXTURE_2D); pglEnable(GL_TEXTURE_2D);
@ -2339,4 +2372,77 @@ EXPORT void HWRAPI(MakeScreenTexture) (void)
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
} }
EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
{
INT32 texsize = 2048;
// Use a power of two texture, dammit
if(screen_width <= 512)
texsize = 512;
else if(screen_width <= 1024)
texsize = 1024;
// Create screen texture
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
#ifdef KOS_GL_COMPATIBILITY
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_FILTER_NONE);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_FILTER_NONE);
#else
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#endif
Clamp2D(GL_TEXTURE_WRAP_S);
Clamp2D(GL_TEXTURE_WRAP_T);
#ifndef KOS_GL_COMPATIBILITY
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0);
#endif
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
}
EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
{
float xfix, yfix;
INT32 texsize = 2048;
if(screen_width <= 1024)
texsize = 1024;
if(screen_width <= 512)
texsize = 512;
xfix = 1/((float)(texsize)/((float)((screen_width))));
yfix = 1/((float)(texsize)/((float)((screen_height))));
//pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
pglViewport(0, 0, width, height);
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
pglBegin(GL_QUADS);
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// Bottom left
pglTexCoord2f(0.0f, 0.0f);
pglVertex3f(-1, -1, 1.0f);
// Top left
pglTexCoord2f(0.0f, yfix);
pglVertex3f(-1, 1, 1.0f);
// Top right
pglTexCoord2f(xfix, yfix);
pglVertex3f(1, 1, 1.0f);
// Bottom right
pglTexCoord2f(xfix, 0.0f);
pglVertex3f(1, -1, 1.0f);
pglEnd();
SetModelView(screen_width, screen_height);
SetStates();
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
}
#endif //HWRENDER #endif //HWRENDER

View file

@ -105,6 +105,8 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DoScreenWipe); GETFUNC(DoScreenWipe);
GETFUNC(DrawIntermissionBG); GETFUNC(DrawIntermissionBG);
GETFUNC(MakeScreenTexture); GETFUNC(MakeScreenTexture);
GETFUNC(MakeScreenFinalTexture);
GETFUNC(DrawScreenFinalTexture);
#else //HWRENDER #else //HWRENDER
if (0 == strcmp("FinishUpdate", funcName)) if (0 == strcmp("FinishUpdate", funcName))
return funcPointer; //&FinishUpdate; return funcPointer; //&FinishUpdate;

View file

@ -301,37 +301,38 @@ SDL_bool framebuffer = SDL_FALSE;
UINT8 keyboard_started = false; UINT8 keyboard_started = false;
#if 0 FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
static void signal_handler(INT32 num)
{ {
//static char msg[] = "oh no! back to reality!\r\n"; //static char msg[] = "oh no! back to reality!\r\n";
char * sigmsg; const char * sigmsg;
char sigdef[32]; char sigdef[32];
D_QuitNetGame(); // Fix server freezes
switch (num) switch (num)
{ {
case SIGINT: case SIGINT:
sigmsg = "interrupt"; sigmsg = "SIGINT - interrupted";
break; break;
case SIGILL: case SIGILL:
sigmsg = "illegal instruction - invalid function image"; sigmsg = "SIGILL - illegal instruction - invalid function image";
break; break;
case SIGFPE: case SIGFPE:
sigmsg = "floating point exception"; sigmsg = "SIGFPE - floating point exception";
break; break;
case SIGSEGV: case SIGSEGV:
sigmsg = "segment violation"; sigmsg = "SIGSEGV - segment violation";
break; break;
case SIGTERM: case SIGTERM:
sigmsg = "Software termination signal from kill"; sigmsg = "SIGTERM - Software termination signal from kill";
break; break;
#if !(defined (__unix_) || defined (UNIXCOMMON)) #if !(defined (__unix_) || defined (UNIXCOMMON))
case SIGBREAK: case SIGBREAK:
sigmsg = "Ctrl-Break sequence"; sigmsg = "SIGBREAK - Ctrl-Break sequence";
break; break;
#endif #endif
case SIGABRT: case SIGABRT:
sigmsg = "abnormal termination triggered by abort call"; sigmsg = "SIGABRT - abnormal termination triggered by abort call";
break; break;
default: default:
sprintf(sigdef,"signal number %d", num); sprintf(sigdef,"signal number %d", num);
@ -339,13 +340,17 @@ static void signal_handler(INT32 num)
} }
I_OutputMsg("signal_handler() error: %s\n", sigmsg); I_OutputMsg("signal_handler() error: %s\n", sigmsg);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Signal caught",
sigmsg, NULL);
I_ShutdownSystem();
signal(num, SIG_DFL); //default signal action signal(num, SIG_DFL); //default signal action
raise(num); raise(num);
I_Quit(); I_Quit();
} }
#endif
#if defined (NDEBUG) && !defined (DC) && !defined (_WIN32_WCE) #if !defined (DC)
FUNCNORETURN static ATTRNORETURN void quit_handler(int num) FUNCNORETURN static ATTRNORETURN void quit_handler(int num)
{ {
signal(num, SIG_DFL); //default signal action signal(num, SIG_DFL); //default signal action
@ -737,21 +742,21 @@ static inline void I_ShutdownConsole(void){}
// //
void I_StartupKeyboard (void) void I_StartupKeyboard (void)
{ {
#if defined (NDEBUG) && !defined (DC) #if !defined (DC)
#ifdef SIGILL #ifdef SIGILL
// signal(SIGILL , signal_handler); signal(SIGILL , signal_handler);
#endif #endif
#ifdef SIGINT #ifdef SIGINT
signal(SIGINT , quit_handler); signal(SIGINT , quit_handler);
#endif #endif
#ifdef SIGSEGV #ifdef SIGSEGV
// signal(SIGSEGV , signal_handler); signal(SIGSEGV , signal_handler);
#endif #endif
#ifdef SIGBREAK #ifdef SIGBREAK
signal(SIGBREAK , quit_handler); signal(SIGBREAK , quit_handler);
#endif #endif
#ifdef SIGABRT #ifdef SIGABRT
// signal(SIGABRT , signal_handler); signal(SIGABRT , signal_handler);
#endif #endif
#ifdef SIGTERM #ifdef SIGTERM
signal(SIGTERM , quit_handler); signal(SIGTERM , quit_handler);

View file

@ -124,8 +124,8 @@ static SDL_Color localPalette[256];
static SDL_Rect **modeList = NULL; static SDL_Rect **modeList = NULL;
static Uint8 BitsPerPixel = 16; static Uint8 BitsPerPixel = 16;
#endif #endif
static Uint16 realwidth = BASEVIDWIDTH; Uint16 realwidth = BASEVIDWIDTH;
static Uint16 realheight = BASEVIDHEIGHT; Uint16 realheight = BASEVIDHEIGHT;
static const Uint32 surfaceFlagsW = 0/*|SDL_RESIZABLE*/; static const Uint32 surfaceFlagsW = 0/*|SDL_RESIZABLE*/;
static const Uint32 surfaceFlagsF = 0; static const Uint32 surfaceFlagsF = 0;
static SDL_bool mousegrabok = SDL_TRUE; static SDL_bool mousegrabok = SDL_TRUE;
@ -174,7 +174,6 @@ static void Impl_SetWindowIcon(void);
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
{ {
static SDL_bool wasfullscreen = SDL_FALSE; static SDL_bool wasfullscreen = SDL_FALSE;
static SDL_bool glfallbackresolution = SDL_FALSE;
Uint32 rmask; Uint32 rmask;
Uint32 gmask; Uint32 gmask;
Uint32 bmask; Uint32 bmask;
@ -195,16 +194,15 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
else if (!fullscreen && wasfullscreen) else if (!fullscreen && wasfullscreen)
{ {
wasfullscreen = SDL_FALSE; wasfullscreen = SDL_FALSE;
glfallbackresolution = SDL_FALSE;
SDL_SetWindowFullscreen(window, 0); SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowSize(window, width, height); SDL_SetWindowSize(window, width, height);
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1));
} }
else if (!wasfullscreen) else if (!wasfullscreen)
{ {
// Reposition window only in windowed mode // Reposition window only in windowed mode
SDL_SetWindowSize(window, width, height); SDL_SetWindowSize(window, width, height);
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1));
} }
} }
else else
@ -221,26 +219,6 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
if (rendermode == render_opengl) if (rendermode == render_opengl)
{ {
int sdlw, sdlh;
SDL_GetWindowSize(window, &sdlw, &sdlh);
// Logical fullscreen is not implemented yet for OpenGL, so...
// Special case handling
if (glfallbackresolution == SDL_FALSE && fullscreen && width != sdlw && height != sdlh)
{
if (VID_GetModeForSize(sdlw, sdlh) != -1)
{
wasfullscreen = SDL_TRUE;
VID_SetMode(VID_GetModeForSize(sdlw, sdlh));
return;
}
else
{
wasfullscreen = SDL_TRUE;
glfallbackresolution = SDL_TRUE;
VID_SetMode(-1);
return;
}
}
OglSdlSurface(vid.width, vid.height); OglSdlSurface(vid.width, vid.height);
} }
@ -278,221 +256,150 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
} }
} }
// static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
// Translates the SDL key into SRB2 key
//
static INT32 SDLatekey(SDL_Keycode sym)
{ {
INT32 rc = sym + 0x80; if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
switch (sym)
{ {
case SDLK_LEFT: // get lowercase ASCII
rc = KEY_LEFTARROW; return code - SDL_SCANCODE_A + 'a';
break; }
case SDLK_RIGHT: if (code >= SDL_SCANCODE_1 && code <= SDL_SCANCODE_9)
rc = KEY_RIGHTARROW; {
break; return code - SDL_SCANCODE_1 + '1';
case SDLK_DOWN: }
rc = KEY_DOWNARROW; else if (code == SDL_SCANCODE_0)
break; {
case SDLK_UP: return '0';
rc = KEY_UPARROW; }
break; if (code >= SDL_SCANCODE_F1 && code <= SDL_SCANCODE_F12)
{
return KEY_F1 + (code - SDL_SCANCODE_F1);
}
switch (code)
{
case SDL_SCANCODE_KP_0:
return KEY_KEYPAD0;
case SDL_SCANCODE_KP_1:
return KEY_KEYPAD1;
case SDL_SCANCODE_KP_2:
return KEY_KEYPAD2;
case SDL_SCANCODE_KP_3:
return KEY_KEYPAD3;
case SDL_SCANCODE_KP_4:
return KEY_KEYPAD4;
case SDL_SCANCODE_KP_5:
return KEY_KEYPAD5;
case SDL_SCANCODE_KP_6:
return KEY_KEYPAD6;
case SDL_SCANCODE_KP_7:
return KEY_KEYPAD7;
case SDL_SCANCODE_KP_8:
return KEY_KEYPAD8;
case SDL_SCANCODE_KP_9:
return KEY_KEYPAD9;
case SDLK_ESCAPE: case SDL_SCANCODE_RETURN:
rc = KEY_ESCAPE; return KEY_ENTER;
break; case SDL_SCANCODE_ESCAPE:
case SDLK_SPACE: return KEY_ESCAPE;
rc = KEY_SPACE; case SDL_SCANCODE_BACKSPACE:
break; return KEY_BACKSPACE;
case SDLK_RETURN: case SDL_SCANCODE_TAB:
case SDLK_KP_ENTER: return KEY_TAB;
rc = KEY_ENTER; case SDL_SCANCODE_SPACE:
break; return KEY_SPACE;
case SDLK_TAB: case SDL_SCANCODE_MINUS:
rc = KEY_TAB; return KEY_MINUS;
break; case SDL_SCANCODE_EQUALS:
case SDLK_F1: return KEY_EQUALS;
rc = KEY_F1; case SDL_SCANCODE_LEFTBRACKET:
break; return '[';
case SDLK_F2: case SDL_SCANCODE_RIGHTBRACKET:
rc = KEY_F2; return ']';
break; case SDL_SCANCODE_BACKSLASH:
case SDLK_F3: return '\\';
rc = KEY_F3; case SDL_SCANCODE_NONUSHASH:
break; return '#';
case SDLK_F4: case SDL_SCANCODE_SEMICOLON:
rc = KEY_F4; return ';';
break; case SDL_SCANCODE_APOSTROPHE:
case SDLK_F5: return '\'';
rc = KEY_F5; case SDL_SCANCODE_GRAVE:
break; return '`';
case SDLK_F6: case SDL_SCANCODE_COMMA:
rc = KEY_F6; return ',';
break; case SDL_SCANCODE_PERIOD:
case SDLK_F7: return '.';
rc = KEY_F7; case SDL_SCANCODE_SLASH:
break; return '/';
case SDLK_F8: case SDL_SCANCODE_CAPSLOCK:
rc = KEY_F8; return KEY_CAPSLOCK;
break; case SDL_SCANCODE_PRINTSCREEN:
case SDLK_F9: return 0; // undefined?
rc = KEY_F9; case SDL_SCANCODE_SCROLLLOCK:
break; return KEY_SCROLLLOCK;
case SDLK_F10: case SDL_SCANCODE_PAUSE:
rc = KEY_F10; return KEY_PAUSE;
break; case SDL_SCANCODE_INSERT:
case SDLK_F11: return KEY_INS;
rc = KEY_F11; case SDL_SCANCODE_HOME:
break; return KEY_HOME;
case SDLK_F12: case SDL_SCANCODE_PAGEUP:
rc = KEY_F12; return KEY_PGUP;
break; case SDL_SCANCODE_DELETE:
return KEY_DEL;
case SDLK_BACKSPACE: case SDL_SCANCODE_END:
rc = KEY_BACKSPACE; return KEY_END;
break; case SDL_SCANCODE_PAGEDOWN:
case SDLK_DELETE: return KEY_PGDN;
rc = KEY_DEL; case SDL_SCANCODE_RIGHT:
break; return KEY_RIGHTARROW;
case SDL_SCANCODE_LEFT:
case SDLK_KP_EQUALS: //Alam & Logan: WTF? Mac KB haves one! XD return KEY_LEFTARROW;
case SDLK_PAUSE: case SDL_SCANCODE_DOWN:
rc = KEY_PAUSE; return KEY_DOWNARROW;
break; case SDL_SCANCODE_UP:
return KEY_UPARROW;
case SDLK_EQUALS: case SDL_SCANCODE_NUMLOCKCLEAR:
case SDLK_PLUS: return KEY_NUMLOCK;
rc = KEY_EQUALS; case SDL_SCANCODE_KP_DIVIDE:
break; return KEY_KPADSLASH;
case SDL_SCANCODE_KP_MULTIPLY:
case SDLK_MINUS: return '*'; // undefined?
rc = KEY_MINUS; case SDL_SCANCODE_KP_MINUS:
break; return KEY_MINUSPAD;
case SDL_SCANCODE_KP_PLUS:
case SDLK_LSHIFT: return KEY_PLUSPAD;
rc = KEY_LSHIFT; case SDL_SCANCODE_KP_ENTER:
break; return KEY_ENTER;
case SDL_SCANCODE_KP_PERIOD:
case SDLK_RSHIFT: return KEY_KPADDEL;
rc = KEY_RSHIFT; case SDL_SCANCODE_NONUSBACKSLASH:
break; return '\\';
case SDLK_CAPSLOCK:
rc = KEY_CAPSLOCK;
break;
case SDLK_LCTRL:
rc = KEY_LCTRL;
break;
case SDLK_RCTRL:
rc = KEY_RCTRL;
break;
case SDLK_LALT:
rc = KEY_LALT;
break;
case SDLK_RALT:
rc = KEY_RALT;
break;
case SDLK_NUMLOCKCLEAR:
rc = KEY_NUMLOCK;
break;
case SDLK_SCROLLLOCK:
rc = KEY_SCROLLLOCK;
break;
case SDLK_PAGEUP:
rc = KEY_PGUP;
break;
case SDLK_PAGEDOWN:
rc = KEY_PGDN;
break;
case SDLK_END:
rc = KEY_END;
break;
case SDLK_HOME:
rc = KEY_HOME;
break;
case SDLK_INSERT:
rc = KEY_INS;
break;
case SDLK_KP_0:
rc = KEY_KEYPAD0;
break;
case SDLK_KP_1:
rc = KEY_KEYPAD1;
break;
case SDLK_KP_2:
rc = KEY_KEYPAD2;
break;
case SDLK_KP_3:
rc = KEY_KEYPAD3;
break;
case SDLK_KP_4:
rc = KEY_KEYPAD4;
break;
case SDLK_KP_5:
rc = KEY_KEYPAD5;
break;
case SDLK_KP_6:
rc = KEY_KEYPAD6;
break;
case SDLK_KP_7:
rc = KEY_KEYPAD7;
break;
case SDLK_KP_8:
rc = KEY_KEYPAD8;
break;
case SDLK_KP_9:
rc = KEY_KEYPAD9;
break;
case SDLK_KP_PERIOD:
rc = KEY_KPADDEL;
break;
case SDLK_KP_DIVIDE:
rc = KEY_KPADSLASH;
break;
case SDLK_KP_MULTIPLY:
rc = '*';
break;
case SDLK_KP_MINUS:
rc = KEY_MINUSPAD;
break;
case SDLK_KP_PLUS:
rc = KEY_PLUSPAD;
break;
case SDLK_LMETA:
rc = KEY_LEFTWIN;
break;
case SDLK_RMETA:
rc = KEY_RIGHTWIN;
break;
case SDLK_MENU:
rc = KEY_MENU;
break;
case SDL_SCANCODE_LSHIFT:
return KEY_LSHIFT;
case SDL_SCANCODE_RSHIFT:
return KEY_RSHIFT;
case SDL_SCANCODE_LCTRL:
return KEY_LCTRL;
case SDL_SCANCODE_RCTRL:
return KEY_RCTRL;
case SDL_SCANCODE_LALT:
return KEY_LALT;
case SDL_SCANCODE_RALT:
return KEY_RALT;
case SDL_SCANCODE_LGUI:
return KEY_LEFTWIN;
case SDL_SCANCODE_RGUI:
return KEY_RIGHTWIN;
default: default:
if (sym >= SDLK_SPACE && sym <= SDLK_DELETE)
rc = sym - SDLK_SPACE + ' ';
else if (sym >= 'A' && sym <= 'Z')
rc = sym - 'A' + 'a';
else if (sym)
{
I_OutputMsg("Unknown Keycode %i, Name: %s\n",sym, SDL_GetKeyName( sym ));
}
else if (!sym) rc = 0;
break; break;
} }
DBG_Printf("Unknown incoming scancode: %d, represented %c\n",
return rc; code,
SDL_GetKeyName(SDL_GetKeyFromScancode(code)));
return 0;
} }
static void SDLdoUngrabMouse(void) static void SDLdoUngrabMouse(void)
@ -809,7 +716,7 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
{ {
return; return;
} }
event.data1 = SDLatekey(evt.keysym.sym); event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode);
if (event.data1) D_PostEvent(&event); if (event.data1) D_PostEvent(&event);
} }
@ -818,6 +725,8 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
event_t event; event_t event;
int wwidth, wheight; int wwidth, wheight;
if (USE_MOUSEINPUT)
{
SDL_GetWindowSize(window, &wwidth, &wheight); SDL_GetWindowSize(window, &wwidth, &wheight);
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window)) if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
@ -832,8 +741,8 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
} }
else else
{ {
event.data2 = (evt.xrel) * (wwidth / realwidth); event.data2 = (INT32)lround((evt.xrel) * ((float)wwidth / (float)realwidth));
event.data3 = -evt.yrel * (wheight / realheight); event.data3 = (INT32)lround(-evt.yrel * ((float)wheight / (float)realheight));
} }
event.type = ev_mouse; event.type = ev_mouse;
@ -841,9 +750,11 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window)
{ {
D_PostEvent(&event); D_PostEvent(&event);
SDL_SetWindowGrab(window, SDL_TRUE);
HalfWarpMouse(wwidth, wheight); HalfWarpMouse(wwidth, wheight);
} }
} }
}
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
{ {
@ -869,8 +780,10 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
event.data1 = KEY_MOUSE1+1; event.data1 = KEY_MOUSE1+1;
else if (evt.button == SDL_BUTTON_LEFT) else if (evt.button == SDL_BUTTON_LEFT)
event.data1 = KEY_MOUSE1; event.data1 = KEY_MOUSE1;
else if (evt.button <= MOUSEBUTTONS) else if (evt.button == SDL_BUTTON_X1)
event.data1 = KEY_MOUSE1 + evt.which - SDL_BUTTON_LEFT; event.data1 = KEY_MOUSE1+3;
else if (evt.button == SDL_BUTTON_X2)
event.data1 = KEY_MOUSE1+4;
if (event.type == ev_keyup || event.type == ev_keydown) if (event.type == ev_keyup || event.type == ev_keydown)
{ {
D_PostEvent(&event); D_PostEvent(&event);
@ -912,7 +825,7 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev); joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
joyid[1] = SDL_JoystickInstanceID(JoyInfo.dev); joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
evt.axis++; evt.axis++;
event.data1 = event.data2 = event.data3 = INT32_MAX; event.data1 = event.data2 = event.data3 = INT32_MAX;
@ -951,7 +864,7 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev); joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
joyid[1] = SDL_JoystickInstanceID(JoyInfo.dev); joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
if (evt.which == joyid[0]) if (evt.which == joyid[0])
{ {
@ -984,6 +897,9 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
void I_GetEvent(void) void I_GetEvent(void)
{ {
SDL_Event evt; SDL_Event evt;
// We only want the first motion event,
// otherwise we'll end up catching the warp back to center.
int mouseMotionOnce = 0;
if (!graphics_started) if (!graphics_started)
{ {
@ -1002,7 +918,8 @@ void I_GetEvent(void)
Impl_HandleKeyboardEvent(evt.key, evt.type); Impl_HandleKeyboardEvent(evt.key, evt.type);
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
Impl_HandleMouseMotionEvent(evt.motion); if (!mouseMotionOnce) Impl_HandleMouseMotionEvent(evt.motion);
mouseMotionOnce = 1;
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
@ -1841,6 +1758,8 @@ void I_StartupGraphics(void)
HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL); HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL);
HWD.pfnDrawIntermissionBG=hwSym("DrawIntermissionBG",NULL); HWD.pfnDrawIntermissionBG=hwSym("DrawIntermissionBG",NULL);
HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL); HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL);
HWD.pfnMakeScreenFinalTexture=hwSym("MakeScreenFinalTexture",NULL);
HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL);
// check gl renderer lib // check gl renderer lib
if (HWD.pfnGetRenderVersion() != VERSION) if (HWD.pfnGetRenderVersion() != VERSION)
I_Error("%s", M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n")); I_Error("%s", M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n"));

View file

@ -201,13 +201,22 @@ boolean OglSdlSurface(INT32 w, INT32 h)
void OglSdlFinishUpdate(boolean waitvbl) void OglSdlFinishUpdate(boolean waitvbl)
{ {
static boolean oldwaitvbl = false; static boolean oldwaitvbl = false;
int sdlw, sdlh;
if (oldwaitvbl != waitvbl) if (oldwaitvbl != waitvbl)
{ {
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0); SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
} }
oldwaitvbl = waitvbl; oldwaitvbl = waitvbl;
SDL_GetWindowSize(window, &sdlw, &sdlh);
HWR_MakeScreenFinalTexture();
HWR_DrawScreenFinalTexture(sdlw, sdlh);
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
SetModelView(realwidth, realheight);
SetStates();
} }
EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma) EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)

View file

@ -27,6 +27,8 @@ void OglSdlFinishUpdate(boolean vidwait);
extern SDL_Window *window; extern SDL_Window *window;
extern SDL_Renderer *renderer; extern SDL_Renderer *renderer;
extern SDL_GLContext sdlglcontext; extern SDL_GLContext sdlglcontext;
extern Uint16 realwidth;
extern Uint16 realheight;
#ifdef _CREATE_DLL_ #ifdef _CREATE_DLL_
EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma); EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma);

View file

@ -105,6 +105,8 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DoScreenWipe); GETFUNC(DoScreenWipe);
GETFUNC(DrawIntermissionBG); GETFUNC(DrawIntermissionBG);
GETFUNC(MakeScreenTexture); GETFUNC(MakeScreenTexture);
GETFUNC(MakeScreenFinalTexture);
GETFUNC(DrawScreenFinalTexture);
#else //HWRENDER #else //HWRENDER
if (0 == strcmp("FinishUpdate", funcName)) if (0 == strcmp("FinishUpdate", funcName))
return funcPointer; //&FinishUpdate; return funcPointer; //&FinishUpdate;

View file

@ -122,6 +122,8 @@ static loadfunc_t hwdFuncTable[] = {
{"DoScreenWipe@4", &hwdriver.pfnDoScreenWipe}, {"DoScreenWipe@4", &hwdriver.pfnDoScreenWipe},
{"DrawIntermissionBG@0",&hwdriver.pfnDrawIntermissionBG}, {"DrawIntermissionBG@0",&hwdriver.pfnDrawIntermissionBG},
{"MakeScreenTexture@0", &hwdriver.pfnMakeScreenTexture}, {"MakeScreenTexture@0", &hwdriver.pfnMakeScreenTexture},
{"MakeScreenFinalTexture@0", &hwdriver.pfnMakeScreenFinalTexture},
{"DrawScreenFinalTexture@8", &hwdriver.pfnDrawScreenFinalTexture},
#else #else
{"Init", &hwdriver.pfnInit}, {"Init", &hwdriver.pfnInit},
{"Shutdown", &hwdriver.pfnShutdown}, {"Shutdown", &hwdriver.pfnShutdown},
@ -150,6 +152,8 @@ static loadfunc_t hwdFuncTable[] = {
{"DoScreenWipe", &hwdriver.pfnDoScreenWipe}, {"DoScreenWipe", &hwdriver.pfnDoScreenWipe},
{"DrawIntermissionBG", &hwdriver.pfnDrawIntermissionBG}, {"DrawIntermissionBG", &hwdriver.pfnDrawIntermissionBG},
{"MakeScreenTexture", &hwdriver.pfnMakeScreenTexture}, {"MakeScreenTexture", &hwdriver.pfnMakeScreenTexture},
{"MakeScreenFinalTexture", &hwdriver.pfnMakeScreenFinalTexture},
{"DrawScreenFinalTexture", &hwdriver.pfnDrawScreenFinalTexture},
#endif #endif
{NULL,NULL} {NULL,NULL}
}; };