关于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 具体代码见上方。
想要通过选择菜单项“暂停”“播放”来实现图像序列的停止渲染和继续渲染,请问怎么实现??


非常感谢~~~好人一生幸福!!!
...全文
157 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
的年 2013-04-14
  • 打赏
  • 举报
回复
自己顶。。。。
的年 2013-04-10
  • 打赏
  • 举报
回复
引用 1 楼 gamedevboy 的回复:
问题一:重置设备,并把d3dpp.Windowed置为FALSE即可。 问题二: RenderImage 带个参数,加入你有类似结构, imageIndex++ 这种,可以在暂停状态下把这个递增删除。另外,最通用的方法是把BackBuffer拷贝出来,在暂停的情况下,只把之前的BackBuffer内容提交到FrontBuffer上。
请问怎么重置设备啊??能写的具体点嘛???谢谢 暂停那边我用killtimer实现了。。。
gamedevboy 2013-04-10
  • 打赏
  • 举报
回复
问题一:重置设备,并把d3dpp.Windowed置为FALSE即可。 问题二: RenderImage 带个参数,加入你有类似结构, imageIndex++ 这种,可以在暂停状态下把这个递增删除。另外,最通用的方法是把BackBuffer拷贝出来,在暂停的情况下,只把之前的BackBuffer内容提交到FrontBuffer上。

64,639

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧