关于directx9 立体图像停止渲染,窗口与全屏的切换等。50分在线等!!
的年 2013-04-10 02:07:59 vs2008,c++,directx9
以打开对话框的方式选择左右文件后,对左右图像文件进行3D渲染,并显示。
但在窗口内显示的时候无法合成,全屏显示的时候左右图片能合成并呈现立体效果。
问题1:
想通过选择菜单项“全屏”然后将原来在窗口模式播放的切换成全屏播放,在网上查资料看到三步:
onLostDevice(); 怎么写??
pDevice->Reset(&d3dpp);
onResetDevice();
但不知道这些函数具体怎么写??
//D3D初始化
void initD3D(HWND hWnd)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = true; // program fullscreen 原来false
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; // set the back buffer format to 32 bit
d3dpp.BackBufferWidth = gImageWidth;
d3dpp.BackBufferHeight = gImageHeight;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; //原来D3DPRESENT_INTERVAL_ONE
d3dpp.BackBufferCount = 1;
// create a device class using this information and information from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
}
void render_frame(void)
{
// clear the window to a deep blue
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
d3ddev->BeginScene(); // begins the 3D scene
// do 3D rendering on the back buffer here
render3D();
d3ddev->EndScene(); // ends the 3D scene
d3ddev->Present(NULL, NULL,NULL, NULL); // displays the created frame 原来为NULL
}
void render3D(void)
{
// set destRect
destRect.left = 0;
destRect.top = 0;
destRect.bottom = gImageHeight;
destRect.right = gImageWidth;
// Get the Backbuffer then Stretch the Surface on it.
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &gBackBuf);
d3ddev->StretchRect(gImageSrc, NULL, gBackBuf, &destRect, D3DTEXF_NONE);
}
case WM_COMMAND:
switch(wParam)
case IDM_FULLSCREEN:
fullscreen(); 这个函数怎么写呢??
问题2:
SetTimer(hWndGlobal, 1, 30, NULL);通过定时器实现图片序列的连续渲染,渲染流程:
1、 case WM_TIMER:
RenderImage();
2、 render_frame
3、render3D 具体代码见上方。
想要通过选择菜单项“暂停”“播放”来实现图像序列的停止渲染和继续渲染,请问怎么实现??
非常感谢~~~好人一生幸福!!!