mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-22 04:21:23 +00:00
sdl2: it works
This commit is contained in:
parent
cb55317533
commit
63e47c1f0e
1 changed files with 73 additions and 10 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
// SDL2 stub macro
|
// SDL2 stub macro
|
||||||
#define SDL2STUB(name) CONS_Printf("SDL2: stubbed: %s\n", __func__)
|
#define SDL2STUB(name) CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(default : 4214 4244)
|
#pragma warning(default : 4214 4244)
|
||||||
|
@ -189,18 +189,42 @@ static void SDLSetMode(INT32 width, INT32 height, INT32 bpp, Uint32 flags)
|
||||||
realwidth = (Uint16)width;
|
realwidth = (Uint16)width;
|
||||||
realheight = (Uint16)height;
|
realheight = (Uint16)height;
|
||||||
#endif
|
#endif
|
||||||
if (window == NULL)
|
|
||||||
{
|
int rmask;
|
||||||
window = SDL_CreateWindow("Sonic Robo Blast 2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
int gmask;
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
int bmask;
|
||||||
}
|
int amask;
|
||||||
|
|
||||||
|
// Set up Texture
|
||||||
realwidth = width;
|
realwidth = width;
|
||||||
realheight = height;
|
realheight = height;
|
||||||
if (texture != NULL)
|
if (texture != NULL)
|
||||||
{
|
{
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
}
|
}
|
||||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||||
|
|
||||||
|
// Set up SW surface
|
||||||
|
if (vidSurface != NULL)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface(vidSurface);
|
||||||
|
}
|
||||||
|
#ifdef SDL_BIG_ENDIAN
|
||||||
|
rmask = 0xFF000000;
|
||||||
|
gmask = 0x00FF0000;
|
||||||
|
bmask = 0x0000FF00;
|
||||||
|
amask = 0x000000FF;
|
||||||
|
#else
|
||||||
|
amask = 0xFF000000;
|
||||||
|
bmask = 0x00FF0000;
|
||||||
|
gmask = 0x0000FF00;
|
||||||
|
rmask = 0x000000FF;
|
||||||
|
#endif
|
||||||
|
vidSurface = SDL_CreateRGBSurface(0, width, height, 32, rmask, gmask, bmask, amask);
|
||||||
|
|
||||||
|
SDL_SetWindowSize(window, width, height);
|
||||||
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
|
|
||||||
SDL2STUB();
|
SDL2STUB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,6 +731,11 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
void I_GetEvent(void)
|
void I_GetEvent(void)
|
||||||
{
|
{
|
||||||
SDL2STUB();
|
SDL2STUB();
|
||||||
|
SDL_Event evt;
|
||||||
|
|
||||||
|
while (SDL_PollEvent(&evt))
|
||||||
|
{
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
SDL_Event inputEvent;
|
SDL_Event inputEvent;
|
||||||
static SDL_bool sdlquit = SDL_FALSE; //Alam: once, just once
|
static SDL_bool sdlquit = SDL_FALSE; //Alam: once, just once
|
||||||
|
@ -1385,8 +1414,8 @@ static void* SDLGetDirect(void)
|
||||||
|
|
||||||
INT32 VID_SetMode(INT32 modeNum)
|
INT32 VID_SetMode(INT32 modeNum)
|
||||||
{
|
{
|
||||||
SDLSetMode(640, 400, 16, 0);
|
|
||||||
SDL2STUB();
|
SDL2STUB();
|
||||||
|
SDLSetMode(320, 200, 16, 0);
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
#if 0
|
#if 0
|
||||||
SDLdoUngrabMouse();
|
SDLdoUngrabMouse();
|
||||||
|
@ -1496,6 +1525,36 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Impl_CreateWindow(void)
|
||||||
|
{
|
||||||
|
if (window != NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window = SDL_CreateWindow("SRB2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, BASEVIDWIDTH, BASEVIDHEIGHT, 0);
|
||||||
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Impl_SetWindowName(const char *title)
|
||||||
|
{
|
||||||
|
if (window != NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL2STUB();
|
||||||
|
SDL_SetWindowTitle(window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Impl_SetWindowIcon()
|
||||||
|
{
|
||||||
|
if (window == NULL || icoSurface == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL2STUB();
|
||||||
|
SDL_SetWindowIcon(window, icoSurface);
|
||||||
|
}
|
||||||
|
|
||||||
void I_StartupGraphics(void)
|
void I_StartupGraphics(void)
|
||||||
{
|
{
|
||||||
static char SDLNOMOUSE[] = "SDL_NOMOUSE=1";
|
static char SDLNOMOUSE[] = "SDL_NOMOUSE=1";
|
||||||
|
@ -1553,6 +1612,10 @@ void I_StartupGraphics(void)
|
||||||
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2);
|
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2);
|
||||||
SDLESSet();
|
SDLESSet();
|
||||||
VID_Command_ModeList_f();
|
VID_Command_ModeList_f();
|
||||||
|
|
||||||
|
// Create window
|
||||||
|
Impl_CreateWindow();
|
||||||
|
|
||||||
vid.buffer = NULL; // For software mode
|
vid.buffer = NULL; // For software mode
|
||||||
vid.width = BASEVIDWIDTH; // Default size for startup
|
vid.width = BASEVIDWIDTH; // Default size for startup
|
||||||
vid.height = BASEVIDHEIGHT; // BitsPerPixel is the SDL interface's
|
vid.height = BASEVIDHEIGHT; // BitsPerPixel is the SDL interface's
|
||||||
|
@ -1566,13 +1629,13 @@ void I_StartupGraphics(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Window title
|
// Window title
|
||||||
//SDL_WM_SetCaption("SRB2: Starting up", "SRB2");
|
Impl_SetWindowName("SRB2: Starting up");
|
||||||
|
|
||||||
// Window icon
|
// Window icon
|
||||||
#ifdef HAVE_IMAGE
|
#ifdef HAVE_IMAGE
|
||||||
//icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm);
|
//icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm);
|
||||||
#endif
|
#endif
|
||||||
//SDL_WM_SetIcon(icoSurface, NULL);
|
Impl_SetWindowIcon();
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (M_CheckParm("-opengl") || rendermode == render_opengl)
|
if (M_CheckParm("-opengl") || rendermode == render_opengl)
|
||||||
|
|
Loading…
Reference in a new issue