Ahoy, people with multiple monitors!
Blitz3D Forums/Blitz3D Programming/Ahoy, people with multiple monitors!
| ||
Hi, I'm trying to figure out if it's possible to open a 3D graphics window reliably on a multiple monitor setup. So if you have more than one monitor, it would be great if you would run this file: http://www.frecle.net/giles/download/MultipleMonitor3DTest.zip And let me know if it works! |
| ||
Here is the source code, if you don't want to download the executable:Type WinPoint Field X,Y End Type Type WinRect Field x,y,w,h End Type ; Desktop Size Const SM_CXSCREEN=0 Const SM_CYSCREEN=1 ; Set Window Long Const GWL_WNDPROC =(-4) Const GWL_HINSTANCE =(-6) Const GWL_HWNDPARENT =(-8) Const GWL_STYLE =(-16) Const GWL_EXSTYLE =(-20) Const GWL_USERDATA =(-21) Const GWL_ID =(-12) ; Window Style Const WS_OVERLAPPED =$0 Const WS_POPUP =$80000000 Const WS_CHILD =$40000000 Const WS_MINIMIZE =$20000000 Const WS_VISIBLE =$10000000 Const WS_DISABLED =$8000000 Const WS_CLIPSIBLINGS =$4000000 Const WS_CLIPCHILDREN =$2000000 Const WS_MAXIMIZE =$1000000 Const WS_CAPTION =$C00000 Const WS_BORDER =$800000 Const WS_DLGFRAME =$400000 Const WS_VSCROLL =$200000 Const WS_HSCROLL =$100000 Const WS_SYSMENU =$80000 Const WS_THICKFRAME =$40000 Const WS_GROUP =$20000 Const WS_TABSTOP =$10000 Const WS_MINIMIZEBOX =$20000 Const WS_MAXIMIZEBOX =$10000 Const WS_TILED =WS_OVERLAPPED Const WS_ICONIC =WS_MINIMIZE Const WS_SIZEBOX =WS_THICKFRAME Const WS_OVERLAPPEDWINDOW=(WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) Const WS_TILEDWINDOW =WS_OVERLAPPEDWINDOW Const WS_POPUPWINDOW =(WS_POPUP Or WS_BORDER Or WS_SYSMENU) Const WS_CHILDWINDOW =(WS_CHILD) ; Window Messages Const SW_HIDE=0 Const SW_SHOWNORMAL=1 Const SW_NORMAL=1 Const SW_SHOWMINIMIZED=2 Const SW_SHOWMAXIMIZED=3 Const SW_MAXIMIZE=3 Const SW_SHOWNOACTIVATE=4 Const SW_SHOW=5 Const SW_MINIMIZE=6 Const SW_SHOWMINNOACTIVE=7 Const SW_SHOWNA=8 Const SW_RESTORE=9 Const SW_SHOWDEFAULT=10 Const SW_MAX=10 Type win Field TempPos.WinPoint Field MousePos.WinPoint Field WindowRect.WinRect Field DesktopW,DesktopH Field hWindow Field WindowStyle Field W,H,X,Y Field MX,MY,MZ,MSX,MSY,MSZ End Type Global origw,origh ; ; This function initializes the actual blitz window Function InitBlitzWindow() ; Prepare custom types win\TempPos.WinPoint = New WinPoint win\MousePos.WinPoint = New WinPoint win\WindowRect.WinRect = New WinRect ; Get Desktop Dimensions win\DesktopW = User32_GetSystemMetrics(SM_CXSCREEN) win\DesktopH = User32_GetSystemMetrics(SM_CYSCREEN) origw = win\DesktopW origh = win\DesktopH ; Initialize Graphics Window If Windowed3D() notok = True While notok If GfxModeExists(win\DesktopW,win\DesktopH,32) Graphics3D win\DesktopW,win\DesktopH,0,2 notok = False Else win\DesktopW = Win\DesktopW - 1 If win\DesktopW<640 RuntimeError "Couldn't find appropriate 3D resolution, please use a single monitor setup!" End If End If Wend Else RuntimeError "Sorry, your graphics card does not support 3D in a window!" End If ; Get hWnd pointer for the Blitz Window win\hWindow = User32_GetActiveWindow() ; Set the Blitz Window Style win\WindowStyle = WS_VISIBLE + WS_BORDER + WS_MINIMIZEBOX + WS_MAXIMIZEBOX + WS_SIZEBOX + WS_SYSMENU + WS_DLGFRAME;+ WS_THICKFRAME User32_SetWindowLong(win\hWindow,GWL_STYLE,win\WindowStyle) ; Resize and center Blitz Window User32_MoveWindow(win\hWindow,(win\DesktopW/2)-(640/2),(win\DesktopH/2)-(480/2),640,480,True) End Function Function UpdateBlitzWindow() User32_GetWindowRect(win\hWindow,win\WindowRect) win\WindowRect\w = win\WindowRect\w-win\WindowRect\x win\WindowRect\h = win\WindowRect\h-win\WindowRect\y If win\WindowRect\w<320 toosmall = True win\WindowRect\w = 320 End If If win\WindowRect\h<240 toosmall = True win\WindowRect\h = 240 End If If toosmall User32_MoveWindow(win\hWindow,win\WindowRect\x,win\WindowRect\y,win\WindowRect\w,win\WindowRect\h,True) End If ; Get Screen position of pixel 0,0 win\TempPos\x = 0 win\TempPos\y = 0 User32_ClientToScreen(win\hWindow,win\TempPos) win\X = win\TempPos\x win\Y = win\TempPos\y ; Get Width and Height of the Blitz Window User32_GetClientRect(win\hWindow,win\WindowRect) win\W = win\WindowRect\w win\H = win\WindowRect\h Viewport 0,0,win\W,win\H ; Store old mouse position win\MSX = win\MX win\MSY = win\MY win\MSZ = win\MZ ; Get the mouse position (even if mouse is outside the Blitz Window) User32_GetCursorPos(win\MousePos) User32_ScreenToClient(win\hWindow,win\MousePos) win\MX = win\MousePos\x win\MY = win\MousePos\y win\MZ = MouseZ() ; Update Mouse Speed win\MSX = win\MX-win\MSX win\MSY = win\MY-win\MSY win\MSZ = win\MZ-win\MSZ End Function ; Example Global win.win = New win InitBlitzWindow() SetBuffer BackBuffer() Repeat Cls UpdateBlitzWindow() Text 0, 0,"Window Width - "+win\W Text 0,10,"Window Height - "+win\H Text 0,20,"Window X - "+win\X Text 0,30,"Window Y - "+win\Y Text 0,40,"Mouse X - "+win\MX Text 0,50,"Mouse Y - "+win\MY Text 0,80,"Desktop W - "+origw Text 0,90,"Desktop H - "+origh Text 0,110,"Window Max W - "+win\DesktopW Text 0,120,"Window Max H - "+win\DesktopH Flip Until KeyHit(1) EndYou need some userlib declarations from this code archive entry: http://www.blitzbasic.com/codearcs/codearcs.php?code=829 Thanks in advance! |
| ||
Hi, I got no problems with it, but what should it do? It tracks the mouse even inside my second screen. |
| ||
So it opens the window? That's what I wanted to know :) Thanks! What does it say about desktop and window max sizes? |
| ||
works here Desktop W - 1280 Desktop H - 1024 Window Max W - 1280 window Max H - 1024 i'm running 2 monitors each with 1280 x 1024 WinXP Radeon 9700 |
| ||
works Desktop W - 1024 Desktop H - 768 Win Max W - 1024 Win Max H- 768 specs in sig |
| ||
I'll try that when I get back to work (next monday). |
| ||
The radeon series cards only do 3d acceleration on the primary monitor in either D3D or OpenGl , sad but true :-( However there is a hardware mod to change your card to a FireGl. 2 monitors here 1280*1024 Radeon9700pro |
| ||
@maverik: but TombRaider - angel of darkness can be played with both monitors, even on a Radeon |
| ||
works Desktop W - 1280 Desktop H - 960 Window Max W - 1280 Window Max H - 960 ...which is my primary monitor, 21" CRT. Secondary monitor is 18" TFT using 1280*1024 resolution. |
| ||
Ok, so it seems to work mostly...Are you all using Radeon cards? Do someone have a triple monitor setup or more? I know some people have had problems running both Tattoo and gile[s] on multiple monitor setups. It would be nice if this could be fixed. |
| ||
works Desktop W - 1280 Desktop H - 1024 Window Max W - 1280 Window Max H - 1024 Gives mouse position accross multiple monitors,... window can be dragged to either monitor with no problems. Nvidia Quadro 900FX card,... Dual 19" sony Flatscreens |
| ||
works for me too, but... Desktop W - 1280 Desktop H - 1024 Window Max W - 1280 Window Max H - 1024 Gives mouse position across multiple monitors just fine, but dragging the window to my 2nd mointor I noticed it seems to take longer to refresh the screen compared to my primary monitor. Windows 2K Intel Pentium III Xeon (2 CPUs), 730mhz 2 RIVA TNT2/PRO cards |