Skip to content

glViewport resolution difference #29

Closed

Description

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?

Activity

  1. austinkinross commented on Dec 20, 2014

    @austinkinross
    Member

    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/

  2. iliagrigorevdev commented on Dec 26, 2014

    @iliagrigorevdev
    Author

    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?

  3. austinkinross commented on Dec 29, 2014

    @austinkinross
    Member

    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

  4. iliagrigorevdev commented on Dec 29, 2014

    @iliagrigorevdev
    Author

    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?

  5. austinkinross commented on Dec 29, 2014

    @austinkinross
    Member

    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?

  6. iliagrigorevdev commented on Dec 30, 2014

    @iliagrigorevdev
    Author

    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.

  7. austinkinross commented on Jan 2, 2015

    @austinkinross
    Member

    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:

    • 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.

    Thanks,
    Austin

  8. austinkinross commented on Jun 29, 2015

    @austinkinross
    Member

    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:

        Windows::Graphics::Display::DisplayInformation^ info = Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
        float scale = info->LogicalDpi / 96.0f;
        mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, nullptr, &scale);
    

    This will create the window surface at the same resolution as the screen (i.e. without scaling).

    Thanks,
    Austin

  9. iliagrigorevdev commented on Jul 4, 2015

    @iliagrigorevdev
    Author

    It works! Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions