• Advertisement

Archived

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

how do you setup direct3d version 7

This topic is 6479 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

How do you setup direct3d version 7? i just need code with comments. so please help Styles

Share this post


Link to post
Share on other sites
Advertisement
Did you know that you''re kinda posting in an OpenGL section? Doesnt'' really matter though, read the documentation that comes with DirectX7 SDK, it''s really helpful and actually contains some pretty good tutorials. You do have to know how to use DirectDraw first though, but if you''re going to tangle with Direct3D you should know DirectDraw anyways! All the microsoft demo-code is commented and pretty well explained in the tutorials. Cheers!

Share this post


Link to post
Share on other sites
This really isn''t the right place for DirectX questions but since I know a real easy way to set up Direct3D, which I wish to share with the OpenGL people who say that Direct3D is hard to initialize I will tell you. (Please I''m not flaming anyone and I''m not saying that Direct3D is better than OpenGL, just that it is a lot easier to work with now than with previous versions )

Initialization of Direct3D, the easy way:


HRESULT CD3DApp::InitializeD3D()
{
// Initialize D3DX
HRESULT hr;
if( FAILED(hr = D3DXInitialize()) )
return hr;


// Create the D3DX context
// D3DX creates everything we need here
DWORD Flags = m_bFullscreen ? D3DX_CONTEXT_FULLSCREEN : 0;
hr = D3DXCreateContextEx( D3DX_DEFAULT, // Use the best acceleration
Flags,
m_hWnd,
NULL, // We don''t use a parent window
m_nColorBits,
m_nAlphaBits,
m_nDepthBits,
m_nStencilBits,
D3DX_DEFAULT, // Use one backbuffer
m_nWidth,
m_nHeight,
D3DX_DEFAULT, // Let D3DX choose refreshrate
&m_pD3DX );
if( FAILED(hr) )
return hr;


// Get a reference to Direct3DDevice
m_pD3DDev = m_pD3DX->GetD3DDevice();
if( m_pD3DDev == NULL )
return E_FAIL;


// Get a reference to DirectDraw
m_pDD = m_pD3DX->GetDD();
if( m_pDD == NULL )
return E_FAIL;


return S_OK;
}


And when you shut down the application you shut down Direct3D this way:


HRESULT CD3DApp::TerminateD3D()
{
// Release our DirectX objects
if( m_pDD )
{
m_pDD->Release();
m_pDD = 0;
}


if( m_pD3DDev )
{
m_pD3DDev->Release();
m_pD3DDev = 0;
}


if( m_pD3DX )
{
m_pD3DX->Release();
m_pD3DX = 0;
}


// Let D3DX do some final uninitializations
D3DXUninitialize();


return S_OK;
}


These functions are taken directly from my own little framework so all the variables that start with m_ is declared and initialized somewhere else, but I think you can figure out what they do.

The D3DXCreateContextEx() function has a little brother called D3DXCreateContext() that has less parameters, so it can be easier to use if you don''t need the extra features.


- WitchLord

Share this post


Link to post
Share on other sites
Since NeHe''s area is now an OpenGL type area, maybe someone should volunteer to moderate a DirectX section, just an idea.

Share this post


Link to post
Share on other sites

  • Advertisement