Changing the display DPI of the renderer

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

icetea
Just popping in
Just popping in
Posts: 11
Joined: Thu Sep 25, 2014 11:10

Changing the display DPI of the renderer

Postby icetea » Tue Oct 07, 2014 21:43

I created some menus with CEGUI based on mockups from our designer. These mockups also provided the font sizes on a basis of 72 DPI. After wondering, why the text is way too big in many places, I looked at the display DPI set by the renderer. Looking at the source code (of the Ogre renderer), it is set to 96x96 on construction and I haven't seen any way to change it from the outside (setDisplayDPI or similar). I can only get the value through getDisplayDPI. Have I missed something or is there really no way to change that?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Changing the display DPI of the renderer

Postby Ident » Wed Oct 08, 2014 17:41

DPI is pretty meaningless on a computer as they are not actual dots per inch. This will only be true for print. Nevertheless I understand where your question (or your designer's question) is coming from. I looked into it in our code and checked how this value is used. The DPI in our case is only used for one purpose: Font sizes. This is exactly what you noticed and beyond that it is not used anywhere. The setter is currently not exposed for this.

I doubt a setter honestly makes much sense. THis is something you only wanna set once when you create the Renderer. Could you be so kind to open your CEGUI project, look for the code "d_displayDPI(96" and replace the 96's there both with the number you want? After that please compile and use the compiled binaries for your project. Does everything still work as expected then? If yes, then I will think of a way to aloow changes to this setting.
CrazyEddie: "I don't like GUIs"

icetea
Just popping in
Just popping in
Posts: 11
Joined: Thu Sep 25, 2014 11:10

Re: Changing the display DPI of the renderer

Postby icetea » Thu Oct 09, 2014 09:20

Ident wrote:Could you be so kind to open your CEGUI project, look for the code "d_displayDPI(96" and replace the 96's there both with the number you want? After that please compile and use the compiled binaries for your project. Does everything still work as expected then?
I did that and linked the altered Ogre renderer instead of the the "normal" one. Everything still works, but strangely the resulting font sizes with 72 set are still the same as before with the "normal" renderer setting d_displayDPI(96, 96).

Edit:
Stupid me...had the symlink pointing to the wrong lib for execution. Now the font sizes are correct and everything else works fine.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Changing the display DPI of the renderer

Postby Kulik » Thu Oct 09, 2014 09:47

So we just need to expose a method to change DPI, right? I suspect this has to be done before any resource loading commences.

icetea
Just popping in
Just popping in
Posts: 11
Joined: Thu Sep 25, 2014 11:10

Re: Changing the display DPI of the renderer

Postby icetea » Thu Oct 09, 2014 15:37

Kulik wrote:So we just need to expose a method to change DPI, right? I suspect this has to be done before any resource loading commences.
Yep, I think that works. Might be a little off topic, but I am working with CEED to create layouts and have the same issue there obviously. I would really appreciate it if you guys can add an option to change the DPI there as well.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Changing the display DPI of the renderer

Postby Ident » Thu Oct 09, 2014 16:05

There is two ways to solve this.

The easy one would be: Set the DPI only once namely in the creation of the renderer ( this could easily be done by adding a parameter which is set to 96 by default and using it in the initialiser list) and in the bootstrap function of the System. The rationale behidn this would be: you would normally never change it for the Renderer in runtime and you only wanna set this once anyways.

The other way would be to do it per Font. This should (imo) not be difficult to add and can be done in XML. There could still be a default value for this in the Font manager. So before u load the fonts, you could change the Font manager default, and then it would be applied to all loaded fonts, unless they do not inherit this value. They would not inherit it in case their attribute (let's call it "DPI") is set to a number. If it is not set, or set to "inherit" it should inherit the value. This would allow for precise control but the question is: is this necessary? (we might be able to add this to v0-8 though. which i doubt is possible with above solution #1)
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 35 guests