Re: Multiple windows and multithreading
From: mikegi (mikegi_at_prestige.net)
Date: 03/03/04
- Next message: michael m. hen: "Re: [Help Pls] I don't grasp this C/C++ code"
- Previous message: Le Géant Vert: "Re: [Help Pls] I don't grasp this C/C++ code"
- In reply to: Danil Shebounin: "Re: Multiple windows and multithreading"
- Next in thread: Danil Shebounin: "Re: Multiple windows and multithreading"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Mar 2004 23:24:52 -0500
> Unfortunately, I have to build-in my new code into existed and
> old enough application. The application have a following data
> processing algorithm: there is some data source (recording of
> the aircraft parameters during flight) and there are many
> representations of the data. Each representation is in separate
> window in separate thread (don't ask me why).
[I'm talking out of my rear end here since I have never written a
multithreaded Direct3d app, but anyway ...]
I'd try creating a small set of routines that manage the d3d device:
CreateD3DDevice -- This function is called from WinMain. It creates the d3d
device with a back buffer sized to the full screen. It also creates a mutex
or critical section to manage access to the device.
GetD3DDevice -- This is called at the beginning of each window's render
proc. It waits on the mutex/CS created in InitD3D then returns the device.
ReleaseD3DDevice -- This is called at the end of the window's render proc.
It releases the mutex/CS so that another thread can get access to the
device.
DestroyD3DDevice -- Called just before WinMain exits. It does
device->Release() and closes the mutex.
> Can I, for example, create swap chain sized to screen dimensions
> for current mode? But how to tell DirectX not to scale back buffer
> contents, when they drawed in the window. Use viewport? Is there
> any example of such a technique?
I use the following code at the beginning of the rendering proc in my app to
handle window resizing. I create the device with a full screen-sized back
buffer.
//------------------ Adjust viewport if necessary ---------------------
D3DVIEWPORT8 vp;
device->GetViewport( &vp );
if( vp.X != 0 || vp.Y != 0 ||
vp.Width != (UINT)cxClient || vp.Height != (UINT)cyClient )
{
vp.X = 0;
vp.Y = 0;
vp.Width = cxClient;
vp.Height = cyClient;
device->SetViewport( &vp );
}
//------------------------- Render scene ------------------------------
[... rendering crap ...]
//-------------------------- Display it -------------------------------
RECT rc;
rc.left = 0;
rc.top = 0;
rc.right = cxClient;
rc.bottom = cyClient;
device->Present( &rc, &rc, hwnd, NULL );
It would be smarter to call GetD3DDevice with cxClient and cyClient. By
funneling all viewport requests through a single point you could eliminate
the GetViewport call.
- Next message: michael m. hen: "Re: [Help Pls] I don't grasp this C/C++ code"
- Previous message: Le Géant Vert: "Re: [Help Pls] I don't grasp this C/C++ code"
- In reply to: Danil Shebounin: "Re: Multiple windows and multithreading"
- Next in thread: Danil Shebounin: "Re: Multiple windows and multithreading"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|