Get Desktop Deep and Herz

BlitzMax Forums/BlitzMax Programming/Get Desktop Deep and Herz

MacSven(Posted 2006) [#1]
How can i get the deep and the herz of the Desktop Screen?

This works:

x=Desktop().width
y=Desktop().height

Sven.


Grey Alien(Posted 2006) [#2]
Depth and Hertz in DirectX return 0 last time I looked, yet they work in OpenGL.

This works in DirectX to get the Hz:

?win32
Extern "win32"
	Function GetDeviceCaps%(hdc, nIndex)
End Extern

GetDeviceCaps(GetDC(0),VREFRESH)
?


but you have to call it (before) you create your game window (I think)


ImaginaryHuman(Posted 2006) [#3]
Look at the desktopext(ension) module from d:bug, search the forums, it's cross-platform.


MacSven(Posted 2006) [#4]
I need the screen deep and hertz from the actual Desktop Screen. I am working on a testprogram and the actual screen size and deep should be the same as the desktop. The height and the width work's great. Any idea's!

Code Sample:

For mode:TGraphicsMode=EachIn GraphicsModes()
width[i]=mode.width
height[i]=mode.height
deep[i]=mode.depth
herz[i]=mode.hertz
If width[i]=Desktop().width And height[i]=Desktop().height Then
AddGadgetItem combobox,width[i]+" x "+height[i]+" , "+deep[i]+" Bit , "+herz[i]+" Hertz",True
Else
AddGadgetItem combobox,width[i]+" x "+height[i]+" , "+deep[i]+" Bit , "+herz[i]+" Hertz"
EndIf
i=i+1
Next

But i need the deep and hertz, too.


Grey Alien(Posted 2006) [#5]
I just told you how to get the Hz.


tonyg(Posted 2006) [#6]
Look at the desktopext(ension) module from d:bug, search the forums, it's cross-platform.

Isn't this it?


ImaginaryHuman(Posted 2006) [#7]
Yes look for that module, it's free and it's in the module tweaks forum I think. It tells you the desktop hertz, bit-depth, width and height using o/s calls, and it works on all 3 platforms.


MacSven(Posted 2006) [#8]
Thanx to all! It work's great.


Chroma(Posted 2007) [#9]
As Grey Alien posted, if you wanna keep it simple, the code below works great too.
?win32
Extern "win32"
	Function GetDeviceCaps%(hdc, nIndex)
End Extern
?

Global desktop_width:Int = GetDeviceCaps(GetDC(0),HORZREZ)
Global desktop_height:Int = GetDeviceCaps(GetDC(0),VERTREZ)
Global desktop_bpp:Int = GetDeviceCaps(GetDC(0),BITSPIXEL)
Global desktop_hertz:Int = GetDeviceCaps(GetDC(0),VREFRESH)



smilertoo(Posted 2007) [#10]
Getting the hertz in dx mode seems to be an issue even MS are having problems with, XNA got it wrong as well.
XNA people said theyre just going to check the desktop hertz when a game runs and try to match it.


JazzieB(Posted 2007) [#11]
If you only need the current desktop settings as a means to determine what mode to set in your game/app, then whether you're in DX mode shouldn't matter, as all you'd do (as I do) is get these settings before any graphcis mode and/or drivers are set. The DesktopExt module works a treat in this way.

I've used this on my PC (4:3 CRT) and my laptop (16:10 TFT) and my game picked the correct resolution for the aspect ratio of the monitor in use, using the depth and hertz setting of the desktop. No more defaulting to 640x480x16 @ 60hz if someone is already using a monitor capable of 32bpp and >60hz.

Of course, you may have a different reason/time for needed to check these settings after a graphics mode has been set.


d-bug(Posted 2007) [#12]
Yeah, chroma, it's exactly what I'm doing in this module to get hertz and bpp, but GetDeviceCaps will only return width and height values from the primary display of multi-display systems.