would you support a windowed-mode pro game?

Started by
17 comments, last by ouraqt 17 years, 7 months ago
Off Topic:

Quote:Original post by penwan
If anybody sees anything glaringly wrong, be sure to let me know

Nothing glaringly wrong, just a matter of taste: You can gain the slightest increase in speed, code size and readability with:

if (fullscreen == IsFullscreen()) return SUCCESS;if (fullscreen) {    // Set Fullscreen} else {    // Set Windowed}


This in no way warranted a reply, but that toggle-if structure you are using has always bugged me [rolleyes].

Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Advertisement
Quote:Original post by Rockoon1
Certainly if development is being done with it as a windowed application, then there is no big reason to take advantage of exclusive mode unless performance has become a concern.

I'd go with a maximized window with no border or title bar as the "full screen" option given to the user.. the end user doesnt care how its implimented.


The driver is likely to understand that qs q fullscreen mode and enter fullscreen mode automatically. It is how I implemented it in two previous engines and both ati and nvidia drivers treated this as a real fullscreen mode.

Ultimately, it means that you have to manage the disposable resources, as well as the device lost state - which is, I think, the biggest problem in a game. Fortunately, this problem can be solved with a clever design of your resource classes (resources that are likely to be reseted should be duplicated in memory. During the reset, loop over the resources to reset them - if the resource is managed oor in the system pool you don't have to do anything, but if the resource is in the default pool, you'll have to release it and recreate it once the you have reseted the device. The pseudo code I used was something along the line of:
if (device lost){  for each resource  {    if resource needs to be reseted    {      release resource      released_resource.push_back(resource);    }  }  if (reset device ok)  {    for each resource in released_resources      recreate resource  }}

Since device reset happen only in a limited number of situations (alt-tab, hibernation, ...) you don't really care if it takes a few seconds to rebuild the whole thing.

Of course, it needs you to create some kind of abstraction around the driver and the resource. If you didn't do that, you'll have hard time to figure what resource should be released and recreated - and the whole thing becomes a PITA.

HTH,
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?
Quote: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.
Quote: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).
Quote: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).
Quote: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).
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 ouraqt
Quote: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 ouraqt
Quote: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 ouraqt
Quote: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 ouraqt
Quote: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.
i want to say:
i would never play a game in window mode.
full-screen only is ok for me, as long as you can alt-tab and alt-f4.
i think theres no need to have a windowed game with resizing and whatever.
Quote: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.
I suppose it does depend on the theme (most people just use Luna), however you should never assume the user will have a particular theme anyway.

Also, I made a fullscreen FPS demo with a WS_OVERLAPPEDWINDOW window. The corners were still rounded. If you want a window maximized, you have to do it yourself (but you should be using WS_POPUP anyways).
Quote:Yes, I have and it works fine, although I don't use SetWindowPos().
I think you should use SetWindowPos(...) so Windows will update the window cache.
Quote:True, I didn't actually think about that, but I usually don't use D3DX interfaces (ID3DXLine, ID3DXSprite, and ID3DXFont.)
So what do you draw text with? I suppose you could make your own text-drawing engine, but that would take forever! You must be a real D3D guru. I don't really use ID3DXLine much, but what about ID3DXSprite? It makes drawing sprites (and particles!) much easier. You hand-code all of this yourself?
Quote: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.)
I'll look at it and see if it works for me. I think the source of my glitches was a poorly programmed message loop. You always have to remember to avoid calling your WinProc from within your WinProc. Many Windows dunctions will inevitably call your window procedure without telling you first (which could easily make your app hang).
Quote:Original post by ouraqt
Quote: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.

I suppose it does depend on the theme, however you should never assume the user will have a particular theme anyway.

Agreed[smile].

Quote:Original post by ouraqt
Also, I made a fullscreen FPS demo with a WS_OVERLAPPEDWINDOW window. The corners were still rounded. If you want a window maximized, you have to do it yourself (but you should be using WS_POPUP anyways).

Thanks, that's good to know. Now I can stop telling people bad information lol.

Quote:Original post by ouraqt
Quote:Yes, I have and it works fine, although I don't use SetWindowPos().

I think you should use SetWindowPos(...) so Windows will update the window cache.

Thanks for the info. I actually was reading through the documents to see how SetWindowPos(). I'll be updating my library when I'm done posting[smile].

Quote:Original post by ouraqt
Quote:True, I didn't actually think about that, but I usually don't use D3DX interfaces (ID3DXLine, ID3DXSprite, and ID3DXFont.)

So what do you draw text with? I suppose you could make your own text-drawing engine, but that would take forever! You must be a real D3D guru. I don't really use ID3DXLine much, but what about ID3DXSprite? It makes drawing sprites (and particles!) much easier. You hand-code all of this yourself?

Font engines are pretty easy to do once you learn the algorithms, the only real problem I've had is batching things. I coded a system that is very similar to ID3DXSprite, but a custom system allows for much more flexibility.
I prefer windowed mode myself. That way I can multi task better. Play a game keep an eye on other things. Plus it is easier to minimize when the boss comes by.
So is the best way to switch from fullscreen/windowed mode to change the window style? Or is it better (and more stable) to create 2 windows, with different styles, and only allow one to be visible at a time? Microsoft should explain this to us.

I think it might be unsafe to be drawing on a window other than your main window (you can only have one main window). Actually if I remember correctly, D3D takes in a window for input (so when the window looses focus the device is lost, etc.) and an optional, different window for drawing (just pass a different window handle to Present(...)). Hmm...

This is a common factor that nearly very game incorporates in one way or another, so why is it so perplexing to me?

This topic is closed to new replies.

Advertisement