|
*brammie*
|
 |
« on: May 23, 2008, 02:53:34 PM » |
|
does anyone know how to make a good alt-tab handler for directx?
|
|
|
|
|
Logged
|
|
|
|
|
*brammie*
|
 |
« Reply #1 on: May 25, 2008, 09:04:36 PM » |
|
-bump- nobody?
|
|
|
|
|
Logged
|
|
|
|
|
biggoron
|
 |
« Reply #2 on: May 25, 2008, 09:48:31 PM » |
|
What's to handle?
|
|
|
|
|
Logged
|
|
|
|
|
Melastoma
|
 |
« Reply #3 on: May 25, 2008, 10:39:55 PM » |
|
What's to handle?
When you alt-tab from a full screen DirectX app, you have to reset the device and re-create all the resources that were in video memory. I've never really looked into it, but I read somewhere that a good thing to do would be to have it call the initialization procedure once the window is re-activated. *Shrug*
|
|
|
|
|
Logged
|
The language itself isn't complicated, it's getting it to do what you want that's the puzzle. Here, Here.That, my friend, should be on a T-shirt, or in somones signature. 
|
|
|
|
*brammie*
|
 |
« Reply #4 on: May 26, 2008, 11:53:16 AM » |
|
ok thanks, ill try it out when i come home  edit: it works, but now, if i alt-tab out of it, it directly goes back without alt-tabbing in it. this is my code: HRESULT hr; hr=d3ddev->TestCooperativeLevel(); if (hr==D3DERR_DEVICELOST || hr==D3DERR_DEVICENOTRESET) enable_d3d(hwnd,hi); how could i make it wait until i alt-tab back in?
|
|
|
|
« Last Edit: May 26, 2008, 02:37:28 PM by *brammie* »
|
Logged
|
|
|
|
|
TheoLogic
|
 |
« Reply #5 on: May 26, 2008, 03:54:39 PM » |
|
D3DERR_DEVICELOST tells you that the device is lost, but it can't be resetted yet. So maybe do this; if(hr == D3DERR_DEVICELOST) { Sleep(100); //Wait a bit so we don't burn through cycles for no reason } else if(hr == D3DERR_DEVICENOTRESET) { m_pd3dDevice->Reset(&d3dpp); }
|
|
|
|
|
Logged
|
|
|
|
|
Melastoma
|
 |
« Reply #6 on: May 26, 2008, 10:41:09 PM » |
|
You can also use " WM_ACTIVATE", which I believe is called anytime a window gains or loses focus.
|
|
|
|
|
Logged
|
The language itself isn't complicated, it's getting it to do what you want that's the puzzle. Here, Here.That, my friend, should be on a T-shirt, or in somones signature. 
|
|
|
|
*brammie*
|
 |
« Reply #7 on: May 27, 2008, 07:43:01 AM » |
|
well, i did try this: HRESULT hr; hr=d3ddev->TestCooperativeLevel(); if (hr==D3DERR_DEVICENOTRESET) enable_d3d(hwnd,hi);
but it won't work. so i think i would try WM_ACTIVATE, ill edit if it works 
|
|
|
|
|
Logged
|
|
|
|
|
TheoLogic
|
 |
« Reply #8 on: May 27, 2008, 08:18:30 AM » |
|
Alt-tab is a sizemove... case WM_SIZE: switch(wParam){ case SIZE_MAXIMIZED: m_bFullScreen=true; break; case SIZE_MINIMIZED: m_ptrGame->GameEnd(); bIsMinimised=true; break; case SIZE_RESTORED: if(bIsMinimised){ m_ptrGame->GameStart(); bIsMinimised=false; } //if(bSizeMoved){//after a resize, not during resizing // FullOrWindowed(); // bSizeMoved=false; //} break; } break; This way changes the size also to fullscreen to windowed, but I think u'll get the idea 
|
|
|
|
|
Logged
|
|
|
|
|
*brammie*
|
 |
« Reply #9 on: May 27, 2008, 02:59:27 PM » |
|
WM_SIZE works, thanks =) case WM_DESTROY: PostQuitMessage (0); break; case WM_SIZE: if (alt_tab_reset && wParam==SIZE_RESTORED) enable_d3d(hwnd,pass); break; default: return DefWindowProc (hwnd, message, wParam, lParam); break;
|
|
|
|
|
Logged
|
|
|
|
|
TheoLogic
|
 |
« Reply #10 on: May 27, 2008, 06:27:01 PM » |
|
Glad to be of service. All those little things make a programmers life difficult  I'm programming a mini RTS in DX too, and it's getting the hell out of me. HLSL is cool too, but man, difficult 
|
|
|
|
|
Logged
|
|
|
|
|