Ejemplo n.º 1
0
bool BaseApp::BuildShader( DeviceDx11* pDevice )
{
	Safe_Delete( m_pBaseShader );
	m_pBaseShader = new BaseShader();

	bool bVSResult = false;
	bool bPSResult = false;
	bool bILResult = false;
	if( pDevice && m_pBaseShader && m_pBaseResource )
	{
		D3D11_INPUT_ELEMENT_DESC layout[] =
		{
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};
		UINT numElements = ARRAYSIZE( layout );
				
		ID3DBlob* pVSBlob = nullptr;
		bVSResult = m_pBaseShader->CreateVertexShader( pDevice->GetDevice(), L"Tutorial03.fx", "VS", "vs_5_0", &pVSBlob );
		bILResult = m_pBaseResource->CreateInputLayout( pDevice->GetDevice(), layout, numElements, pVSBlob );
		Safe_Release( pVSBlob );
		
		ID3DBlob* pPSBlob = nullptr;
		bPSResult = m_pBaseShader->CreatePixelShader( pDevice->GetDevice(), L"Tutorial03.fx", "PS", "ps_5_0", &pPSBlob );
		Safe_Release( pPSBlob );		
	}

	if( !bVSResult || !bPSResult || !bILResult )
		return false;
	else
		return true;
}
Ejemplo n.º 2
0
CShadow::~CShadow()
{
	Safe_Release(m_pVB);
	for (unsigned int i(0); i < m_vVB.size(); i++)
		Safe_Release(m_vVB[i]);
	m_vVB.clear();
}
Ejemplo n.º 3
0
bool CEntity::ComputeNormalVector(
	LPD3DXMESH _pMesh, D3DXVECTOR3& _vNormal, D3DXVECTOR3& _vCol, CEntity* target)
{
	BOOL isHit = false;
	DWORD dwFaceIndex = 0;
	float fDist = 0;
	LPD3DXBUFFER ppAllhit;
	DWORD pCountOfHits;
	
	D3DXVECTOR3 vPos = m_vPos - target->GetPos();
	D3DXVECTOR3 vtar = (-vPos);
	D3DXVec3Normalize( &vtar, &vtar);

	D3DXIntersect( _pMesh, &vPos, &vtar, &isHit, 
		&dwFaceIndex, NULL, NULL, &fDist, &ppAllhit, &pCountOfHits );

	if ( !isHit || fDist > GetSize()  )
		return false;// Ãæµ¹ÀÌ ¾È‰ç°Å³ª °Å¸®°¡ ¸Ö´Ù¸é ¸®ÅÏ;

	LPDIRECT3DVERTEXBUFFER9 pVB; 
	LPDIRECT3DINDEXBUFFER9 pIB; 

	_pMesh->GetVertexBuffer(&pVB); 
	_pMesh->GetIndexBuffer( &pIB ); 

	WORD* pIndices; 
	D3DVERTEX* pVertices; 

	pIB->Lock( 0, 0, (void**)&pIndices, 0 ); 
	pVB->Lock( 0, 0,(void**)&pVertices, 0); 

	D3DXVECTOR3 v0 = pVertices[pIndices[3*dwFaceIndex+0]].vPos; 
	D3DXVECTOR3 v1 = pVertices[pIndices[3*dwFaceIndex+1]].vPos; 
	D3DXVECTOR3 v2 = pVertices[pIndices[3*dwFaceIndex+2]].vPos; 
	
	D3DXPLANE plane;
	
	D3DXPlaneFromPoints( &plane, &v0, &v1, &v2);
	
	_vCol = (v0 + v1 + v2)/3.f;
	_vCol += target->GetPos();

	_vNormal.x = plane.a;
	_vNormal.y = plane.b;
	_vNormal.z = plane.c;
	
#ifdef _DEBUG
	//Ãæµ¹ÁöÁ¡ Ç¥½Ã
	_SINGLE(CDebug)->AddPosMark( _vCol, COLOR_BLACK);
#endif
	
	pVB->Unlock(); 
	pIB->Unlock(); 
	Safe_Release(pVB); 
	Safe_Release(pIB); 

	return true;
}
Ejemplo n.º 4
0
DWORD CVIBuffer::Release(void)
{
	if (m_dwRefCount == 0)
	{
		Safe_Release(m_VertexBuffer);
		Safe_Release(m_IndexBuffer);
		Safe_Release(m_ConstantBuffer);
	}
	return 0;
}
Ejemplo n.º 5
0
void CShadow::onTick(float fElapsedTime) {
	for (unsigned int i(0); i < m_vMesh.size(); i++) {
		D3DXVECTOR3 vSun(*m_pSun); D3DXMATRIX mInv;
		D3DXMatrixInverse(&mInv, NULL, m_vMat[i]);
		D3DXVec3TransformCoord(&vSun, &vSun, &mInv);

		ID3DXMesh* pMesh;
		m_vMesh[i]->CloneMeshFVF(m_vMesh[i]->GetOptions(), D3DFVF_XYZ, 
			CDirect3D::getInstance()->GetD3D9Device(), &pMesh);

		D3DXVECTOR3 *pVertices, *pVolume;
		WORD* pIndices;
		pMesh->LockVertexBuffer(NULL, (void**) &pVertices);
		pMesh->LockIndexBuffer(NULL, (void**) &pIndices);
		DWORD dwFaces(pMesh->GetNumFaces());

		WORD* pEdges = new WORD[dwFaces*3*2];
		DWORD dwEdges(0);
		for (DWORD j(0); j < dwFaces; j++) {
			WORD wFace0 = pIndices[j*3];
			WORD wFace1 = pIndices[j*3+1];
			WORD wFace2 = pIndices[j*3+2];
			D3DXVECTOR3 v0 = pVertices[wFace0];
			D3DXVECTOR3 v1 = pVertices[wFace1];
			D3DXVECTOR3 v2 = pVertices[wFace2];
			D3DXVECTOR3 vCross1(v2-v1);
			D3DXVECTOR3 vCross2(v1-v0);
			D3DXVECTOR3 vNormal;
			D3DXVec3Cross(&vNormal, &vCross1, &vCross2);
			if (D3DXVec3Dot(&vNormal, m_pSun) > 0.f) {
				AddEdge(pEdges, dwEdges, wFace0, wFace1);
				AddEdge(pEdges, dwEdges, wFace1, wFace2);
				AddEdge(pEdges, dwEdges, wFace2, wFace0);
			}
		}
		m_dwTriangles[i] = dwEdges*2;
		m_vVB[i]->Lock(0, sizeof(D3DXVECTOR3)*m_dwTriangles[i]*3, (void**) &pVolume, NULL);
		// some (solvable, but expensive) issues here: 
		// (view port related) direction undetermined for segment v1 - v2,
		// so CULL_CW doesn't necessarily mean 'back side'.
		for (DWORD j(0); j < dwEdges; j++) {
			D3DXVECTOR3 v1 = pVertices[pEdges[2*j+0]];	
			D3DXVECTOR3 v2 = pVertices[pEdges[2*j+1]];  
			D3DXVECTOR3 v3 = (v1 - vSun);				
			D3DXVECTOR3 v4 = (v2 - vSun);
			pVolume[j*6] = v3;		
			pVolume[j*6+1] = v1;	
			pVolume[j*6+2] = v4;	// 1 2
			pVolume[j*6+3] = v4;	// |\|
			pVolume[j*6+4] = v1;	// 3 4
			pVolume[j*6+5] = v2;
		}
		m_vVB[i]->Unlock();
		pMesh->UnlockVertexBuffer();
		pMesh->UnlockIndexBuffer();
		Safe_Release(pMesh);
		Safe_Delete_Array(pEdges);
	}
}
Ejemplo n.º 6
0
void CDebug::Destroy()
{
	Safe_Release(m_pGridVB);
	Safe_Release(m_pLineVB);

	for( int i = 0; i < LOG_COUNT; ++i)
	{
		Safe_Delete_Array(m_StaticLog[i]);
		Safe_Delete_Array(m_Log[i]);
		Safe_Release(m_Text3D[i]);
		//Safe_Delete_Array(m_vList[i]);
	}
	Safe_Delete_Array(m_StaticLog);
	Safe_Delete_Array(m_Log);
	Safe_Release(m_Line);
	Safe_Release(m_pFont); // 폰트 구조체해제

	DeleteObject(m_hFont);
	DeleteDC(m_hdc);


}
Ejemplo n.º 7
0
HRESULT CDirect3D::CompileEffectFromFile(char* strEffectFile, ID3DXEffect** ppEffect)
{
	if (NULL == m_pD3D9Device || NULL == ppEffect)
		return E_FAIL;

	ID3DXBuffer* pEffectError = NULL;
	HRESULT hr = D3DXCreateEffectFromFileA(m_pD3D9Device, strEffectFile, NULL, NULL, 0, 0, ppEffect, &pEffectError);
	if (NULL != pEffectError)
		::MessageBoxA(0, (char*)pEffectError->GetBufferPointer(), "Error", MB_OK);

	Safe_Release(pEffectError);
	return hr;
}
Ejemplo n.º 8
0
CBoxMesh::~CBoxMesh(void)
{
	Safe_Release(m_pMesh);
}
Ejemplo n.º 9
0
Sampler::~Sampler()
{
	Safe_Release(m_pSampler);
}
Ejemplo n.º 10
0
HRESULT LoadBitmapFromFile(
	PCWSTR uri,
	UINT dweight,
	UINT dheight,
	ID2D1Bitmap **bitmap
	)
{
	HRESULT hr = S_OK;
	IWICImagingFactory* pWICFactory = NULL;
	IWICBitmapDecoder* pDecoder = NULL;
	IWICBitmapScaler* pScaler = NULL;
	IWICBitmapFrameDecode* pSource = NULL;
	IWICFormatConverter* pConverter = NULL;
	hr = CoCreateInstance(
		CLSID_WICImagingFactory,
		NULL,
		CLSCTX_INPROC_SERVER,
		IID_IWICImagingFactory,
		(LPVOID*)&pWICFactory);
	if (SUCCEEDED(hr))
	{
		hr = pWICFactory->CreateDecoderFromFilename(
			uri,
			NULL,
			GENERIC_READ,
			WICDecodeMetadataCacheOnLoad,
			&pDecoder);
	}
	if (SUCCEEDED(hr))
	{
		hr = pDecoder->GetFrame(0, &pSource);
	}
	if (SUCCEEDED(hr))
	{
		hr = pWICFactory->CreateFormatConverter(&pConverter);
	}
	if (SUCCEEDED(hr))
	{
		UINT oWeight, oHeight;
		hr = pSource->GetSize(&oWeight, &oHeight);
		if (SUCCEEDED(hr))
		{
			hr = pWICFactory->CreateBitmapScaler(&pScaler);
			if (SUCCEEDED(hr))
			{
				hr = pScaler->Initialize(
					pSource,
					dweight,
					dheight,
					WICBitmapInterpolationModeCubic);
			}

			if (SUCCEEDED(hr))
			{
				hr = pConverter->Initialize(
					pScaler,
					GUID_WICPixelFormat32bppPBGRA,
					WICBitmapDitherTypeNone,
					NULL,
					0.f,
					WICBitmapPaletteTypeMedianCut
					);
			}

		}
	}
	if (SUCCEEDED(hr))
	{
		hr = pRT->CreateBitmapFromWicBitmap(pConverter, bitmap);
	}
	Safe_Release(pWICFactory);
	Safe_Release(pDecoder);
	Safe_Release(pScaler);
	Safe_Release(pSource);
	Safe_Release(pConverter);
	return hr;
}
Ejemplo n.º 11
0
CMirror::~CMirror()
{
	Safe_Release(m_pVB);
	Safe_Release(m_pTexture);
}
Ejemplo n.º 12
0
CDirect3D::~CDirect3D()
{
	Safe_Release(m_pFont);
	Safe_Release(m_pD3D9Device);
	Safe_Release(m_pDirect3D9);
}
Ejemplo n.º 13
0
CBillBoard::~CBillBoard()
{
	Safe_Release(m_pTexture);
	Safe_Release(m_pVB);
}
Ejemplo n.º 14
0
TDTargeting::~TDTargeting()
{
	Safe_Release(m_pVB);
}
Ejemplo n.º 15
0
CEntity::~CEntity(void)
{
	Safe_Release(m_SphereMesh);
	std::wstring str;
	str.c_str();
}
Ejemplo n.º 16
0
Buffer::~Buffer()
{
	Safe_Release(m_pBuffer);
}
Ejemplo n.º 17
0
void DeviceDx11::CleanupDevice()
{
	Safe_Release( m_pImmediateContext );		
	Safe_Release( m_pSwapChain );
	Safe_Release( m_pd3dDevice );	//디바이스는 가장 나중에 Release해야 한다.
}
Ejemplo n.º 18
0
void CKeyMgr::Release()
{
	Safe_Release(m_pMouseDevice);
	Safe_Release(m_pKeyBoardDevice);
	Safe_Release(m_pInput);
}