mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 15:02:39 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
733873351a
3 changed files with 58 additions and 39 deletions
|
@ -525,7 +525,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
||||||
}
|
}
|
||||||
else if(condition == INVULNERABILITY)
|
else if(condition == INVULNERABILITY)
|
||||||
{
|
{
|
||||||
if(statusBar->CPlayer->cheats&CF_GODMODE)
|
if(statusBar->CPlayer->cheats&(CF_GODMODE|CF_GODMODE2))
|
||||||
{
|
{
|
||||||
drawAlt = 1;
|
drawAlt = 1;
|
||||||
}
|
}
|
||||||
|
@ -1730,7 +1730,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
||||||
static int artiflashTick;
|
static int artiflashTick;
|
||||||
static fixed_t itemflashFade;
|
static fixed_t itemflashFade;
|
||||||
};
|
};
|
||||||
int CommandDrawSelectedInventory::artiflashTick = 4;
|
int CommandDrawSelectedInventory::artiflashTick = 0;
|
||||||
int CommandDrawSelectedInventory::itemflashFade = FRACUNIT*3/4;
|
int CommandDrawSelectedInventory::itemflashFade = FRACUNIT*3/4;
|
||||||
|
|
||||||
void DSBarInfo::FlashItem(const PClass *itemtype)
|
void DSBarInfo::FlashItem(const PClass *itemtype)
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SDLFB : public DFrameBuffer
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(SDLFB, DFrameBuffer)
|
DECLARE_CLASS(SDLFB, DFrameBuffer)
|
||||||
public:
|
public:
|
||||||
SDLFB (int width, int height, bool fullscreen);
|
SDLFB (int width, int height, bool fullscreen, SDL_Window *oldwin);
|
||||||
~SDLFB ();
|
~SDLFB ();
|
||||||
|
|
||||||
bool Lock (bool buffer);
|
bool Lock (bool buffer);
|
||||||
|
@ -67,7 +67,6 @@ private:
|
||||||
SDL_Texture *Texture;
|
SDL_Texture *Texture;
|
||||||
SDL_Surface *Surface;
|
SDL_Surface *Surface;
|
||||||
};
|
};
|
||||||
SDL_Rect UpdateRect;
|
|
||||||
|
|
||||||
bool UsingRenderer;
|
bool UsingRenderer;
|
||||||
bool NeedPalUpdate;
|
bool NeedPalUpdate;
|
||||||
|
@ -261,6 +260,8 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree
|
||||||
PalEntry flashColor;
|
PalEntry flashColor;
|
||||||
int flashAmount;
|
int flashAmount;
|
||||||
|
|
||||||
|
SDL_Window *oldwin = NULL;
|
||||||
|
|
||||||
if (old != NULL)
|
if (old != NULL)
|
||||||
{ // Reuse the old framebuffer if its attributes are the same
|
{ // Reuse the old framebuffer if its attributes are the same
|
||||||
SDLFB *fb = static_cast<SDLFB *> (old);
|
SDLFB *fb = static_cast<SDLFB *> (old);
|
||||||
|
@ -275,6 +276,10 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree
|
||||||
}
|
}
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldwin = fb->Screen;
|
||||||
|
fb->Screen = NULL;
|
||||||
|
|
||||||
old->GetFlash (flashColor, flashAmount);
|
old->GetFlash (flashColor, flashAmount);
|
||||||
old->ObjectFlags |= OF_YesReallyDelete;
|
old->ObjectFlags |= OF_YesReallyDelete;
|
||||||
if (screen == old) screen = NULL;
|
if (screen == old) screen = NULL;
|
||||||
|
@ -286,7 +291,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree
|
||||||
flashAmount = 0;
|
flashAmount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLFB *fb = new SDLFB (width, height, fullscreen);
|
SDLFB *fb = new SDLFB (width, height, fullscreen, oldwin);
|
||||||
|
|
||||||
// If we could not create the framebuffer, try again with slightly
|
// If we could not create the framebuffer, try again with slightly
|
||||||
// different parameters in this order:
|
// different parameters in this order:
|
||||||
|
@ -340,7 +345,7 @@ void SDLVideo::SetWindowedScale (float scale)
|
||||||
|
|
||||||
// FrameBuffer implementation -----------------------------------------------
|
// FrameBuffer implementation -----------------------------------------------
|
||||||
|
|
||||||
SDLFB::SDLFB (int width, int height, bool fullscreen)
|
SDLFB::SDLFB (int width, int height, bool fullscreen, SDL_Window *oldwin)
|
||||||
: DFrameBuffer (width, height)
|
: DFrameBuffer (width, height)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -351,15 +356,27 @@ SDLFB::SDLFB (int width, int height, bool fullscreen)
|
||||||
NotPaletted = false;
|
NotPaletted = false;
|
||||||
FlashAmount = 0;
|
FlashAmount = 0;
|
||||||
|
|
||||||
FString caption;
|
if (oldwin)
|
||||||
caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
|
{
|
||||||
|
// In some cases (Mac OS X fullscreen) SDL2 doesn't like having multiple windows which
|
||||||
|
// appears to inevitably happen while compositor animations are running. So lets try
|
||||||
|
// to reuse the existing window.
|
||||||
|
Screen = oldwin;
|
||||||
|
SDL_SetWindowSize (Screen, width, height);
|
||||||
|
SetFullscreen (fullscreen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FString caption;
|
||||||
|
caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
|
||||||
|
|
||||||
Screen = SDL_CreateWindow (caption,
|
Screen = SDL_CreateWindow (caption,
|
||||||
SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter),
|
SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter),
|
||||||
width, height, (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
|
width, height, (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)|SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
if (Screen == NULL)
|
if (Screen == NULL)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Renderer = NULL;
|
Renderer = NULL;
|
||||||
Texture = NULL;
|
Texture = NULL;
|
||||||
|
@ -381,15 +398,15 @@ SDLFB::SDLFB (int width, int height, bool fullscreen)
|
||||||
|
|
||||||
SDLFB::~SDLFB ()
|
SDLFB::~SDLFB ()
|
||||||
{
|
{
|
||||||
|
if (Renderer)
|
||||||
|
{
|
||||||
|
if (Texture)
|
||||||
|
SDL_DestroyTexture (Texture);
|
||||||
|
SDL_DestroyRenderer (Renderer);
|
||||||
|
}
|
||||||
|
|
||||||
if(Screen)
|
if(Screen)
|
||||||
{
|
{
|
||||||
if (Renderer)
|
|
||||||
{
|
|
||||||
if (Texture)
|
|
||||||
SDL_DestroyTexture (Texture);
|
|
||||||
SDL_DestroyRenderer (Renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_DestroyWindow (Screen);
|
SDL_DestroyWindow (Screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,7 +515,8 @@ void SDLFB::Update ()
|
||||||
SDL_UnlockTexture (Texture);
|
SDL_UnlockTexture (Texture);
|
||||||
|
|
||||||
SDLFlipCycles.Clock();
|
SDLFlipCycles.Clock();
|
||||||
SDL_RenderCopy(Renderer, Texture, NULL, &UpdateRect);
|
SDL_RenderClear(Renderer);
|
||||||
|
SDL_RenderCopy(Renderer, Texture, NULL, NULL);
|
||||||
SDL_RenderPresent(Renderer);
|
SDL_RenderPresent(Renderer);
|
||||||
SDLFlipCycles.Unclock();
|
SDLFlipCycles.Unclock();
|
||||||
}
|
}
|
||||||
|
@ -613,6 +631,9 @@ void SDLFB::GetFlashedPalette (PalEntry pal[256])
|
||||||
|
|
||||||
void SDLFB::SetFullscreen (bool fullscreen)
|
void SDLFB::SetFullscreen (bool fullscreen)
|
||||||
{
|
{
|
||||||
|
if (IsFullscreen() == fullscreen)
|
||||||
|
return;
|
||||||
|
|
||||||
SDL_SetWindowFullscreen (Screen, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen (Screen, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
if (!fullscreen)
|
if (!fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -645,6 +666,8 @@ void SDLFB::ResetSDLRenderer ()
|
||||||
if (!Renderer)
|
if (!Renderer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(Renderer, 0, 0, 0, 255);
|
||||||
|
|
||||||
Uint32 fmt;
|
Uint32 fmt;
|
||||||
switch(vid_displaybits)
|
switch(vid_displaybits)
|
||||||
{
|
{
|
||||||
|
@ -681,24 +704,14 @@ void SDLFB::ResetSDLRenderer ()
|
||||||
NotPaletted = false;
|
NotPaletted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate update rectangle
|
// In fullscreen, set logical size according to animorphic ratio.
|
||||||
|
// Windowed modes are rendered to fill the window (usually 1:1)
|
||||||
if (IsFullscreen ())
|
if (IsFullscreen ())
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSize (Screen, &w, &h);
|
SDL_GetWindowSize (Screen, &w, &h);
|
||||||
UpdateRect.w = w;
|
ScaleWithAspect (w, h, Width, Height);
|
||||||
UpdateRect.h = h;
|
SDL_RenderSetLogicalSize (Renderer, w, h);
|
||||||
ScaleWithAspect (UpdateRect.w, UpdateRect.h, Width, Height);
|
|
||||||
UpdateRect.x = (w - UpdateRect.w)/2;
|
|
||||||
UpdateRect.y = (h - UpdateRect.h)/2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// In windowed mode we just update the whole window.
|
|
||||||
UpdateRect.x = 0;
|
|
||||||
UpdateRect.y = 0;
|
|
||||||
UpdateRect.w = Width;
|
|
||||||
UpdateRect.h = Height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,13 +739,14 @@ void SDLFB::SetVSync (bool vsync)
|
||||||
|
|
||||||
void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
||||||
{
|
{
|
||||||
|
int w, h;
|
||||||
|
SDL_GetWindowSize (Screen, &w, &h);
|
||||||
|
|
||||||
// Detect if we're doing scaling in the Window and adjust the mouse
|
// Detect if we're doing scaling in the Window and adjust the mouse
|
||||||
// coordinates accordingly. This could be more efficent, but I
|
// coordinates accordingly. This could be more efficent, but I
|
||||||
// don't think performance is an issue in the menus.
|
// don't think performance is an issue in the menus.
|
||||||
if(IsFullscreen())
|
if(IsFullscreen())
|
||||||
{
|
{
|
||||||
int w, h;
|
|
||||||
SDL_GetWindowSize (Screen, &w, &h);
|
|
||||||
int realw = w, realh = h;
|
int realw = w, realh = h;
|
||||||
ScaleWithAspect (realw, realh, SCREENWIDTH, SCREENHEIGHT);
|
ScaleWithAspect (realw, realh, SCREENWIDTH, SCREENHEIGHT);
|
||||||
if (realw != SCREENWIDTH || realh != SCREENHEIGHT)
|
if (realw != SCREENWIDTH || realh != SCREENHEIGHT)
|
||||||
|
@ -751,6 +765,11 @@ void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = (SWORD)(x*Width/w);
|
||||||
|
y = (SWORD)(y*Height/h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ADD_STAT (blit)
|
ADD_STAT (blit)
|
||||||
|
|
|
@ -51,7 +51,7 @@ statusbar fullscreen, fullscreenoffsets
|
||||||
|
|
||||||
statusbar Normal
|
statusbar Normal
|
||||||
{
|
{
|
||||||
drawimage "H2BAR", 0, 135;
|
drawimage "H2BAR", 0, 134;
|
||||||
drawimage "STATBAR", 38, 162;
|
drawimage "STATBAR", 38, 162;
|
||||||
|
|
||||||
drawselectedinventory artiflash, INDEXFONT_RAVEN, 143, 163, 174, 184, untranslated;
|
drawselectedinventory artiflash, INDEXFONT_RAVEN, 143, 163, 174, 184, untranslated;
|
||||||
|
@ -204,7 +204,7 @@ statusbar Normal
|
||||||
|
|
||||||
statusbar Automap
|
statusbar Automap
|
||||||
{
|
{
|
||||||
drawimage "H2BAR", 0, 135;
|
drawimage "H2BAR", 0, 134;
|
||||||
drawimage "KEYBAR", 38, 162;
|
drawimage "KEYBAR", 38, 162;
|
||||||
drawkeybar 5, horizontal, 20, 46, 164;
|
drawkeybar 5, horizontal, 20, 46, 164;
|
||||||
drawimage hexenarmor(armor, "ARMSLOT1"), 150, 164;
|
drawimage hexenarmor(armor, "ARMSLOT1"), 150, 164;
|
||||||
|
|
Loading…
Reference in a new issue