-
Notifications
You must be signed in to change notification settings - Fork 165
Scaling your app to run at different resolution on the device
- Allows apps to run at a lower resolution than the device, improving their framerate
- Apps are automatically scaled to the full window size for free using the hardware scaler
- Great for high-resolution devices with weaker GPUs
- Allows apps to run at screen resolution on the device
- Only supported in Windows Store apps
The default resolution managed by ANGLE for rendering surfaces may not be ideal for your application. Larger or smaller sizes can be specified directly during surface creation. This is done by using an IPropertySet configured with a defined set of properties located in angle_windowsstore.h as the IInspectable native window type.
By default our Visual Studio templates do not customize the render surface size. Examples of customizing it can be found in the templates' comments.
Specifying a smaller size may result in a performance gain.
Note: The custom-sized rendering surface will be automatically scaled to fit the entire SwapChainPanel control or CoreWindow.
- Render your content at a certain scale compared to the window size
- Have your content automatically scaled up to fill the window
- For example, if the window is 1920x1080 and the scale is 0.5f, then the render surface will be 960x540 in size. It will then be scaled up to fill the 1920x1080 window
Example code:
// Create a PropertySet and initialize with the EGLNativeWindowType (CoreWindow or SwapChainPanel).
PropertySet^ properties = ref new PropertySet();
properties->Insert(ref new String(EGLNativeWindowTypeProperty), swapChainPanel);
// Add EGLRenderResolutionScaleProperty to the surface creation properties.
float resolutionScale = 0.5f;
properties->Insert(ref new String(EGLRenderResolutionScaleProperty), PropertyValue::CreateSingle(resolutionScale));
EGLSurface surface = EGL_NO_SURFACE;
surface = eglCreateWindowSurface(mEglDisplay, mEglConfig,
reinterpret_cast<IInspectable*>(properties), NULL);
if (surface == EGL_NO_SURFACE)
{
throwException::CreateException(E_FAIL, L"Failed to create EGL surface");
}
Matching the screen resolution is achieved by calculating a scale factor using the current LogicalDpi value obtained from Windows::Graphics::DisplayInformation
// Calculate a scale for a surface that matches the screen resolution
Windows::Graphics::Display::DisplayInformation^ info = Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
float screenResolutionScale = info->LogicalDpi / 96.0f;
- Always render your content at a certain resolution
- Have your content automatically scaled to fit the window
Example code:
// Create a PropertySet and initialize with the EGLNativeWindowType (CoreWindow or SwapChainPanel).
PropertySet^ properties = ref new PropertySet();
properties->Insert(ref new String(EGLNativeWindowTypeProperty), swapChainPanel);
// Add EGLRenderSurfaceSizeProperty to the surface creation properties.
Size renderSurfaceSize(800, 600);
properties->Insert(ref new String(EGLRenderSurfaceSizeProperty), PropertyValue::CreateSize(renderSurfaceSize));
EGLSurface surface = EGL_NO_SURFACE;
surface = eglCreateWindowSurface(mEglDisplay, mEglConfig,
reinterpret_cast<IInspectable*>(properties), NULL);
if (surface == EGL_NO_SURFACE)
{
throwException::CreateException(E_FAIL, L"Failed to create EGL surface");
}