Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Starfalcon2

Device's windowed

This topic is 5225 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I set D3DPresentParams.windowed = true, it failed to create the device. Then I reboot my computer and complie it. It works fine . Uh, My question is why? did I miss something?

Share this post


Link to post
Share on other sites
Advertisement
oh, sorry, here my code



HRESULT hResult = CreateD3DObject();
if (hResult != D3D_OK)
return hResult;
hResult = CheckDisplayMode();
if (hResult != D3D_OK)
return hResult;
hResult = CreateD3DDevice();
if (hResult != D3D_OK)
return hResult;

//////////////////////////////////////////////////////
// CreateD3DObject()
//////////////////////////////////////////////////////
HRESULT CDirect3D::CreateD3DObject()
{
m_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
if (m_pD3D == NULL)
{
MessageBox(m_hWnd, "Couldn’t create DirectX object.",
"DirectX Error", MB_OK);
strcpy(m_szErrorMsg, "CreateD3DObject()");
return E_FAIL;
}
return D3D_OK;
}

//////////////////////////////////////////////////////
// CheckDisplayMode()
//////////////////////////////////////////////////////
HRESULT CDirect3D::CheckDisplayMode()
{
HRESULT hResult = m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, FALSE);
if (hResult != D3D_OK)
{
MessageBox(m_hWnd, "The required display mode is not available on this system.",
"DirectX Error", MB_OK);
strcpy(m_szErrorMsg, "CheckDisplayMode()");
return hResult;
}
return D3D_OK;
}

//////////////////////////////////////////////////////
// CreateD3DDevice()
//////////////////////////////////////////////////////
HRESULT CDirect3D::CreateD3DDevice()
{
D3DPRESENT_PARAMETERS D3DPresentParams;
ZeroMemory(&D3DPresentParams, sizeof(D3DPRESENT_PARAMETERS));
D3DPresentParams.Windowed = true;
D3DPresentParams.BackBufferCount = 1;
D3DPresentParams.BackBufferWidth = 640;
D3DPresentParams.BackBufferHeight = 480;
D3DPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8;
D3DPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
D3DPresentParams.hDeviceWindow = m_hWnd;
HRESULT hResult = m_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&D3DPresentParams, &m_pD3DDevice);
if (FAILED(hResult))
{
MessageBox(m_hWnd, "Failed to create Direct3D device.",
"DirectX Error", MB_OK);
strcpy(m_szErrorMsg, "CreateD3DDevice()");
return hResult;
}
return hResult;
}


P.S. how I do make display as visual C++'s version?

[edited by - Starfalcon2 on May 31, 2004 1:04:30 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!