mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-04-21 21:52:04 +02:00
Support Retina displays
This commit is contained in:
parent
4829f63e45
commit
1a304da43d
7 changed files with 28 additions and 6 deletions
|
@ -25,7 +25,7 @@
|
|||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.role-playing-games</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<false/>
|
||||
<true/>
|
||||
<key>NSRequiresAquaSystemAppearance</key>
|
||||
<string>False</string>
|
||||
</dict>
|
||||
|
|
|
@ -415,6 +415,10 @@ struct GraphicsPrivate {
|
|||
* is blitted inside the game window */
|
||||
Vec2i scOffset;
|
||||
|
||||
// Scaling factor, used to display the screen properly
|
||||
// on Retina displays
|
||||
int scalingFactor;
|
||||
|
||||
ScreenScene screen;
|
||||
RGSSThreadData *threadData;
|
||||
SDL_GLContext glCtx;
|
||||
|
@ -450,7 +454,7 @@ struct GraphicsPrivate {
|
|||
glCtx(SDL_GL_GetCurrentContext()), frameRate(DEF_FRAMERATE),
|
||||
frameCount(0), brightness(255), fpsLimiter(frameRate),
|
||||
useFrameSkip(rtData->config.frameSkip), frozen(false),
|
||||
last_update(0), last_avg_update(0) {
|
||||
last_update(0), last_avg_update(0), scalingFactor(rtData->scale){
|
||||
avgFPSData = std::vector<unsigned long long>();
|
||||
avgFPSLock = SDL_CreateMutex();
|
||||
|
||||
|
@ -547,7 +551,10 @@ struct GraphicsPrivate {
|
|||
void metaBlitBufferFlippedScaled() {
|
||||
GLMeta::blitRectangle(
|
||||
IntRect(0, 0, scRes.x, scRes.y),
|
||||
IntRect(scOffset.x, scSize.y + scOffset.y, scSize.x, -scSize.y),
|
||||
IntRect(scOffset.x * scalingFactor,
|
||||
(scSize.y + scOffset.y) * scalingFactor,
|
||||
scSize.x * scalingFactor,
|
||||
-scSize.y * scalingFactor),
|
||||
threadData->config.smoothScaling);
|
||||
}
|
||||
|
||||
|
@ -589,7 +596,7 @@ struct GraphicsPrivate {
|
|||
}
|
||||
|
||||
double averageFPS() {
|
||||
double ret;
|
||||
double ret = 0;
|
||||
SDL_LockMutex(avgFPSLock);
|
||||
for (unsigned long long times : avgFPSData)
|
||||
ret += times;
|
||||
|
|
|
@ -257,6 +257,7 @@ struct RGSSThreadData
|
|||
|
||||
Vec2 sizeResoRatio;
|
||||
Vec2i screenOffset;
|
||||
int scale;
|
||||
const int refreshRate;
|
||||
|
||||
Config config;
|
||||
|
@ -268,6 +269,7 @@ struct RGSSThreadData
|
|||
SDL_Window *window,
|
||||
ALCdevice *alcDev,
|
||||
int refreshRate,
|
||||
int scalingFactor,
|
||||
const Config& newconf,
|
||||
SDL_GLContext ctx)
|
||||
: ethread(ethread),
|
||||
|
@ -276,6 +278,7 @@ struct RGSSThreadData
|
|||
alcDev(alcDev),
|
||||
sizeResoRatio(1, 1),
|
||||
refreshRate(refreshRate),
|
||||
scale(scalingFactor),
|
||||
config(newconf),
|
||||
glContext(ctx)
|
||||
{}
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
|
||||
#include "filesystem/filesystem.h"
|
||||
|
||||
#include "system/system.h"
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
#include "resource.h"
|
||||
#include <Winsock2.h>
|
||||
|
@ -191,8 +193,8 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
#ifndef WORKDIR_CURRENT
|
||||
char dataDir[512]{};
|
||||
char *tmp{};
|
||||
#if defined(__linux__)
|
||||
char *tmp{};
|
||||
tmp = getenv("SRCDIR");
|
||||
if (tmp) {
|
||||
strncpy(dataDir, tmp, sizeof(dataDir));
|
||||
|
@ -384,7 +386,7 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
|
||||
RGSSThreadData rtData(&eventThread, argv[0], win, alcDev, mode.refresh_rate,
|
||||
conf, glCtx);
|
||||
mkxp_sys::getScalingFactor(), conf, glCtx);
|
||||
|
||||
int winW, winH;
|
||||
SDL_GetWindowSize(win, &winW, &winH);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace systemImpl {
|
||||
std::string getSystemLanguage();
|
||||
std::string getUserName();
|
||||
int getScalingFactor();
|
||||
}
|
||||
|
||||
#ifdef MKXPZ_BUILD_XCODE
|
||||
|
|
|
@ -54,3 +54,8 @@ std::string systemImpl::getUserName() {
|
|||
return std::string(ret);
|
||||
|
||||
}
|
||||
|
||||
// HiDPI scaling not supported outside of macOS for now
|
||||
int systemImpl::getScalingFactor() {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,10 @@ std::string systemImpl::getUserName() {
|
|||
return std::string(NSUserName().UTF8String);
|
||||
}
|
||||
|
||||
int systemImpl::getScalingFactor() {
|
||||
return NSApplication.sharedApplication.mainWindow.backingScaleFactor;
|
||||
}
|
||||
|
||||
|
||||
// constant, if it's not nil then just raise the menu instead
|
||||
SettingsMenu *smenu = nil;
|
||||
|
|
Loading…
Add table
Reference in a new issue