VOGONS


First post, by lizard78

User metadata
Rank Newbie
Rank
Newbie

Hi all,
I've been writing a Glide backend for my game and I noticed the Voodoo cards don't really handle multitasking very well. It always freezes for me when tabbing back in. I've tried totally closing the glide context and re-initializing everything (uploading textures again etc) but it never works correctly. It seems like most Glide games simply disable task switching (alt tab etc) but I'm wondering if there are any Glide games that actually support it (that you can alt tab and back into)? I thought it was maybe an issue specific to the Voodoo 1 / 2 cards, but a Voodoo 3 exhibits similar odd behaviors. The 3dfx OpenGL ICD also doesn't really seem to handle this correctly - which leads me to believe this was just never really correctly implemented. Has anyone ever figured this out?

P.S.
The glide 3.x docs mention grSelectContext() to determine when resources have been lost (due to a different task being scheduled). This API makes no sense to me, what would happen if a task swap happened during the middle of rendering? I don't know, it seems kind of naive. Only thing I can kind of infer is the docs mention "inactivity" - I wonder if it is meant to deal with screensavers or something?

Reply 1 of 2, by lizard78

User metadata
Rank Newbie
Rank
Newbie

I ended up throwing in the towel on this. I tried quite a few different things but as far as I can tell there just isn't a good workaround. I ended up just disabling task switching for Glide mode and called it a day. There's an old Microsoft KB on how to do this - Q226359. On Windows 9x it's pretty easy, just masquerade as a screensaver. On Windows NT you need to install an input hook to intercept the specific events (Older versions of NT can't do this and have more limited options). It's a terrible hack but better than someone accidentally fat fingering the windows key and crashing the game.

Reply 2 of 2, by lizard78

User metadata
Rank Newbie
Rank
Newbie

Going to answer my own question over a year later just in case someone else wants to know this. In retrospect I should've posted this in the Video forum if someone wants to move it?

I recently looked into this again and I figured out how to get this working correctly. Part of why I couldn't get this working before is I was mixing different solutions, and the correct way to do this depends on if you have a voodoo with vga passthrough (like the 1 or 2) or a voodoo that supports 2D like the voodoo 3. You can probe for this difference in the Glide API with grGet() and GR_SUPPORTS_PASSTHRU. The Glide documentation isn't very good at explaining any of this and I didn't really figure out how it all worked until I read the driver code (which was made open source).

So anyway, for the passthrough voodoos it's actually really simple: When you get a deactivation event from windows (WM_ACTIVATEAPP) just disable the VGA passthrough with grDisable(GR_PASSTHRU) and then re enable it again when the window becomes active with grEnable(GR_PASSTHRU). Since they don't support 2D all the state and textures remain.

With the other voodoo it's trickier - and this is where I was getting hung up before. The correct way to do this is to call grSstWinClose() on the glide context when the application deactivates and re-create the window entirely when the app re activates with grSstWinOpen(). Another gotcha with these voodoos is this is essentially like a "device lost" event in DirectX - you need to setup the entire state and all the textures again. The key thing here is not to call grGlideShutdown() - this is unnecessary and I think what was screwing things up when I tried this before.