Archived

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

Scotto1001

3d and 2d

Recommended Posts

Hi. I would like to know how to make 2d objects appear, like bitmaps and stuff, over a 3d rendered space. Not a billboard. Useing DirectX 9.0 Summer Update. -Scotto Gingerbread Men

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

CSoundManager::~CSoundManager()
{
SAFE_RELEASE( m_pDS );
}




//-----------------------------------------------------------------------------
// Name: CSoundManager::Initialize()
// Desc: Initializes the IDirectSound object and also sets the primary buffer
// format. This function must be called before any others.
//-----------------------------------------------------------------------------
HRESULT CSoundManager::Initialize( HWND hWnd,
DWORD dwCoopLevel )
{
HRESULT hr;

SAFE_RELEASE( m_pDS );

// Create IDirectSound using the primary sound device
if( FAILED( hr = DirectSoundCreate8( NULL, &m_pDS, NULL ) ) )
return DXTRACE_ERR( TEXT("DirectSoundCreate8", hr );

// Set DirectSound coop level
if( FAILED( hr = m_pDS->SetCooperativeLevel( hWnd, dwCoopLevel ) ) )
return DXTRACE_ERR( TEXT("SetCooperativeLevel", hr );

return S_OK;
}




//-----------------------------------------------------------------------------
// Name: CSoundManager::SetPrimaryBufferFormat()
// Desc: Set primary buffer to a specified format
// !WARNING! - Setting the primary buffer format and then using this
// same dsound object for DirectMusic messes up DirectMusic!
// For example, to set the primary buffer format to 22kHz stereo, 16-bit
// then: dwPrimaryChannels = 2
// dwPrimaryFreq = 22050,
// dwPrimaryBitRate = 16
//-----------------------------------------------------------------------------
HRESULT CSoundManager::SetPrimaryBufferFormat( DWORD dwPrimaryChannels,
DWORD dwPrimaryFreq,
DWORD dwPrimaryBitRate )
{
HRESULT hr;
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;

if( m_pDS == NULL )
return CO_E_NOTINITIALIZED;

// Get the primary buffer
DSBUFFERDESC dsbd;
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbd.dwBufferBytes = 0;
dsbd.lpwfxFormat = NULL;

if( FAILED( hr = m_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ) ) )
return DXTRACE_ERR( TEXT("CreateSoundBuffer", hr );

WAVEFORMATEX wfx;
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
wfx.wFormatTag = (WORD) WAVE_FORMAT_PCM;
wfx.nChannels = (WORD) dwPrimaryChannels;
wfx.nSamplesPerSec = (DWORD) dwPrimaryFreq;
wfx.wBitsPerSample = (WORD) dwPrimaryBitRate;
wfx.nBlockAlign = (WORD) (wfx.wBitsPerSample / 8 * wfx.nChannels);
wfx.nAvgBytesPerSec = (DWORD) (wfx.nSamplesPerSec * wfx.nBlockAlign);

if( FAILED( hr = pDSBPrimary->SetFormat(&wfx) ) )
return DXTRACE_ERR( TEXT("SetFormat", hr );

SAFE_RELEASE( pDSBPrimary );

return S_OK;
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

CSoundManager::CSoundManager()
{
m_pDS = NULL;
}




//-----------------------------------------------------------------------------

// Name: CSoundManager::~CSoundManager()

// Desc: Destroys the class

//-----------------------------------------------------------------------------

CSoundManager::~CSoundManager()
{
SAFE_RELEASE( m_pDS );
}




//-----------------------------------------------------------------------------

// Name: CSoundManager::Initialize()

// Desc: Initializes the IDirectSound object and also sets the primary buffer

// format. This function must be called before any others.

//-----------------------------------------------------------------------------

HRESULT CSoundManager::Initialize( HWND hWnd,
DWORD dwCoopLevel )
{
HRESULT hr;

SAFE_RELEASE( m_pDS );

// Create IDirectSound using the primary sound device

if( FAILED( hr = DirectSoundCreate8( NULL, &m_pDS, NULL ) ) )
return DXTRACE_ERR( TEXT("DirectSoundCreate8"), hr );

// Set DirectSound coop level

if( FAILED( hr = m_pDS->SetCooperativeLevel( hWnd, dwCoopLevel ) ) )
return DXTRACE_ERR( TEXT("SetCooperativeLevel"), hr );

return S_OK;
}

Share this post


Link to post
Share on other sites