mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-16 01:02:03 +00:00
Further cleanup of native OS X backend video part
This commit is contained in:
parent
16965eb78a
commit
613c3293ce
1 changed files with 40 additions and 46 deletions
|
@ -1814,7 +1814,7 @@ bool I_SetCursor(FTexture* cursorpic)
|
||||||
class CocoaVideo : public IVideo
|
class CocoaVideo : public IVideo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CocoaVideo(int dummy);
|
CocoaVideo();
|
||||||
|
|
||||||
virtual EDisplayType GetDisplayType() { return DISPLAY_Both; }
|
virtual EDisplayType GetDisplayType() { return DISPLAY_Both; }
|
||||||
virtual void SetWindowedScale(float scale);
|
virtual void SetWindowedScale(float scale);
|
||||||
|
@ -1978,10 +1978,9 @@ static cycle_t FlipCycles;
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
CocoaVideo::CocoaVideo(int dummy)
|
CocoaVideo::CocoaVideo()
|
||||||
: m_modeIterator(0)
|
: m_modeIterator(0)
|
||||||
{
|
{
|
||||||
ZD_UNUSED(dummy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocoaVideo::StartModeIterator(int bits, bool fs)
|
void CocoaVideo::StartModeIterator(int bits, bool fs)
|
||||||
|
@ -2176,7 +2175,7 @@ void CocoaFrameBuffer::UpdateColors()
|
||||||
GPfx.SetPalette(palette);
|
GPfx.SetPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
PalEntry *CocoaFrameBuffer::GetPalette()
|
PalEntry* CocoaFrameBuffer::GetPalette()
|
||||||
{
|
{
|
||||||
return m_palette;
|
return m_palette;
|
||||||
}
|
}
|
||||||
|
@ -2290,41 +2289,40 @@ ADD_STAT(blit)
|
||||||
IVideo *Video;
|
IVideo *Video;
|
||||||
|
|
||||||
|
|
||||||
void I_ShutdownGraphics ()
|
void I_ShutdownGraphics()
|
||||||
{
|
{
|
||||||
if (screen)
|
if (NULL != screen)
|
||||||
{
|
{
|
||||||
DFrameBuffer *s = screen;
|
screen->ObjectFlags |= OF_YesReallyDelete;
|
||||||
|
delete screen;
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
s->ObjectFlags |= OF_YesReallyDelete;
|
|
||||||
delete s;
|
|
||||||
}
|
}
|
||||||
if (Video)
|
|
||||||
delete Video, Video = NULL;
|
delete Video;
|
||||||
|
Video = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_InitGraphics ()
|
void I_InitGraphics()
|
||||||
{
|
{
|
||||||
UCVarValue val;
|
UCVarValue val;
|
||||||
|
|
||||||
val.Bool = !!Args->CheckParm ("-devparm");
|
val.Bool = !!Args->CheckParm("-devparm");
|
||||||
ticker.SetGenericRepDefault (val, CVAR_Bool);
|
ticker.SetGenericRepDefault(val, CVAR_Bool);
|
||||||
|
|
||||||
Video = new CocoaVideo (0);
|
|
||||||
if (Video == NULL)
|
|
||||||
I_FatalError ("Failed to initialize display");
|
|
||||||
|
|
||||||
|
Video = new CocoaVideo;
|
||||||
atterm (I_ShutdownGraphics);
|
atterm (I_ShutdownGraphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void I_DeleteRenderer()
|
static void I_DeleteRenderer()
|
||||||
{
|
{
|
||||||
if (Renderer != NULL) delete Renderer;
|
delete Renderer;
|
||||||
|
Renderer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_CreateRenderer()
|
void I_CreateRenderer()
|
||||||
{
|
{
|
||||||
if (Renderer == NULL)
|
if (NULL == Renderer)
|
||||||
{
|
{
|
||||||
Renderer = new FSoftwareRenderer;
|
Renderer = new FSoftwareRenderer;
|
||||||
atterm(I_DeleteRenderer);
|
atterm(I_DeleteRenderer);
|
||||||
|
@ -2332,57 +2330,52 @@ void I_CreateRenderer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old)
|
DFrameBuffer* I_SetMode(int &width, int &height, DFrameBuffer* old)
|
||||||
{
|
{
|
||||||
bool fs = false;
|
return Video->CreateFrameBuffer(width, height, fullscreen, old);
|
||||||
switch (Video->GetDisplayType ())
|
|
||||||
{
|
|
||||||
case DISPLAY_WindowOnly:
|
|
||||||
fs = false;
|
|
||||||
break;
|
|
||||||
case DISPLAY_FullscreenOnly:
|
|
||||||
fs = true;
|
|
||||||
break;
|
|
||||||
case DISPLAY_Both:
|
|
||||||
fs = fullscreen;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Video->CreateFrameBuffer (width, height, fs, old);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool I_CheckResolution (int width, int height, int bits)
|
bool I_CheckResolution(const int width, const int height, const int bits)
|
||||||
{
|
{
|
||||||
int twidth, theight;
|
int twidth, theight;
|
||||||
|
|
||||||
Video->StartModeIterator (bits, screen ? screen->IsFullscreen() : fullscreen);
|
Video->StartModeIterator(bits, fullscreen);
|
||||||
while (Video->NextMode (&twidth, &theight, NULL))
|
|
||||||
|
while (Video->NextMode(&twidth, &theight, NULL))
|
||||||
{
|
{
|
||||||
if (width == twidth && height == theight)
|
if (width == twidth && height == theight)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_ClosestResolution (int *width, int *height, int bits)
|
void I_ClosestResolution(int *width, int *height, int bits)
|
||||||
{
|
{
|
||||||
int twidth, theight;
|
int twidth, theight;
|
||||||
int cwidth = 0, cheight = 0;
|
int cwidth = 0, cheight = 0;
|
||||||
int iteration;
|
int iteration;
|
||||||
DWORD closest = 4294967295u;
|
DWORD closest = DWORD(-1);
|
||||||
|
|
||||||
for (iteration = 0; iteration < 2; iteration++)
|
for (iteration = 0; iteration < 2; ++iteration)
|
||||||
{
|
{
|
||||||
Video->StartModeIterator (bits, screen ? screen->IsFullscreen() : fullscreen);
|
Video->StartModeIterator (bits, fullscreen);
|
||||||
|
|
||||||
while (Video->NextMode (&twidth, &theight, NULL))
|
while (Video->NextMode (&twidth, &theight, NULL))
|
||||||
{
|
{
|
||||||
if (twidth == *width && theight == *height)
|
if (twidth == *width && theight == *height)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (iteration == 0 && (twidth < *width || theight < *height))
|
if (iteration == 0 && (twidth < *width || theight < *height))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD dist = (twidth - *width) * (twidth - *width)
|
const DWORD dist = (twidth - *width) * (twidth - *width)
|
||||||
+ (theight - *height) * (theight - *height);
|
+ (theight - *height) * (theight - *height);
|
||||||
|
|
||||||
if (dist < closest)
|
if (dist < closest)
|
||||||
|
@ -2392,7 +2385,8 @@ void I_ClosestResolution (int *width, int *height, int bits)
|
||||||
cheight = theight;
|
cheight = theight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (closest != 4294967295u)
|
|
||||||
|
if (closest != DWORD(-1))
|
||||||
{
|
{
|
||||||
*width = cwidth;
|
*width = cwidth;
|
||||||
*height = cheight;
|
*height = cheight;
|
||||||
|
|
Loading…
Reference in a new issue