BMX 1.26: Center graphics window by default?
BlitzMax Forums/BlitzMax Programming/BMX 1.26: Center graphics window by default?
| ||
Hello! "Graphics 800,600,0" still doesn't center the window on the desktop by default. What changes do I have to make to the dx and opengl mods in order to enable that? I really hoped bmx 1.26 would finally do that "out of the box". Grisu |
| ||
Pretty sure these mods are lurking somewhere on the forum, we've both been there before ;-) (google search may reveral all). But the are mod tweaks which I don't like as I'd rather this stuff was standard. Be nice to have this in V1.28 (hint hint), although it's not need for Macs as Macs seem to do it automatically. |
| ||
Not mod tweaks at all, but API calls. The following links should help for Windows. As GA says, no need on Mac. Link 1: http://www.blitzbasic.com/codearcs/codearcs.php?code=1318 Link 2: http://www.blitzbasic.com/codearcs/codearcs.php?code=1345 I think they're basically the same, but do other things you may find useful. |
| ||
Thanks for the help. API calls are too slow and ugly. You'll see the window moving on screen when using them. Also you'll have to use the calls over and over -> each time when switching between screenmodes. @Alien: Yes, it's the same old story. :/ |
| ||
API calls are too slow and ugly. You'll see the window moving on screen when using them. Also you'll have to use the calls over and over -> each time when switching between screenmodes. True, but how many times does one switch between modes? I'd imagine most people switch once to their preferred mode and leave it there. The only time I switch a game I would normally play full-screen to windowed is when I'm running something in the background and want to keep an eye on it's progress. But that's just me. Still, it would be nice if BlitzMax did this automatically. After all, Blitz3D did. |
| ||
API calls are too slow and ugly. YEah I used these instead of a mod fix BUT I don't like them as the window is first drawn in the top left for a fraction of a second, then redraws in the middle. It looks bad. Players who ALWAYS start in wondowed mode would see this EVERY time. |
| ||
This is retarded behaviour and windows should be centered by default. |
| ||
Surely it's not *that* hard to fix it? Here's one for glgraphics.win32.c, in bbGLGraphicsCreateGraphics() method : if( depth ){ mode=MODE_DISPLAY; hwnd_style=WS_POPUP; }else{ HWND desktop = GetDesktopWindow(); RECT desktopRect; GetWindowRect(desktop, &desktopRect); rect.left = desktopRect.right / 2 - width / 2; rect.top = desktopRect.bottom / 2 - height / 2; rect.right = rect.left + width; rect.bottom = rect.top + height; mode=MODE_WINDOW; hwnd_style=WS_CAPTION|WS_SYSMENU; } It's not rocket science... |
| ||
And for dx... In d3d7graphics.bmx, TD3D7Graphics.Create() : If depth hwnd=CreateWindowExA( 0,_wndClass,title,WS_VISIBLE|WS_POPUP,0,0,width,height,0,0,hinst,Null ) Else Local style=WS_VISIBLE|WS_CAPTION|WS_SYSMENU Local rect[]=[32,32,width+32,height+32] Local desktopHWND:Int = GetDesktopWindow() Local desktopRect:Int[] = New Int[4] GetWindowRect(desktopHWND, desktopRect) rect[0] = desktopRect[2] / 2 - width / 2; rect[1] = desktopRect[3] / 2 - height / 2; rect[2] = rect[0] + width; rect[3] = rect[1] + height; AdjustWindowRect rect,style,0 hwnd=CreateWindowExA( 0,_wndClass,title,style,rect[0],rect[1],rect[2]-rect[0],rect[3]-rect[1],0,0,hinst,Null ) GetClientRect hwnd,rect width=rect[2]-rect[0] height=rect[3]-rect[1] EndIf Now ask BRL nicely for implementation... :-p |
| ||
I just didn't want to manually modify my modules after every release so I'd prefer a BRL solution, although I have a workaround for now. |
| ||
I just didn't want to manually modify my modules after every release so I'd prefer a BRL solution Because releases come so often :-) |
| ||
well they used too... |
| ||
Lol. Yea, we just got one this past week-ish ;). |
| ||
Eikon hooked everyone up. Where'd he go anyways!? |
| ||
Brucey - how do your solutions work on dual monitor displays? Are they centred horizontally on the width of the primary display, or across the width of the two? |
| ||
I don't have a dual monitor to try it out on. It depends what GetDesktopWindow() returns, probably. This is a nice example of multiple display position code : http://msdn.microsoft.com/en-us/library/ms534817.aspx Here's an exe of the following code using the modified BRL code : centered_dx.zip (75kb) SuperStrict Framework brl.d3d7max2d Graphics 640, 480, 0 While Not KeyDown(KEY_ESCAPE) Cls Flip Wend If anyone with dual setup wants to try it and see where it goes... :-) |
| ||
it centres itself in the middle of my left hand monitor for me, but it might not be the same for each graphics card and OS. (WinXP, Radeon X1300 Pro) |
| ||
Yep, works fine for me using two monitors. I didn't think it would. Wonder if this could be shoehorned into 1.30 as a permanent fixture before release? |
| ||
Can anybody else with a dual monitor setup try this please? DirectX EXE built with Blitzmax 1.30 (tiny 64k download). |
| ||
Seems to work fine here, it centered itself in the middle of my primary display in Windows, and when I switched my secondary screen to be my primary, it then centered itself in that :) I got a dual monitor setup, one 4:3 and one 16:10 (primary). |
| ||
Works okay here too... one 19" and one 17"... both set to 12x10 res. |