You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows Phone app with ICoreWindow has higher glViewport resolution than Windows Phone app with SwapChainPanel. Tested on emulator and device. How can I use raw pixel glViewport size on the Windows Phone with SwapChainPanel?
Hi Xenice. Yes, by default the SwapChainPanel sample creates its EGL window surface at a lower resolution than the screen. Like Visual Studio's D3D11 templates, it uses the values from the SwapChainPanel's RenderSize or ActualSize properties.
There is no harm in having the SwapChainPanel at a lower resolution than the screen, unless you are noticing aliasing when the SwapChainPanel is scaled up to the screen's resolution. It may actually help your application's performance to have a lower resolution, since your app might achieve a better framerate.
Thanks for you reply!
Yes I can manually configure the SwapChainPanel size. But is it optimal, to recreate OpenGLES window surface (eglDestroySurface, eglCreateWindowSurface) every time SwapChainPanel size changed?
I want to set a native pixel resolution of the device screen (without scaling) just by specifying glViewport(0, 0, width, height). Because I need to dynamically resize opengl viewport if a user resizes window. But SwapChainPanel's (and thus opengl windows's) dimension is in density independent pixels. How can I create opengl window in native pixels instead of dpis?
How are you getting the "native pixel resolution of the device screen"?
The templates use "Windows::UI::Xaml::SizeChangedEventArgs" to get the width/height in DIPS of the SwapChainPanel (in "OpenGLESPage::OnSwapChainPanelSizeChanged"). It then calls glViewport() using these values. Does this not suffice for you?
Okay. We don't officially support creating the SwapChainPanel in any units other than Dips.
If you really want to create the SwapChainPanel at the native resolution, then you should modify the internals of ANGLE to also call your ConvertDipsToPixels() function in the right places. I believe you'll need to do this in:
src/common/winrt/SwapChainPanelNativeWindow.h
call ConvertDipsToPixels() on the output of "sizeChangedEventArgs->get_NewSize(&newSize);"
src/common/winrt/SwapChainPanelNativeWindow.cpp
call ConvertDipsToPixels() on the result of "uiElement->get_RenderSize(&renderSize);"
I can't promise that these changes won't have any unwanted side-effects, but I can't think of any right now.
We now have an easy solution to your issue. In "OpenGLESPage::CreateRenderSurface" in OpenGLESPage.xaml.cpp, you can define mRenderSurface using something like this:
Activity
austinkinross commentedon Dec 20, 2014
Hi Xenice. Yes, by default the SwapChainPanel sample creates its EGL window surface at a lower resolution than the screen. Like Visual Studio's D3D11 templates, it uses the values from the SwapChainPanel's RenderSize or ActualSize properties.
There is no harm in having the SwapChainPanel at a lower resolution than the screen, unless you are noticing aliasing when the SwapChainPanel is scaled up to the screen's resolution. It may actually help your application's performance to have a lower resolution, since your app might achieve a better framerate.
You can manually configure the SwapChainPanel size if you really want to. Instructions for this can be found in the SwapChainPanel template (in 'OpenGLESPage::CreateRenderSurface()'), or in this blog post: http://msopentech.com/blog/2014/11/06/creating-corewindow-and-swapchainpanel-window-surfaces-in-angle/
iliagrigorevdev commentedon Dec 26, 2014
Thanks for you reply!
Yes I can manually configure the SwapChainPanel size. But is it optimal, to recreate OpenGLES window surface (eglDestroySurface, eglCreateWindowSurface) every time SwapChainPanel size changed?
austinkinross commentedon Dec 29, 2014
You're correct. Recreating the window surface is expensive.
Can you clarify exactly what you're trying to achieve here, and why? This will help us to find a solution for you.
Thanks,
Austin
iliagrigorevdev commentedon Dec 29, 2014
I want to set a native pixel resolution of the device screen (without scaling) just by specifying glViewport(0, 0, width, height). Because I need to dynamically resize opengl viewport if a user resizes window. But SwapChainPanel's (and thus opengl windows's) dimension is in density independent pixels. How can I create opengl window in native pixels instead of dpis?
austinkinross commentedon Dec 29, 2014
How are you getting the "native pixel resolution of the device screen"?
The templates use "Windows::UI::Xaml::SizeChangedEventArgs" to get the width/height in DIPS of the SwapChainPanel (in "OpenGLESPage::OnSwapChainPanelSizeChanged"). It then calls glViewport() using these values. Does this not suffice for you?
iliagrigorevdev commentedon Dec 30, 2014
I get it using the ConvertDipsToPixels() method from the template based on ICoreWindow.
// Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
inline float ConvertDipsToPixels(float dips)
{
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
static const float dipsPerInch = 96.0f;
return floor(dips * currentDisplayInformation->LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
}
I want to have the glViewport() resolution in the ISwapChainPanel based project just like in the ICoreWindow based project.
austinkinross commentedon Jan 2, 2015
Hey Xenice,
Okay. We don't officially support creating the SwapChainPanel in any units other than Dips.
If you really want to create the SwapChainPanel at the native resolution, then you should modify the internals of ANGLE to also call your ConvertDipsToPixels() function in the right places. I believe you'll need to do this in:
I can't promise that these changes won't have any unwanted side-effects, but I can't think of any right now.
Thanks,
Austin
austinkinross commentedon Jun 29, 2015
Hi Xenice,
We now have an easy solution to your issue. In "OpenGLESPage::CreateRenderSurface" in OpenGLESPage.xaml.cpp, you can define mRenderSurface using something like this:
This will create the window surface at the same resolution as the screen (i.e. without scaling).
Thanks,
Austin
iliagrigorevdev commentedon Jul 4, 2015
It works! Many thanks