mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Implemented love.window.getPixelScale for Android. Fullscreen windows now use Android's 'immersive mode'.
This commit is contained in:
@@ -23,6 +23,10 @@
|
|||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
#include "common/android.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -392,6 +396,11 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|||||||
|
|
||||||
Uint32 sdlflags = SDL_WINDOW_OPENGL;
|
Uint32 sdlflags = SDL_WINDOW_OPENGL;
|
||||||
|
|
||||||
|
// On Android we always must have fullscreen type FULLSCREEN_TYPE_DESKTOP
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
f.fstype = FULLSCREEN_DESKTOP;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (f.fullscreen)
|
if (f.fullscreen)
|
||||||
{
|
{
|
||||||
if (f.fstype == FULLSCREEN_DESKTOP)
|
if (f.fstype == FULLSCREEN_DESKTOP)
|
||||||
@@ -471,6 +480,10 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|||||||
if (gfx != nullptr)
|
if (gfx != nullptr)
|
||||||
gfx->setMode(curMode.pixelwidth, curMode.pixelheight);
|
gfx->setMode(curMode.pixelwidth, curMode.pixelheight);
|
||||||
|
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
love::android::setImmersive(f.fullscreen);
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,6 +528,10 @@ void Window::updateSettings(const WindowSettings &newsettings)
|
|||||||
curMode.settings.fstype = newsettings.fstype;
|
curMode.settings.fstype = newsettings.fstype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
curMode.settings.fullscreen = love::android::getImmersive();
|
||||||
|
#endif
|
||||||
|
|
||||||
// The min width/height is set to 0 internally in SDL when in fullscreen.
|
// The min width/height is set to 0 internally in SDL when in fullscreen.
|
||||||
if (curMode.settings.fullscreen)
|
if (curMode.settings.fullscreen)
|
||||||
{
|
{
|
||||||
@@ -619,6 +636,10 @@ bool Window::setFullscreen(bool fullscreen, Window::FullscreenType fstype)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
love::android::setImmersive(fullscreen);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SDL_SetWindowFullscreen(window, sdlflags) == 0)
|
if (SDL_SetWindowFullscreen(window, sdlflags) == 0)
|
||||||
{
|
{
|
||||||
SDL_GL_MakeCurrent(window, context);
|
SDL_GL_MakeCurrent(window, context);
|
||||||
@@ -886,8 +907,11 @@ void Window::pixelToWindowCoords(double *x, double *y) const
|
|||||||
|
|
||||||
double Window::getPixelScale() const
|
double Window::getPixelScale() const
|
||||||
{
|
{
|
||||||
// TODO: Return the density display metric on Android.
|
#ifdef LOVE_ANDROID
|
||||||
|
return love::android::getScreenScale();
|
||||||
|
#else
|
||||||
return (double) curMode.pixelheight / (double) curMode.height;
|
return (double) curMode.pixelheight / (double) curMode.height;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
double Window::toPixels(double x) const
|
double Window::toPixels(double x) const
|
||||||
|
|||||||
Reference in New Issue
Block a user