Browse Source

Platform: added AndroidApplication::framebufferSize() and dpiScaling().

Doesn't provide any new interesting values, just for compatibility with
other toolkits.
pull/297/head
Vladimír Vondruš 8 years ago
parent
commit
d40e4f2dea
  1. 7
      doc/changelog.dox
  2. 16
      src/Magnum/Platform/AbstractXApplication.h
  3. 2
      src/Magnum/Platform/AndroidApplication.cpp
  4. 53
      src/Magnum/Platform/AndroidApplication.h

7
doc/changelog.dox

@ -61,6 +61,13 @@ r<Player<T, K>>>)
@ref Math::Color3 and @ref Math::Color4 literals with the new experimental
@ref Corrade::Utility::Tweakable utility. See also @ref tweakableliterals.
@subsubsection changelog-latest-new-platform Platform libraries
- Added @ref Platform::AndroidApplication::framebufferSize(),
@ref Platform::AndroidApplication::dpiScaling() and
@ref Platform::AndroidApplication::ViewportEvent::dpiScaling() for
compatibility with other application implementations
@subsection changelog-latest-changes Changes and improvements
@subsubsection changelog-latest-changes-gl GL library

16
src/Magnum/Platform/AbstractXApplication.h

@ -212,7 +212,21 @@ class AbstractXApplication {
#else
private:
#endif
/** @copydoc GlfwApplication::viewportEvent(ViewportEvent&) */
/**
* @brief Viewport event
*
* Called when window size changes. The default implementation does
* nothing. If you want to respond to size changes, you should pass the
* new size to @ref GL::DefaultFramebuffer::setViewport() (if using
* OpenGL) and possibly elsewhere (to
* @ref SceneGraph::Camera::setViewport(), other framebuffers...).
*
* Note that this function might not get called at all if the window
* size doesn't change. You should configure the initial state of your
* cameras, framebuffers etc. in application constructor rather than
* relying on this function to be called. Size of the window can be
* retrieved using @ref windowSize().
*/
virtual void viewportEvent(ViewportEvent& event);
#ifdef MAGNUM_BUILD_DEPRECATED

2
src/Magnum/Platform/AndroidApplication.cpp

@ -165,7 +165,7 @@ bool AndroidApplication::tryCreate(const Configuration& configuration, const GLC
return _context->tryCreate();
}
Vector2i AndroidApplication::windowSize() const {
Vector2i AndroidApplication::framebufferSize() const {
return {ANativeWindow_getWidth(_state->window),
ANativeWindow_getHeight(_state->window)};
}

53
src/Magnum/Platform/AndroidApplication.h

@ -306,8 +306,45 @@ class AndroidApplication {
* @brief Window size
*
* Window size to which all input event coordinates can be related.
* Expects that a window is already created, equivalent to
* @ref framebufferSize().
*
* @attention The reported value will be incorrect in case you use
* the [Screen Compatibility Mode](http://www.androiddocs.com/guide/practices/screen-compat-mode.html).
* See @ref platforms-android-apps-manifest-screen-compatibility-mode
* for details.
*/
Vector2i windowSize() const { return framebufferSize(); }
/**
* @brief Framebuffer size
*
* Size of the default framebuffer, equivalent to @ref windowSize().
* Expects that a window is already created.
* @see @ref dpiScaling()
*/
Vector2i framebufferSize() const;
/**
* @brief DPI scaling
*
* Provided only for compatibility with other toolkits. Returns always
* @cpp {1.0f, 1.0f} @ce.
* @see @ref framebufferSize()
*/
Vector2i windowSize() const;
Vector2 dpiScaling() const { return Vector2{1.0f}; }
/**
* @brief DPI scaling for given configuration
*
* Provided only for compatibility with other toolkits. Returns always
* @cpp {1.0f, 1.0f} @ce.
* @see @ref framebufferSize()
*/
Vector2 dpiScaling(const Configuration& configuration) const {
static_cast<void>(configuration);
return Vector2{1.0f};
}
/**
* @brief Swap buffers
@ -521,18 +558,26 @@ class AndroidApplication::ViewportEvent {
/**
* @brief Window size
*
* @see @ref AndroidApplication::windowSize()
* The same as @ref framebufferSize(). See
* @ref AndroidApplication::windowSize() for possible caveats.
*/
Vector2i windowSize() const { return _windowSize; }
/**
* @brief Framebuffer size
*
* The same as @ref windowSize().
* @todo this might not be true, implement properly!
* The same as @ref windowSize(). See
* @ref AndroidApplication::framebufferSize() for possible caveats.
*/
Vector2i framebufferSize() const { return _windowSize; }
/**
* @brief DPI scaling
*
* Always @cpp {1.0f, 1.0f} @ce.
*/
Vector2 dpiScaling() const { return Vector2{1.0f}; }
private:
friend AndroidApplication;

Loading…
Cancel
Save