Browse Source

Platform: document how to calculate content scaling in a x-platform way.

pull/405/head
Vladimír Vondruš 6 years ago
parent
commit
314cad0d89
  1. 9
      doc/snippets/MagnumPlatform.cpp
  2. 6
      src/Magnum/Platform/Sdl2Application.h

9
doc/snippets/MagnumPlatform.cpp

@ -83,6 +83,8 @@ namespace C {
struct MyApplication: Platform::Application {
MyApplication(const Arguments& arguments);
void foo();
};
/* [configuration] */
@ -95,6 +97,13 @@ MyApplication::MyApplication(const Arguments& arguments):
}
/* [configuration] */
void MyApplication::foo() {
/* [Sdl2Application-dpi-scaling] */
Vector2 scaling = Vector2{framebufferSize()}*dpiScaling()/Vector2{windowSize()};
/* [Sdl2Application-dpi-scaling] */
static_cast<void>(scaling);
}
}
namespace D {

6
src/Magnum/Platform/Sdl2Application.h

@ -383,6 +383,12 @@ The default is depending on the platform:
@ref Platform-EmscriptenApplication-dpi "EmscriptenApplication DPI awareness docs"
for more information.
With @ref windowSize(), @ref framebufferSize() and @ref dpiScaling() having a
different relation on each platform, the way to calculate context scaling
consistently everywhere is using this expression:
@snippet MagnumPlatform.cpp Sdl2Application-dpi-scaling
If your application is saving and restoring window size, it's advisable to take
@ref dpiScaling() into account:

Loading…
Cancel
Save