DirectDraw 问题 - 将应用程序作为常规 Windows 应用程序运行

发布于 2024-07-11 12:46:48 字数 1139 浏览 12 评论 0原文

我正在开发一个视频录制应用程序,我想在视频预览上叠加徽标和录制计时器。

我尝试运行全屏应用程序,一切正常。 然后我尝试将该应用程序作为常规 Windows 应用程序运行,但它返回了错误。

如果有办法修改它以将应用程序作为常规 Windows 应用程序运行,任何人都可以看一下下面的代码吗?

HRESULT CViewfinderRenderer::OnStartStreaming()
{
  HRESULT hr = S_OK;
  DDSURFACEDESC ddsd;

  m_pDD = NULL;

  //full screen settings
  hr = DirectDrawCreate(NULL, &m_pDD, NULL);
  hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_FULLSCREEN);

  ddsd.dwSize = sizeof(ddsd); 
  ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; 
  ddsd.ddsCaps.dwCaps = DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
  ddsd.dwBackBufferCount = 1;

  //end full screen settings

  //normal settings
  /*hr = DirectDrawCreate(NULL, &m_pDD, NULL);
  hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);

  ddsd.dwSize = sizeof(ddsd);
  ddsd.dwFlags = DDSD_BACKBUFFERCOUNT;
  ddsd.dwBackBufferCount = 1;*/
  //end normal settings

  hr = m_pDD->CreateSurface(&ddsd, &m_pSurface, NULL);
  if (hr != DD_OK) {
    return hr;
  }

  // Get backsurface
  hr = m_pSurface->EnumAttachedSurfaces(&m_pBackSurface, EnumFunction);

  return S_OK;
}

I am developing an application for video recording and I want to overlay the video preview with a logo and recording timer.

I tried to run the full-screen application and everything worked fine. Then I tried to run the application as a regular Windows application and it returned an error.

Could anyone take a look at the code below if there's a way to modify it to run the application as a regular Windows app?

HRESULT CViewfinderRenderer::OnStartStreaming()
{
  HRESULT hr = S_OK;
  DDSURFACEDESC ddsd;

  m_pDD = NULL;

  //full screen settings
  hr = DirectDrawCreate(NULL, &m_pDD, NULL);
  hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_FULLSCREEN);

  ddsd.dwSize = sizeof(ddsd); 
  ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; 
  ddsd.ddsCaps.dwCaps = DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
  ddsd.dwBackBufferCount = 1;

  //end full screen settings

  //normal settings
  /*hr = DirectDrawCreate(NULL, &m_pDD, NULL);
  hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);

  ddsd.dwSize = sizeof(ddsd);
  ddsd.dwFlags = DDSD_BACKBUFFERCOUNT;
  ddsd.dwBackBufferCount = 1;*/
  //end normal settings

  hr = m_pDD->CreateSurface(&ddsd, &m_pSurface, NULL);
  if (hr != DD_OK) {
    return hr;
  }

  // Get backsurface
  hr = m_pSurface->EnumAttachedSurfaces(&m_pBackSurface, EnumFunction);

  return S_OK;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

后eg是否自 2024-07-18 12:46:48

即使在窗口中运行,您也需要创建一个主表面,只是它不是可翻转的表面。

 //full screen settings
 hr = DirectDrawCreate(NULL, &m_pDD, NULL);
 hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);

 ddsd.dwSize = sizeof(ddsd); 
 ddsd.dwFlags = DDSD_CAPS; 
 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

除了创建表面之外,您很可能还想为窗口创建一个剪裁器。 有关完整示例,请参阅这篇 GameDev 文章中的“以窗口方式运行”段落。

Even when running windowed, you need to create a primary surface, only it is not a flippable surface.

 //full screen settings
 hr = DirectDrawCreate(NULL, &m_pDD, NULL);
 hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);

 ddsd.dwSize = sizeof(ddsd); 
 ddsd.dwFlags = DDSD_CAPS; 
 ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

Besides of creating a surface, most likely you will want to create a clipper for the window. For a complete sample see paragraph Running windowed in this GameDev article.

执手闯天涯 2024-07-18 12:46:48

它返回了什么错误?

也可以试试这个:

ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

What error did it return?

Also try this instead:

ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文