I think also this would be very convenient if there was an SDL /
cross-platform way to get this information (in horizontal and vertical
direction separately).
(But that has nothing to do with phone or tablet !)
some information mac/linux :
http://stackoverflow.com/questions/2621439/how-to-get-screen-dpi-linux-mac-programaticallyOn Mon, Jun 30, 2014 at 7:12 PM, Andre Leiradella wrote:
On Windows, I use
HDC hDC = GetWindowDC( NULL );
int hor_mm = GetDeviceCaps( hDC, HORZSIZE );
int ver_mm = GetDeviceCaps( hDC, VERTSIZE );
To check the screen dimensions, though my use case is to get the true
monitor aspect ratio. I don’t know if other platforms have something
similar, and maybe nowadays every monitor/screen have square pixels so that
one could just get the screen resolution to find the aspect ratio.
Cheers,
Andre
On 30/06/2014 10:19, zackslash wrote:
Thank you for this answer, it may do the job for now [image: Very Happy]
Pallav Nawani wrote: No, SDL doesn’t have a way to retrieve pixel
density. However, you can get the Desktop resolution. Use that. For example:
DrawWidth = 0.4 * ScreenWidth (40% of screen width).
Now use SDL_Render functions to draw image with the calculated size.
Of course this is not always useful, but you will be surprised how many
times you can get by with just this.
Pallav Nawani
IronCode Gaming Private Limited
Website:? http://www.ironcode.com
Twitter:? http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768
On Wed, Jun 25, 2014 at 6:34 PM, zackslash <> wrote:
Quote: Hey,
I’ve double checked the documentation and searched in the usual places but
can’t seem to find any indication as to if SDL 2.0 has any methods for
retrieving the device’s pixel density.
I would like to draw images at their density independent size so that
something rendered on say a extra high resolution android device will be
the same on any other device such as an iPhone with the same size screen
but a different pixel density.
I know that I can make calls through JNI and other platform specific
methods, but it would be very convenient if there was an SDL /
cross-platform way to get this information.
Any replies much appreciated.
Thanks
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
Sylvain Becker