OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Declare Windows applications as DPI-aware


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
bbjorn
Appreciator


Joined: 12 Oct 2010
Posts: 219
Location: Linköping, Sweden

PostPosted: Thu Nov 30, 2017 1:59 pm    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Hi,

Since Windows Vista the operating system assumes all applications as DPI-unaware, unless stated otherwise. This means that if you have desktop scaling enabled (which is pretty much mandatory if you are running a high resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either be done via the inclusion of a manifest file during compilation or by declaring it inside your application. By doing this you are making a promise to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32 constructor to declare the application as DPI-aware per monitor. This guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or later. To be able to detect the correct windows version I had to add a CMake macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn
Back to top
View user's profile Send private message Visit poster's website
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12131

PostPosted: Thu Nov 30, 2017 2:19 pm    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Thanks Bjorn, changes merged and submitted to master :-)

On 30 November 2017 at 13:59, Björn Blissing <> wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as DPI-unaware, unless stated otherwise. This means that if you have desktop scaling enabled (which is pretty much mandatory if you are running a high resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either be done via the inclusion of a manifest file during compilation or by declaring it inside your application. By doing this you are making a promise to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32 constructor to declare the application as DPI-aware per monitor. This guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or later. To be able to detect the correct windows version I had to add a CMake macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Anna Sokol
Guest





PostPosted: Fri Dec 01, 2017 8:20 pm    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Hi,


There is no need to specify WINVER of 0x0603 in order to check for the SetProcessDPIAwareness function existence.

If your current OS where the application is running is Windows 8.1 or above it the function will exist in the dll or if its below it wont.

I checked the attached code with both a Windows 7 desktop (where the function doesn't exist) and a Windows 10 tablet (where it does and had my screen scaled to 150%) and in both cases the code worked as intended.
Regards,
Anna Sokol




On Thu, Nov 30, 2017 at 9:17 AM, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Thanks Bjorn, changes merged and submitted to master Smile

On 30 November 2017 at 13:59, Björn Blissing < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as DPI-unaware, unless stated otherwise. This means that if you have desktop scaling enabled (which is pretty much mandatory if you are running a high resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either be done via the inclusion of a manifest file during compilation or by declaring it inside your application. By doing this you are making a promise to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32 constructor to declare the application as DPI-aware per monitor. This guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or later. To be able to detect the correct windows version I had to add a CMake macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492





_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12131

PostPosted: Sun Dec 03, 2017 1:03 pm    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Hi Anna,

What about older versions of Windows?

What is the harm of the #if (WINVER >= 0x8603)

Thanks any clarification you can provide.
Robert.


On 1 December 2017 at 20:18, Anna Sokol <> wrote:
Quote:
Hi,

There is no need to specify WINVER of 0x0603 in order to check for the
SetProcessDPIAwareness function existence.
If your current OS where the application is running is Windows 8.1 or above
it the function will exist in the dll or if its below it wont.
I checked the attached code with both a Windows 7 desktop (where the
function doesn't exist) and a Windows 10 tablet (where it does and had my
screen scaled to 150%) and in both cases the code worked as intended.

Regards,
Anna Sokol

On Thu, Nov 30, 2017 at 9:17 AM, Robert Osfield <>
wrote:
Quote:

Thanks Bjorn, changes merged and submitted to master :-)

On 30 November 2017 at 13:59, Björn Blissing <>
wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as
DPI-unaware, unless stated otherwise. This means that if you have desktop
scaling enabled (which is pretty much mandatory if you are running a high
resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either
be done via the inclusion of a manifest file during compilation or by
declaring it inside your application. By doing this you are making a promise
to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32
constructor to declare the application as DPI-aware per monitor. This
guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or
later. To be able to detect the correct windows version I had to add a CMake
macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the
osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492














------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 280

PostPosted: Mon Dec 04, 2017 10:01 am    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Hi.Looks like

On 3 December 2017 at 16:01, Robert Osfield <> wrote:
Quote:
Hi Anna,

What about older versions of Windows?

What is the harm of the #if (WINVER >= 0x8603)

Thanks any clarification you can provide.
Robert.


On 1 December 2017 at 20:18, Anna Sokol <> wrote:
Quote:
Hi,

There is no need to specify WINVER of 0x0603 in order to check for the
SetProcessDPIAwareness function existence.
If your current OS where the application is running is Windows 8.1 or above
it the function will exist in the dll or if its below it wont.
I checked the attached code with both a Windows 7 desktop (where the
function doesn't exist) and a Windows 10 tablet (where it does and had my
screen scaled to 150%) and in both cases the code worked as intended.

Regards,
Anna Sokol

On Thu, Nov 30, 2017 at 9:17 AM, Robert Osfield <>
wrote:
Quote:

Thanks Bjorn, changes merged and submitted to master :-)

On 30 November 2017 at 13:59, Björn Blissing <>
wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as
DPI-unaware, unless stated otherwise. This means that if you have desktop
scaling enabled (which is pretty much mandatory if you are running a high
resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either
be done via the inclusion of a manifest file during compilation or by
declaring it inside your application. By doing this you are making a promise
to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32
constructor to declare the application as DPI-aware per monitor. This
guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or
later. To be able to detect the correct windows version I had to add a CMake
macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the
osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492















------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 280

PostPosted: Mon Dec 04, 2017 10:02 am    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Sorry, wrong shortcut.
Looks like the single most crucial point is

setProcessDpiAwareness = (SetProcessDpiAwarenessFunc *)
GetProcAddress(hModuleShore, "SetProcessDpiAwareness");

call. Which produces zero if such function does not exist. This means
runtime check is enough, no conditional compilation is required. Just
as Anna suggested.


On 4 December 2017 at 12:59, michael kapelko <> wrote:
Quote:
Hi.Looks like

On 3 December 2017 at 16:01, Robert Osfield <> wrote:
Quote:
Hi Anna,

What about older versions of Windows?

What is the harm of the #if (WINVER >= 0x8603)

Thanks any clarification you can provide.
Robert.


On 1 December 2017 at 20:18, Anna Sokol <> wrote:
Quote:
Hi,

There is no need to specify WINVER of 0x0603 in order to check for the
SetProcessDPIAwareness function existence.
If your current OS where the application is running is Windows 8.1 or above
it the function will exist in the dll or if its below it wont.
I checked the attached code with both a Windows 7 desktop (where the
function doesn't exist) and a Windows 10 tablet (where it does and had my
screen scaled to 150%) and in both cases the code worked as intended.

Regards,
Anna Sokol

On Thu, Nov 30, 2017 at 9:17 AM, Robert Osfield <>
wrote:
Quote:

Thanks Bjorn, changes merged and submitted to master :-)

On 30 November 2017 at 13:59, Björn Blissing <>
wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as
DPI-unaware, unless stated otherwise. This means that if you have desktop
scaling enabled (which is pretty much mandatory if you are running a high
resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either
be done via the inclusion of a manifest file during compilation or by
declaring it inside your application. By doing this you are making a promise
to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32
constructor to declare the application as DPI-aware per monitor. This
guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or
later. To be able to detect the correct windows version I had to add a CMake
macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the
osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492















------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12131

PostPosted: Mon Dec 04, 2017 1:04 pm    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Thanks Anna (and Michael for the explanation), changes now merged with
OSG master.

On 1 December 2017 at 20:18, Anna Sokol <> wrote:
Quote:
Hi,

There is no need to specify WINVER of 0x0603 in order to check for the
SetProcessDPIAwareness function existence.
If your current OS where the application is running is Windows 8.1 or above
it the function will exist in the dll or if its below it wont.
I checked the attached code with both a Windows 7 desktop (where the
function doesn't exist) and a Windows 10 tablet (where it does and had my
screen scaled to 150%) and in both cases the code worked as intended.

Regards,
Anna Sokol

On Thu, Nov 30, 2017 at 9:17 AM, Robert Osfield <>
wrote:
Quote:

Thanks Bjorn, changes merged and submitted to master :-)

On 30 November 2017 at 13:59, Björn Blissing <>
wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as
DPI-unaware, unless stated otherwise. This means that if you have desktop
scaling enabled (which is pretty much mandatory if you are running a high
resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either
be done via the inclusion of a manifest file during compilation or by
declaring it inside your application. By doing this you are making a promise
to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32
constructor to declare the application as DPI-aware per monitor. This
guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or
later. To be able to detect the correct windows version I had to add a CMake
macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the
osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492














------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Alberto Luaces
Guest





PostPosted: Fri Dec 22, 2017 9:18 am    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

The problem of getting the version at compile time is that it breaks
cross-compilation, where the value is set to "".

Maybe a better solution is to explicitly specify the target version of
windows instead of taking the one of the build system.

Alberto

Robert Osfield writes:

Quote:
Thanks Anna (and Michael for the explanation), changes now merged with
OSG master.

On 1 December 2017 at 20:18, Anna Sokol <> wrote:
Quote:
Hi,

There is no need to specify WINVER of 0x0603 in order to check for the
SetProcessDPIAwareness function existence.
If your current OS where the application is running is Windows 8.1 or above
it the function will exist in the dll or if its below it wont.
I checked the attached code with both a Windows 7 desktop (where the
function doesn't exist) and a Windows 10 tablet (where it does and had my
screen scaled to 150%) and in both cases the code worked as intended.

Regards,
Anna Sokol

On Thu, Nov 30, 2017 at 9:17 AM, Robert Osfield <>
wrote:
Quote:

Thanks Bjorn, changes merged and submitted to master :-)

On 30 November 2017 at 13:59, Björn Blissing <>
wrote:
Quote:
Hi,

Since Windows Vista the operating system assumes all applications as
DPI-unaware, unless stated otherwise. This means that if you have desktop
scaling enabled (which is pretty much mandatory if you are running a high
resolution screen) you will get incorrect scaling and blurry images.

The solution is to declare the application as DPI-aware. This can either
be done via the inclusion of a manifest file during compilation or by
declaring it inside your application. By doing this you are making a promise
to the operating system that you are handling the scaling instead of the OS.

I have made a modification of the osgViewer::GraphicsWindowWin32
constructor to declare the application as DPI-aware per monitor. This
guarantees that the operating system will never scale the application.

Regretfully the required Windows library call requires Windows 8.1 or
later. To be able to detect the correct windows version I had to add a CMake
macro to detect and define the _WIN32_WINNT variable.

During this development I also found a redundant definition inside the
osgDB/FileUtils.cpp file, which I removed.

The resulting commits are sent as the following pull request:
https://github.com/openscenegraph/OpenSceneGraph/pull/396

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72492#72492














--
Alberto



------------------
Post generated by Mail2Forum
Back to top
Alberto Luaces
Guest





PostPosted: Tue Dec 26, 2017 2:46 pm    Post subject:
Declare Windows applications as DPI-aware
Reply with quote

Alberto Luaces writes:

Quote:
The problem of getting the version at compile time is that it breaks
cross-compilation, where the value is set to "".

Maybe a better solution is to explicitly specify the target version of
windows instead of taking the one of the build system.

I have made this auto-detection optional to get cross-compilation
working again (defaulting ON).

This is PR #414.

--
Alberto



------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts GL profiles issues on Windows Riccardo Corsi General 11 Tue Sep 04, 2018 8:46 pm View latest post
No new posts Cross-platform examples for Linux, ma... kornerr Announcement [ANN] 6 Tue Aug 14, 2018 10:51 am View latest post
No new posts osglight demo problems with Intel gra... eventhorizon5 General 2 Mon Jul 09, 2018 8:52 pm View latest post
No new posts Build error under Windows? Need feedb... robertosfield General 3 Wed Jun 27, 2018 11:11 am View latest post
No new posts Where can i find the windows binaries peter_k General 2 Thu May 31, 2018 12:19 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP