remove unused functions

This commit is contained in:
Denis Pauk 2018-08-15 22:49:01 +03:00
parent 2812ef30dd
commit 01ca7db6f4
3 changed files with 3 additions and 182 deletions

View file

@ -1578,70 +1578,6 @@ static SDL_Surface *surface = NULL;
static SDL_Texture *texture = NULL;
static SDL_Renderer *renderer = NULL;
/*
* Sets the window icon
*/
static void
SetSDLIcon()
{
/* The 64x64 32bit window icon */
#include "../../vid/icon/q2icon64.h"
/* these masks are needed to tell SDL_CreateRGBSurface(From)
to assume the data it gets is byte-wise RGB(A) data */
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int shift = (q2icon64.bytes_per_pixel == 3) ? 8 : 0;
rmask = 0xff000000 >> shift;
gmask = 0x00ff0000 >> shift;
bmask = 0x0000ff00 >> shift;
amask = 0x000000ff >> shift;
#else /* little endian, like x86 */
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = (q2icon64.bytes_per_pixel == 3) ? 0 : 0xff000000;
#endif
SDL_Surface* icon = SDL_CreateRGBSurfaceFrom((void*)q2icon64.pixel_data, q2icon64.width,
q2icon64.height, q2icon64.bytes_per_pixel*8, q2icon64.bytes_per_pixel*q2icon64.width,
rmask, gmask, bmask, amask);
SDL_SetWindowIcon(window, icon);
SDL_FreeSurface(icon);
}
static int
IsFullscreen()
{
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP) {
return 1;
} else if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
return 2;
} else {
return 0;
}
}
static qboolean
GetWindowSize(int* w, int* h)
{
if(window == NULL || w == NULL || h == NULL)
return false;
SDL_DisplayMode m;
if(SDL_GetWindowDisplayMode(window, &m) != 0)
{
Com_Printf("Can't get Displaymode: %s\n", SDL_GetError());
return false;
}
*w = m.w;
*h = m.h;
return true;
}
static int
RE_InitContext(void *win)
{
@ -1692,17 +1628,6 @@ RE_InitContext(void *win)
return true;
}
static qboolean
CreateSDLWindow(int flags, int w, int h)
{
int windowPos = SDL_WINDOWPOS_UNDEFINED;
// TODO: support fullscreen on different displays with SDL_WINDOWPOS_UNDEFINED_DISPLAY(displaynum)
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos, w, h, flags);
return window != NULL;
}
static void
RE_ShutdownContext(void)
{
@ -1813,13 +1738,6 @@ RE_ShutdownContext(void)
SDL_DestroyRenderer(renderer);
}
renderer = NULL;
/* Is the surface used? */
/*if (window)
{
SDL_DestroyWindow(window);
}
window = NULL;*/
}
/*
@ -1828,89 +1746,6 @@ point math used in R_ScanEdges() overflows at width 2048 !!
*/
char shift_size;
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem. In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean
SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
{
int flags;
int curWidth, curHeight;
int width = *pwidth;
int height = *pheight;
unsigned int fs_flag = 0;
if (fullscreen == 1) {
fs_flag = SDL_WINDOW_FULLSCREEN_DESKTOP;
} else if (fullscreen == 2) {
fs_flag = SDL_WINDOW_FULLSCREEN;
}
if (GetWindowSize(&curWidth, &curHeight) && (curWidth == width) && (curHeight == height))
{
/* If we want fullscreen, but aren't */
if (fullscreen != IsFullscreen())
{
SDL_SetWindowFullscreen(window, fs_flag);
ri.Cvar_SetValue("vid_fullscreen", fullscreen);
}
/* Are we now? */
if (fullscreen == IsFullscreen())
{
return true;
}
}
RE_ShutdownContext();
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (vid.width, vid.height);
flags = RE_PrepareForWindow();
if (fs_flag)
{
flags |= fs_flag;
}
while (1)
{
if (!CreateSDLWindow(flags, width, height))
{
Sys_Error("(SOFTSDL) SDL SetVideoMode failed: %s\n", SDL_GetError());
return false;
}
else
{
break;
}
}
if(!RE_InitContext(window))
{
// InitContext() should have logged an error
return false;
}
/* Note: window title is now set in re.InitContext() to include renderer name */
/* Set the window icon - For SDL2, this must be done after creating the window */
SetSDLIcon();
/* No cursor */
SDL_ShowCursor(0);
return true;
}
static void
RE_CopyFrame (Uint32 * pixels, int pitch)
{

View file

@ -226,7 +226,6 @@ typedef struct
qboolean (IMPORT *Vid_GetModeInfo)(int *width, int *height, int mode);
void (IMPORT *Vid_MenuInit)( void );
void (IMPORT *Vid_NewWindow)( int width, int height );
// called with image data of width*height pixel which comp bytes per pixel (must be 3 or 4 for RGB or RGBA)
// expects the pixels data to be row-wise, starting at top left
void (IMPORT *Vid_WriteScreenshot)( int width, int height, int comp, const void* data );

View file

@ -42,7 +42,7 @@ compress_for_stbiw(unsigned char *data, int data_len, int *out_len, int quality)
{
uLongf bufSize = compressBound(data_len);
unsigned char* buf = malloc(bufSize);
if (buf == NULL)
{
return NULL;
@ -192,7 +192,7 @@ void VID_WriteScreenshot(int width, int height, int comp, const void* data)
{
Com_Printf("SCR_ScreenShot_f: Couldn't write %s\n", picname);
}
}
}
// --------
@ -309,18 +309,6 @@ VID_Restart_f(void)
vid_fullscreen->modified = true;
}
/*
* FIXME: This is only used by the softrenderer. The software
* renderer should be ported to the API provided by refresh.c
* and this call removed.
*/
void
VID_NewWindow(int width, int height)
{
viddef.width = width;
viddef.height = height;
}
/*
* Shuts the renderer down and unloads it.
*/
@ -402,7 +390,6 @@ VID_LoadRenderer(void)
ri.Sys_Error = Com_Error;
ri.Vid_GetModeInfo = VID_GetModeInfo;
ri.Vid_MenuInit = VID_MenuInit;
ri.Vid_NewWindow = VID_NewWindow;
ri.Vid_WriteScreenshot = VID_WriteScreenshot;
// Exchange our export struct with the renderers import struct.
@ -440,7 +427,7 @@ VID_LoadRenderer(void)
return true;
}
/*
* Checks if a renderer changes was requested and executes it.
* Inclusive fallback through all renderers. :)