I'm trying to reset a d3d device in the WM_SIZE event of a window, but it's causing access violations all over the place. I'm guessing this is because WndProc is on a different thread or something. All the examples I can find do exactly what I'm trying.
This is my code:
[cpp]
void MessageCallback( Window* wnd, UINT a, WPARAM b, LPARAM c, void* userdata )
{
UserData* ud = static_cast< UserData* >( userdata );
if( a == WM_CLOSE )
wnd->Close( );
else if( a == WM_SIZE )
{
int w = c & 0xFFFF;
int h = ( c >> 16 ) & 0xFFFF;
ud->dev->Resize( w, h );
}
}
[/cpp]
D3DDevice::Resize:
[cpp]
void Resize( int w, int h )
{
if( device ) // access violation
{
params.BackBufferWidth = w;
params.BackBufferHeight = h;
device->Reset( ¶ms );
}
}
[/cpp]
Am I doing it wrong? I can't seem to find anything that wasn't written a hundred years ago in some ancient version of VS.
Lock it with a mutex I'd say.
Only atomic operations (operations that take one tick) will work properly with threaded objects.
Would help with some more code.
Like how is "device" defined?
I have no idea what I just did, but something fixed it. I have been working on this for about 30 minutes now. Don't you hate it when that happens? I'll probably change something and break it again. :saddowns:
Sorry, you need to Log In to post a reply to this thread.