Esempio n. 1
0
void CGeometry::SetLightCone(int LightID,float Umbra,float Penumbra)
{
	ASSERT((LightID < MAXLIGHTS) && (LightID >= 0));

	if(m_Lights[LightID].InUse) {
		m_Lights[LightID].LightDesc.dvTheta = D3DVAL(Umbra);
		m_Lights[LightID].LightDesc.dvPhi = D3DVAL(Penumbra);
	}
}
Esempio n. 2
0
//////////////////////////////////////////////////////////////////////////////////
// CRMScene Create
//////////////////////////////////////////////////////////////////////////////////
BOOL CRMScene::Create(void)
{
	m_Engine->CreateFrame(NULL, &m_Frame);

	m_Engine->GetD3DRM()->CreateLightRGB(D3DRMLIGHT_AMBIENT, D3DVAL(0.3), D3DVAL(0.3), D3DVAL(0.3), &m_Light);
	m_Frame->AddLight(m_Light);

	return TRUE;
}
Esempio n. 3
0
void CGeometry::SetLightAttenuation(int LightID,float Att0,float Att1,float Att2)
{
	ASSERT((LightID < MAXLIGHTS) && (LightID >= 0));

	if(m_Lights[LightID].InUse) {
		m_Lights[LightID].LightDesc.dvAttenuation0 = D3DVAL(Att0);
		m_Lights[LightID].LightDesc.dvAttenuation1 = D3DVAL(Att1);
		m_Lights[LightID].LightDesc.dvAttenuation2 = D3DVAL(Att2);
	}
}
Esempio n. 4
0
//////////////////////////////////////////////////////////////////////////////////
// CRMCamera Create
//////////////////////////////////////////////////////////////////////////////////
BOOL CRMCamera::Create(CRMScene* pScene)
{
	m_Engine->CreateFrame(pScene->m_Frame, &m_Frame);
	m_Frame->SetPosition(pScene->m_Frame, D3DVAL(0.0), D3DVAL(0.0), D3DVAL(-10.0));

	m_Engine->GetD3DRM()->CreateViewport(m_Engine->m_RMDevice, m_Frame, 0, 0,
	                                     m_Engine->m_Screen->GetWidth(),
	                                     m_Engine->m_Screen->GetHeight(), &m_View);

	m_View->SetBack(D3DVAL(5000.0));

	return TRUE;
}
Esempio n. 5
0
//************************************************************************
BOOL CDirSnd::SetPosition(int x, int y, int z)
//************************************************************************
{
	if (!m_p3dBuff)
		return FALSE;

	// Convert coordinates to 3d values
	float fx = (float)x / m_fXRange;
	float fy = (float)y / m_fYRange;

	//float f
	HRESULT hr = m_p3dBuff->SetPosition(D3DVAL(fx), D3DVAL(fy), D3DVAL(0), DS3D_IMMEDIATE);

	return (hr == DS_OK);
}
Esempio n. 6
0
void CGeometry::SetLightFalloff(int LightID,float Falloff)
{
	ASSERT((LightID < MAXLIGHTS) && (LightID >= 0));

	if(m_Lights[LightID].InUse) {
		m_Lights[LightID].LightDesc.dvFalloff = D3DVAL(Falloff);
	}
}
Esempio n. 7
0
void CGeometry::SetLightRange(int LightID,float Range)
{
	ASSERT((LightID < MAXLIGHTS) && (LightID >= 0));

	if(m_Lights[LightID].InUse) {
		m_Lights[LightID].LightDesc.dvRange = D3DVAL(Range);
	}
}
Esempio n. 8
0
//************************************************************************
BOOL CDirSnd::Play(BOOL bLooping, BOOL bInit3dPos, BOOL bReset)
//************************************************************************
{
	if (!m_pBuffer)
		return FALSE;

	HRESULT hr;
	if (bReset)
		 m_pBuffer->SetCurrentPosition(0);

	if (m_p3dBuff && bInit3dPos)
		hr = m_p3dBuff->SetPosition(D3DVAL(0), D3DVAL(0), D3DVAL(0), DS3D_IMMEDIATE);

	hr = m_pBuffer->Play(0, 0, bLooping ? DSBPLAY_LOOPING : 0);
	
	return (hr == DS_OK);
}
Esempio n. 9
0
/*===========================================================================*/
extern "C" BOOL InitD3DText( void )
{
  int	index;

  /* Set the D3D Vertex Buffer up once so we don't do redundant changes. */
  memset( &TextVertices[0], 0, sizeof(TextVertices) );
  for( index = 0; index < MAX_VERTICES; index++ )
	TextVertices[index].rhw	= D3DVAL( 1.0 );

  return TRUE;
}
Esempio n. 10
0
/*===========================================================================*/
static int	ConvertCharacter( char *c, int cIndex,  PD3DFONTMETRICS pfntMetrics )
{
  DWORD	asciiChar = (int)(*c);

  /* Handle the TOP line. */
  if ( textBitMasks[asciiChar] & BIT1 )
  { 
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TL_0][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_0][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_0][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_0][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_1][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_1][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TL_1][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_1][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TL_0][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_0][1] );
  }

  /* Handle the TOP/BOTTOM RIGHT lines. */
  //  if ( textBitMasks[index] & (BIT2|BIT3) )
  if ( 1 == 0 )
  {
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_1][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TRR][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TRR][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[BRR][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[BRR][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[BRR][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[BRR][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[BR_0][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_0][1] );
    TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_1][0] );
    TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
  }
  else 
  {
	if ( textBitMasks[asciiChar] & BIT2 )
	{
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[TR_1][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[TRR][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[TRR][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MRR_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MRR_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MRR_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MRR_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MR_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MR_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[TR_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[TR_1][1] );
	}
	if ( textBitMasks[asciiChar] & BIT3 )
	{
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MR_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MR_1][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MRR_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MRR_1][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[BRR][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[BRR][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[BRR][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[BRR][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[BR_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[BR_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MR_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MR_1][1] );
	}
  }

  /* Handle the TOP/BOTTOM LEFT lines. */
  //  if ( textBitMasks[asciiChar] & (BIT5|BIT6) )
  if ( 1 == 0 )
  {
	TextVertices[cIndex].sx	= D3DVAL( lCoords[TLL][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[TLL][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[TL_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BLL][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BLL][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[TLL][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[TLL][1] );
  }
  else 
  {
	if ( textBitMasks[asciiChar] & BIT5 )
	{
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MLL_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MLL_1][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[ML_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[ML_1][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[BL_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[BL_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[BLL][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[BLL][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MLL_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MLL_1][1] );
	}
	if ( textBitMasks[asciiChar] & BIT6 )
	{
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[TLL][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[TLL][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[TL_1][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[TL_1][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[ML_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[ML_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[ML_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[ML_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[MLL_0][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[MLL_0][1] );
	  TextVertices[cIndex].sx	= D3DVAL( lCoords[TLL][0] );
	  TextVertices[cIndex++].sy	= D3DVAL( lCoords[TLL][1] );
	}
  }

  /* Handle the MIDDLE line. */
  if ( textBitMasks[asciiChar] & BIT7 )
  {
	TextVertices[cIndex].sx	= D3DVAL( lCoords[ML_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[ML_0][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[MR_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[MR_0][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[MR_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[MR_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[MR_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[MR_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[ML_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[ML_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[ML_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[ML_0][1] );
  }

  /* Handle the BOTTOM line. */
  if ( textBitMasks[asciiChar] & BIT4 )
  {
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BR_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_0][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BR_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BR_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_1][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_1][1] );
	TextVertices[cIndex].sx	= D3DVAL( lCoords[BL_0][0] );
	TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
  }
  
  return cIndex;
}
Esempio n. 11
0
int CGeometry::AddLight(DWORD Type)
{
	for(int i=0; i<MAXLIGHTS; i++) {
		if(m_Lights[i].InUse == 0) {
			memset(&m_Lights[i].LightDesc, 0, sizeof(D3DLIGHT));
			m_Lights[i].LightDesc.dwSize = sizeof(D3DLIGHT);
			m_Lights[i].LightDesc.dltType = (D3DLIGHTTYPE)Type;
			m_Lights[i].LightDesc.dcvColor.r = D3DVAL(1.0);
			m_Lights[i].LightDesc.dcvColor.g = D3DVAL(1.0);
			m_Lights[i].LightDesc.dcvColor.b = D3DVAL(1.0);
			m_Lights[i].LightDesc.dcvColor.a = D3DVAL(1.0);
			m_Lights[i].LightDesc.dvPosition.x = D3DVAL(0);
			m_Lights[i].LightDesc.dvPosition.y = D3DVAL(5000);
			m_Lights[i].LightDesc.dvPosition.z = D3DVAL(0);
			m_Lights[i].LightDesc.dvDirection.x = D3DVAL(0);
			m_Lights[i].LightDesc.dvDirection.y = D3DVAL(-1);
			m_Lights[i].LightDesc.dvDirection.z = D3DVAL(0);
			m_Lights[i].LightDesc.dvRange = D3DVAL(4000);
			m_Lights[i].LightDesc.dvFalloff = D3DVAL(0);
			m_Lights[i].LightDesc.dvTheta = D3DVAL(1);
			m_Lights[i].LightDesc.dvPhi = D3DVAL(10);
			m_Lights[i].LightDesc.dvAttenuation0 = D3DVAL(0.5);
			m_Lights[i].LightDesc.dvAttenuation1 = D3DVAL(0.0);
			m_Lights[i].LightDesc.dvAttenuation2 = D3DVAL(0.0);
			m_Lights[i].Position.x = D3DVAL(0);
			m_Lights[i].Position.y = D3DVAL(5000);
			m_Lights[i].Position.z = D3DVAL(0);
			m_Lights[i].Direction.x = D3DVAL(0);
			m_Lights[i].Direction.y = D3DVAL(-1);
			m_Lights[i].Direction.z = D3DVAL(0);
			m_Lights[i].Transform = TRUE;
			m_Lights[i].InUse++;

			HRESULT	ddrval;
			DXCALL_INT(m_Direct3D->CreateLight(&m_Lights[i].Light, NULL));
			DXCALL_INT(m_Lights[i].Light->SetLight(&m_Lights[i].LightDesc));
			DXCALL_INT(m_Viewport->AddLight(m_Lights[i].Light));

			return i;
		}
	}

	return -1;
}
Esempio n. 12
0
CGeometry::CGeometry(ID3D *Direct3D,ID3DDEVICE *Device,ID3DVIEPORT *Viewport)
{
	// Matrix for projecting 3d view onto a 2d screen surface
	D3DMATRIX InitProj = {
		D3DVAL(2.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(2.0), D3DVAL(0.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0), D3DVAL(1.0),
		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(-512.0), D3DVAL(0.0)
//		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(-8.0), D3DVAL(0.0)
	};
	D3DMATRIX InitView = {
		D3DVAL(1.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(10.0), D3DVAL(1.0)
	};
	D3DMATRIX InitIdentity = {
		D3DVAL(1.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0),
		D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0)
	};


	m_Direct3D = Direct3D;
	m_3DDevice = Device;
	m_Viewport = Viewport;
	m_proj=InitProj;
	m_view=InitView;
	m_identity=InitIdentity;

// Set the view, world and projection matrices
// Create a buffer for matrix set commands etc.

    m_3DDevice->BeginScene();
	m_3DDevice->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &m_proj);
	m_3DDevice->SetTransform(D3DTRANSFORMSTATE_VIEW, &m_view);      
	m_3DDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &m_world);    
    m_3DDevice->EndScene();

	for(int i=0; i<MAXLIGHTS; i++) {
		m_Lights[i].InUse = 0;
	}

	m_MatrixStackPos = 0;
}
Esempio n. 13
0
//************************************************************************
BOOL CDirSnd::LoadWaveResource(LPSTR lpSound, HINSTANCE hInstance, BOOL b3D)
// lpSound is a resource name
//************************************************************************
{
	HGLOBAL hWave;
	LPTR lpWave;
    PCMWAVEFORMAT pcm; 
	HMMIO hio;
	MMCKINFO RiffChunk;
	MMCKINFO FmtChunk;
	MMCKINFO DataChunk;
	HRESULT hr;
	MMRESULT Res;
	MMIOINFO Info;
	long lRead;

	WAVEFORMATEX Format;
	DSBUFFERDESC BuffDesc;

	BYTE *pData1;
	BYTE *pData2;
	DWORD dwBytes1;
	DWORD dwBytes2;

	Init( GetApp()->GetMainWnd() );

	if ( !m_pDirectSound )
		return NO;

	if ( !hInstance )
		return NO;

	// Find the resource
	if ( !(hWave = (HGLOBAL)FindResource( hInstance, lpSound, "WAVE" )) )
		return NO;

	// Load the resource
	if ( !(hWave = LoadResource( hInstance, (HRSRC)hWave )) )
		return( NO );

	// Lock it
	if ( !(lpWave = (LPTR)LockResource( hWave )) )
	{
		FreeResource( hWave );
		return NO;
	}

	// Set up mmio Info structure for opening memory for mmio
	memset(&Info, 0, sizeof(MMIOINFO));
	Info.pchBuffer = (LPSTR)lpWave;
	Info.fccIOProc = FOURCC_MEM;
	Info.cchBuffer = SizeofResource(hInstance, (HRSRC)hWave);  
	Info.adwInfo[0] = 0;

	// Open memory for mmio
	hio = mmioOpen(NULL, &Info, MMIO_READ); 
	if (!hio)
		return 0;

	// Descened into the WAVE section
	RiffChunk.ckid = FOURCC_RIFF;
	RiffChunk.fccType = mmioFOURCC('W', 'A', 'V', 'E' );
	Res = mmioDescend(hio, &RiffChunk, NULL, MMIO_FINDRIFF);
	if (Res != 0)
		goto ERROR_READING_WAVE;

    // Descend into the fmt chunk
    FmtChunk.ckid = mmioFOURCC('f', 'm', 't', ' ');
    Res = mmioDescend(hio, &FmtChunk, &RiffChunk, MMIO_FINDCHUNK);
	if (Res != 0)
		goto ERROR_READING_WAVE;
                                                                                                                                                               
	// Read the 'fmt ' chunk into <pcmWaveFormat>
    if (mmioRead(hio, (HPSTR) &pcm, (long)sizeof(pcm)) 
		!= (long) sizeof(pcm))
	    goto ERROR_READING_WAVE;
                                                                                                           

	DataChunk.ckid = mmioFOURCC('d', 'a', 't', 'a');
	Res = mmioDescend(hio, &DataChunk, &RiffChunk, MMIO_FINDCHUNK);
	if (Res != 0)
		goto ERROR_READING_WAVE;

	// Set the wave format 
	memset(&Format, 0, sizeof(WAVEFORMATEX));
	Format.wFormatTag = pcm.wf.wFormatTag;
	Format.nChannels = pcm.wf.nChannels;
	Format.nSamplesPerSec = pcm.wf.nSamplesPerSec;
	Format.nAvgBytesPerSec = pcm.wf.nAvgBytesPerSec;
	Format.nBlockAlign = pcm.wf.nBlockAlign;
	Format.wBitsPerSample = pcm.wBitsPerSample;

	// Set up the sound buffer description
	memset(&BuffDesc, 0, sizeof(BuffDesc));
	BuffDesc.dwSize = sizeof(DSBUFFERDESC);
	if (b3D)
		BuffDesc.dwFlags = DSBCAPS_CTRLVOLUME|DSBCAPS_CTRL3D;
	else
		BuffDesc.dwFlags = DSBCAPS_CTRLDEFAULT;
	BuffDesc.dwBufferBytes = DataChunk.cksize;
	BuffDesc.lpwfxFormat = &Format;


	// Create the buffer
    hr =  m_pDirectSound->CreateSoundBuffer( &BuffDesc, &m_pBuffer, NULL);

	if (hr != DS_OK)
	{
		goto ERROR_READING_WAVE;
	}

	if (b3D)
	{
		hr = m_pBuffer->QueryInterface(IID_IDirectSound3DBuffer, (void **)&m_p3dBuff);
		//hr = m_pBuffer->QueryInterface(IID_IMAPISession, (void **)&m_p3dBuff);
		if (SUCCEEDED(hr)) 
		{
			// Set 3D parameters of this sound.
			hr = m_p3dBuff->SetPosition(D3DVAL(0), D3DVAL(0), D3DVAL(0), DS3D_IMMEDIATE);
		}
	}

	// Lock the buffer so we can read into it
	hr = m_pBuffer->Lock(0, DataChunk.cksize, &pData1, &dwBytes1, 
		&pData2, &dwBytes2, 0);
    
    // If we got DSERR_BUFFERLOST, restore and retry lock.
    if (DSERR_BUFFERLOST == hr)
	{
        m_pBuffer->Restore();
		hr = m_pBuffer->Lock(0, DataChunk.cksize, &pData1, &dwBytes1, 
			&pData2, &dwBytes2, 0);
    }

	// Read the data
	lRead = mmioRead(hio, (HPSTR)pData1, dwBytes1);
	if (pData2 != NULL)
		lRead = mmioRead(hio, (HPSTR)pData2, dwBytes2);

    // Release the data back to DirectSound.
    hr = m_pBuffer->Unlock(pData1, dwBytes1, pData2, dwBytes2);

	ERROR_READING_WAVE:

	mmioClose(hio, 0);	
	
	return YES;
}
Esempio n. 14
0
//////////////////////////////////////////////////////////////////////////////////
// CRMEngine CreateLight
//////////////////////////////////////////////////////////////////////////////////
HRESULT CRMEngine::CreateLight(D3DRMLIGHTTYPE type, double r, double g, double b,
                               LPDIRECT3DRMLIGHT* pLight)
{
	CDXLOG("START: CRMEngine::CreateLight");
	return m_Direct3DRM->CreateLightRGB(type, D3DVAL(r), D3DVAL(g), D3DVAL(b), pLight);
}
Esempio n. 15
0
//---フィールド頂点を初期化
CRBATINIT_API int crbatInitFieldVertex(void)
{
	int a,x,y;

	D3DVECTOR vNormal( D3DVAL(0.0f), D3DVAL(1.0f), D3DVAL(0.0f) );
	D3DVECTOR vNormal2( D3DVAL(0.0f), D3DVAL(-1.0f), D3DVAL(0.0f) );
	D3DVECTOR p1(D3DVAL(-0.5f) , D3DVAL(0.0f) , D3DVAL(-0.5f));
	D3DVECTOR p2( D3DVAL(0.5f) , D3DVAL(0.0f) , D3DVAL(-0.5f));
	D3DVECTOR p3(D3DVAL(-0.5f) , D3DVAL(0.0f) , D3DVAL( 0.5f));
	D3DVECTOR p4( D3DVAL(0.5f) , D3DVAL(0.0f) , D3DVAL( 0.5f));
/*
	D3DVECTOR vNormal( D3DVAL(0.0f), D3DVAL(1.0f), D3DVAL(0.0f) );
	D3DVECTOR vNormal2( D3DVAL(0.0f), D3DVAL(-1.0f), D3DVAL(0.0f) );
	D3DVECTOR p1(D3DVAL(-0.5f) , D3DVAL(-0.5f) , D3DVAL(0.0f));
	D3DVECTOR p2( D3DVAL(0.5f) , D3DVAL(-0.5f) , D3DVAL(0.0f));
	D3DVECTOR p3(D3DVAL(-0.5f) , D3DVAL(0.5f) , D3DVAL( 0.0f));
	D3DVECTOR p4( D3DVAL(0.5f) , D3DVAL(0.5f) , D3DVAL( 0.0f));
*/
	for(y = 0;y < BATTLEFIELD_VERTEXCOUNT_Y;y ++){
		for(x = 0;x < BATTLEFIELD_VERTEXCOUNT_X;x ++){
			BattleField[x][y].Vertex[0] = D3DVERTEX( p1, vNormal,D3DVAL(0.0f),D3DVAL(0.0f));
			BattleField[x][y].Vertex[1] = D3DVERTEX( p2, vNormal,D3DVAL(1.0f),D3DVAL(0.0f));
			BattleField[x][y].Vertex[2] = D3DVERTEX( p3, vNormal,D3DVAL(0.0f),D3DVAL(1.0f));
			BattleField[x][y].Vertex[3] = D3DVERTEX( p4, vNormal,D3DVAL(1.0f),D3DVAL(1.0f));

			for(a = 0;a < 4;a ++){
				BattleField[x][y].Vertex[a].x += (float)((float)x * 1.0f);
				BattleField[x][y].Vertex[a].z += (float)((float)y * 1.0f);
			}

//			BattleField[x][y].TextureNumber = eiRnd(2);
		}
	}

	return 1;
}