GithubHelp home page GithubHelp logo

Comments (9)

austinkinross avatar austinkinross commented on August 18, 2024

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/

from angle.

iliagrigorevdev avatar iliagrigorevdev commented on August 18, 2024

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?

from angle.

austinkinross avatar austinkinross commented on August 18, 2024

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

from angle.

iliagrigorevdev avatar iliagrigorevdev commented on August 18, 2024

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?

from angle.

austinkinross avatar austinkinross commented on August 18, 2024

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?

from angle.

iliagrigorevdev avatar iliagrigorevdev commented on August 18, 2024

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.

from angle.

austinkinross avatar austinkinross commented on August 18, 2024

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

from angle.

austinkinross avatar austinkinross commented on August 18, 2024

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

from angle.

iliagrigorevdev avatar iliagrigorevdev commented on August 18, 2024

It works! Many thanks

from angle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.