Click to See Complete Forum and Search --> : [RESOLVED] Windows UI Drawing Method Adapts to Available Resources?


TheGreatCthulhu
February 17th, 2010, 05:58 AM
Maybe this is not the right forum, but it is a question related to graphics programming, so...

A friend of mine has Windows 7 on his laptop, and DirectX runtime is not installed (except for the Direct2D libraries (I think – no more DirectDraw, right?) that apparently come with Windows). Now, we were playing some Sega Genesis games using the Gens emulator, set to use “DirectDraw” option since Direct3D is not available.
If u ever used this emulator, you know that when u run it the screen turns black for a moment, while the program initializes its graphics system.

I noticed that Windows 7 changes its behavior while Gens is running, in terms of UI presentation – the blurry window frame becomes solid, app thumbnail representations (when you hover the mouse pointer over an app button on the taskbar) are replaced with text, etc.

Is this a result of Windows readjusting itself to the available resources, or the program somehow changes the way Windows draws its UI? Is the latter even possible?

Mike Harnad
February 26th, 2010, 01:01 PM
I'm betting that it's an incompatibility issue. DirectX is now on version 11.

TheGreatCthulhu
February 27th, 2010, 04:48 AM
Could be.
(Just in case there was a misunderstanding: Gens runs fine - it's what's going on during the initialization, and how it effects the UI, that I'm interested in.)
But I think this is the way the application operates - I noticed the emulator has similar effect on WinXP, except it's far more subtle (see the attachment).

I'm thinking it could be some hack by the developers used to maximize performance (and this is what makes it interesting; however, in that case this is something only the developers could answer).

But, it could also be related to a number of things - maybe it's some mechanism of the OS, or maybe it has something to do with SDL (since the app uses it), or it could even be related to the GPU.

P.S. As for the disabled Direct3D option, it seems that I was wrong - in this variant of Gens (Gens Plus), it appears that it always stays disabled (even on systems that can support it), indicating that this is only a feature that is planned for a future version.

ATTACHMENT: Effects on Windows XP (start menu icons)

hoxsiew
February 27th, 2010, 09:08 AM
I would guess from those image captures that it is setting the screen bpp to some lower mode.

As for your earlier comment about Windows7, there's one or two legacy apps (the only one I can think of right now is WinAVI when it starts an mpeg remux) that cause this behavior in Win7; however, on my system, it warns me with a popup balloon, telling me that the application requires that the UI be set to some mode or other. I can't recall the exact message, but it has the same effect: the glass-look and hover glow stuff all goes away until the app is done.

Mike Harnad
March 1st, 2010, 07:32 AM
Have you tried runing the app in XP compatibility mode? Do you get different results?

TheGreatCthulhu
March 2nd, 2010, 10:41 AM
Have you tried runing the app in XP compatibility mode? Do you get different results?
I tried to play with compatibility modes to see what happens, but I observed no significant differences. Again, the application runs the way it's supposed to, and this behavior is normal and expected. I just wanted to know what is happening during initialization and how it is done.

I would guess from those image captures that it is setting the screen bpp to some lower mode.


Turns out you were right. I was so blinded by my theory that it is some exotic code that is behind it (:rolleyes:), that I didn't see it.
This is the simplest explanation and it is correct. I've done some research, and there's no doubt anymore.

First, take a look at the image I attached, showing the effect on Windows 7, and on the display mode.

Second, as I said before, this program uses SDL, and in SDL documentation you can find the following method:
SDL_Surface* SDL_SetVideoMode(int width, int height, int bitsperpixel, Uint32 flags);


Third, Gens is an open Source project, so when I downloaded the code I searched for this method, and I found the following line in the file g_sdldraw.c (version gens-2.15.5, path: src\gens\sdllayer\g_sdldraw.c, Ln 217), in a method called Init_draw_sdl:

screen = SDL_SetVideoMode(w,h,16,sdl_flags|(Full_Screen?SDL_FULLSCREEN:0));

Note that the third parameter is set to 16 bpp.
I also tried to change the screen bpp manually back to 32 bpp using display settings, which revealed that Gens won't display anything at all in this mode.


And finally, I was able to find a change log somewhere on the net, with the foolowing entry:

(02/09/2000) Changes Gens 0.8 <- Gens 0.78b :
---------------------------------------------

[...]

* Auto Switch to 16 BPP when Gens starting
(settings are recovered when Gens exiting)

[...]


As for the behavior of Windows 7 - this means that it has different UI rendering strategies for different display settings.