Quote:Original post by ouraqt
Quote:To the above poster: it's actually not *that* hard. Look in to the SetWindowLong and SetWindowPos Win32 API calls. (Essentially you use SetWindowLong to modify the window's style parameters and then SetWindowPos to make sure that Windows actually recognizes the changes). Of course, you also have to make sure to reset the D3D device.
I know the API calls (thanks to MSDN) but I always get weird glitchy errors when changing the window style of a Direct3D window. (I've never actually tried to change the style of a NON-D3D win.) Has anyone done this successfully?
Yes, I have and it works fine, although I don't use SetWindowPos().
Quote:Original post by ouraqtQuote:You make it sound like OpenGL solves everything and is free of all problems. While it does solve some of the aforementioned issues, it definitely has issues of its own.
Of course it does. But I've heard that OpenGL handles more of the resource management than D3D does (I don't do OGL programming). I know, both of them are just 3D APIs.
It's good that you know that, but making statements like that is a really good way to start a flame war. It's especially bad to make a statement like that on hearsay[smile].
Quote:Original post by ouraqtQuote:Direct3D doesn't expect anything. It works perfectly fine if you have a WS_OVERLAPPEDWINDOW style, but you'll still be able to interact with the title bar, which can cause problems.
True, but you should NEVER have a fullscreen app that uses a WS_OVERLAPPEDWINDOW style. Not only does the title bar create problems, but also the corners are rounded in WinXP (so you could accidentally click on the window behind your game window).
The corners aren't necessarily rounded, it depends on the theme. But despite that, when you create a full screen device I'm pretty sure the window is maximized (And maximized windows don't have rounded corners. But I'm not positive that it maximizes the window.) Anyway, you're right and you should never create a fullscreen device for a window with a titlebar.
Quote:Original post by ouraqtQuote:Switching back and forth between windows styles is pretty trivial. It does require a slight hack to get back to the WS_OVERLAPPEDWINDOW, but nothing major. I don't have the time at the moment, but I'll dig through my library for a snippet later.
That is the problem I always encounted. I've never been able to switch back to a W_OVERLAPPEDWINDOW style. If I remember correctly, the window stops resoponding (I need to look over my code more, maybe I created some weird eternal loop with the window procedure or something).
This is the code I'm using at the moment. It works fine on all the computers that I've tested it on (6 if I remember correctly.)
if(!Fullscreen) { SetWindowLong(WndHandle, GWL_STYLE, WS_POPUP); PresentParams.Windowed = false; GuiManager.PreDeviceReset(); D3DSprite->OnLostDevice(); DeviceComPtr->Reset(&PresentParams); GuiManager.PostDeviceReset(); D3DSprite->OnResetDevice(); } else if(Fullscreen) { SetWindowLong(WndHandle, GWL_STYLE, WS_OVERLAPPEDWINDOW); PresentParams.Windowed = true; GuiManager.PreDeviceReset(); D3DSprite->OnLostDevice(); DeviceComPtr->Reset(&PresentParams); GuiManager.PostDeviceReset(); D3DSprite->OnResetDevice(); int Width = PresentParams.BackBufferWidth, Height =PresentParams.BackBufferHeight; int WindowX = 0, WindowY = 0; int WindowWidth = Width, WindowHeight = Height; RECT WndRect = {0, 0, Width, Height}; AdjustWindowRectEx(&WndRect, WS_OVERLAPPEDWINDOW, false, 0); WindowWidth = WndRect.right - WndRect.left; WindowHeight = WndRect.bottom - WndRect.top; GetWindowRect(GetDesktopWindow(), &WndRect); WindowX = (WndRect.right / 2) - (WindowWidth / 2); WindowY = (WndRect.bottom / 2) - (WindowHeight / 2); MoveWindow(WndHandle, WindowX, WindowY, WindowWidth, WindowHeight, FALSE); ShowWindow(WndHandle, SW_HIDE); ShowWindow(WndHandle, SW_SHOWNORMAL); }
Quote:Original post by ouraqtQuote:Use managed resources. Not a single resource that I create needs to be reset when I alt-tab out of my application. It may not be the most efficient or best way to do it, but it's easier and it's worked perfectly so far.
I use managed resources as well. But then you still need to reset all of the device states/settings, which can be annoying. Also, if you have any D3DX resources (ie. fonts or sprites) or cursor stuff then it needs to be done manually (I think).
True, I didn't actually think about that, but I usually don't use D3DX interfaces (ID3DXLine, ID3DXSprite, and ID3DXFont.) Still, if your resource management system is setup correctly, it shouldn't be a problem. I modified my system to support it by just supplying 2 functions.