示例#1
0
void CContextManager::Dispose()
{
	for (int i = 0; i < RS_COUNT; ++i)
	{
		CHECKED_RELEASE(m_RasterizerSates[i]);
	}
	for (int i = 0; i < DSS_COUNT; ++i)
	{
		CHECKED_RELEASE(m_DepthStencilStates[i]);
	}
	for (int i = 0; i < BLEND_COUNT; ++i)
	{
		CHECKED_RELEASE(m_BlendStates[i]);
	}

	CHECKED_RELEASE(m_RenderTargetView);
	CHECKED_RELEASE(m_DepthStencil);
	CHECKED_RELEASE(m_DepthStencilView);

	if (m_SwapChain)
	{
		m_DeviceContext->OMSetRenderTargets(0, nullptr, nullptr);
		m_SwapChain->SetFullscreenState(FALSE, nullptr);
	}

	if (m_D3DDebug)
		m_D3DDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);

	CHECKED_RELEASE(m_D3DDebug);

	CHECKED_RELEASE(m_D3DDevice);
	CHECKED_RELEASE(m_DeviceContext);
	CHECKED_RELEASE(m_SwapChain);
}
///<summary>
/// CAnimatedInstanceModel:: Destroy
///</summary>
void CAnimatedInstanceModel::Destroy()
{
  CHECKED_DELETE(m_CalModel);
  CHECKED_RELEASE(m_pVB);
  CHECKED_RELEASE(m_pIB);
	m_TextureList.clear();
}
示例#3
0
void CTexture::UnsetAsRenderTarget()
{
	LPDIRECT3DDEVICE9 l_Device=CORE->GetRenderManager()->GetDevice();
	l_Device->SetDepthStencilSurface(m_OldDepthStencilRenderTarget);
	CHECKED_RELEASE(m_OldDepthStencilRenderTarget);
	l_Device->SetRenderTarget(0, m_OldRenderTarget);
	CHECKED_RELEASE(m_OldRenderTarget);
}
CInputManagerImplementation::~CInputManagerImplementation()
{
	if (m_Mouse != NULL)
		m_Mouse->Unacquire();

	CHECKED_RELEASE(m_Mouse);
	CHECKED_RELEASE(m_DI);
}
void CCubeTexture::UnsetAsRenderTarget(size_t IdStage)
{
	LPDIRECT3DDEVICE9 l_Device=CORE->GetRenderManager()->GetDevice();

	if(!m_ViewportStencil)
	{
		l_Device->SetDepthStencilSurface(m_OldDepthStencilRenderTarget);
		CHECKED_RELEASE(m_OldDepthStencilRenderTarget);
	}
	l_Device->SetRenderTarget(IdStage, m_OldRenderTarget);
	CHECKED_RELEASE(m_OldRenderTarget);
}
示例#6
0
CDebugRender::~CDebugRender()
{
    CHECKED_DELETE(m_AxisRenderableVertexs);
    CHECKED_DELETE(m_GridRenderableVertexs);
    CHECKED_DELETE(m_CubeRenderableVertexs);
    CHECKED_DELETE(m_SphereRenderableVertexs);

    CHECKED_RELEASE(m_DrawQuadBlendState);
    CHECKED_DELETE(m_DrawQuadRV);

    CHECKED_RELEASE(m_WireframeRenderState);
    CHECKED_RELEASE(m_SolidRenderState);
}
void CContextManager::Resize(HWND hWnd, unsigned int Width, unsigned int Height)
{
	if (m_D3DDevice != nullptr)
	{
		CHECKED_RELEASE(m_RenderTargetView);
		CHECKED_RELEASE(m_DepthStencil);
		CHECKED_RELEASE(m_DepthStencilView);

		m_SwapChain->ResizeBuffers(0, Width, Height, DXGI_FORMAT_UNKNOWN, 0);
		HRESULT hr = CreateBackBuffer(hWnd, Width, Height);
		assert(hr == S_OK);
	}
}
示例#8
0
HRESULT CContextManager::CreateBackBuffer(HWND hWnd, int Width, int Height)
{

	CHECKED_RELEASE(m_RenderTargetView);
	CHECKED_RELEASE(m_DepthStencil);
	CHECKED_RELEASE(m_DepthStencilView);

	m_Width = Width;
	m_Height = Height;

	ID3D11Texture2D *pBackBuffer;
	if (FAILED(m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer)))
		return FALSE;
	HRESULT hr = m_D3DDevice->CreateRenderTargetView(pBackBuffer, NULL, &m_RenderTargetView);
	pBackBuffer->Release();
	if (FAILED(hr))
		return FALSE;


	D3D11_TEXTURE2D_DESC descDepth;
	ZeroMemory(&descDepth, sizeof(descDepth));
	descDepth.Width = Width;
	descDepth.Height = Height;
	descDepth.MipLevels = 1;
	descDepth.ArraySize = 1;
	descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
	descDepth.SampleDesc.Count = 1;
	descDepth.SampleDesc.Quality = 0;
	descDepth.Usage = D3D11_USAGE_DEFAULT;
	descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL;
	descDepth.CPUAccessFlags = 0;
	descDepth.MiscFlags = 0;
	hr = m_D3DDevice->CreateTexture2D(&descDepth, NULL, &m_DepthStencil);
	if (FAILED(hr))
		return hr;

	D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
	ZeroMemory(&descDSV, sizeof(descDSV));
	descDSV.Format = descDepth.Format;
	descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
	descDSV.Texture2D.MipSlice = 0;
	hr = m_D3DDevice->CreateDepthStencilView(m_DepthStencil, &descDSV, &m_DepthStencilView);
	if (FAILED(hr))
		return hr;

	return S_OK;
}
//----------------------------------------------------------------------------
// Free memory
//----------------------------------------------------------------------------
void CInputManager::Release () 
{
	LOGGER->AddNewLog(ELL_INFORMATION, "InputManager:: shutting down DirectInput");

	CHECKED_DELETE(m_pKB);
	CHECKED_DELETE(m_pMouse);
	CHECKED_DELETE(m_pGamePad);
	CHECKED_RELEASE(m_pDI);
  CHECKED_DELETE(m_pAction);

	LOGGER->AddNewLog(ELL_INFORMATION, "InputManager:: offline (ok)");
}
示例#10
0
CContextManager::~CContextManager()
{
	CHECKED_RELEASE(m_D3DDevice);
	CHECKED_RELEASE(m_DeviceContext);
	CHECKED_RELEASE(m_SwapChain);
	CHECKED_RELEASE(m_RenderTargetView);
	CHECKED_RELEASE(m_DepthStencil);
	CHECKED_RELEASE(m_DepthStencilView);
}
示例#11
0
void CCubeTexture::Release()
{
	CHECKED_RELEASE(cubeFacePX);
	cubeFacePX=NULL;
	CHECKED_RELEASE(cubeFacePY);
	cubeFacePY=NULL;
	CHECKED_RELEASE(cubeFacePZ);
	cubeFacePZ=NULL;
	CHECKED_RELEASE(cubeFaceNX);
	cubeFaceNX=NULL;
	CHECKED_RELEASE(cubeFaceNX);
	cubeFaceNX=NULL;
	CHECKED_RELEASE(cubeFaceNX);
	cubeFaceNX=NULL;

	CHECKED_RELEASE(m_CubeTexture);
	m_CubeTexture=NULL;
}
示例#12
0
bool CTexture::SetAsRenderTarget()
{
  LPDIRECT3DDEVICE9 l_Device= CORE->GetRenderManager()->GetDevice();
  l_Device->GetRenderTarget(0,&m_OldRenderTarget);

	if (FAILED(m_Texture->GetSurfaceLevel(0,&m_RenderTargetTexture)))
	{
		return false;
	}

	l_Device->SetRenderTarget(0, m_RenderTargetTexture);
	CHECKED_RELEASE(m_RenderTargetTexture);
	if(FAILED(l_Device->GetDepthStencilSurface(&m_OldDepthStencilRenderTarget)))
	{
		return false;
	}
	l_Device->SetDepthStencilSurface(m_DepthStencilRenderTargetTexture);
	
	return true;
}
CEffectVertexShader::~CEffectVertexShader()
{
	CHECKED_RELEASE( m_VertexShader );
	CHECKED_RELEASE( m_VertexLayout );
}
示例#14
0
void CEffect::Release() 
{
  CHECKED_RELEASE(m_pD3DEffect);
  m_pD3DTechnique = 0;
  m_pD3DInstancedTechnique = 0;
}
示例#15
0
bool CEffect::LoadEffect(LPD3DXEFFECTPOOL _pEffectPool)
{
  LPD3DXBUFFER l_ErrorBuffer=NULL;

#ifdef _DEBUG
    HRESULT l_HR = D3DXCreateEffectFromFile(
                          RENDER_MANAGER->GetDevice(),
                          m_szFileName.c_str(),
                          NULL,
                          NULL,
                          D3DXSHADER_OPTIMIZATION_LEVEL0,
                          _pEffectPool,
                          &m_pD3DEffect,
                          &l_ErrorBuffer);
#else
    HRESULT l_HR = D3DXCreateEffectFromFile(
                          RENDER_MANAGER->GetDevice(),
                          m_szFileName.c_str(),
                          NULL,
                          NULL,
                          D3DXSHADER_OPTIMIZATION_LEVEL3,
                          _pEffectPool,
                          &m_pD3DEffect,
                          &l_ErrorBuffer);
#endif

  if(l_ErrorBuffer)
  {
    LOGGER->AddNewLog(ELL_ERROR,"CEffect::Init Error creating effect '%s':\n%s", m_szFileName.c_str(), l_ErrorBuffer->GetBufferPointer());
    CHECKED_RELEASE(l_ErrorBuffer);
  }

  if(l_HR != D3D_OK)
  {
    if(l_HR == D3DERR_INVALIDCALL)
    {
      LOGGER->AddNewLog(ELL_ERROR,"CEffect::Init Error crida invàlida");
    }
    else if(l_HR == D3DXERR_INVALIDDATA)
    {
      LOGGER->AddNewLog(ELL_ERROR,"CEffect::Init Error invalid data");
    }
    else if(l_HR == E_OUTOFMEMORY)
    {
      LOGGER->AddNewLog(ELL_ERROR,"CEffect::Init Error out of memory");
    }

    return false;
  }

  m_pD3DTechnique = m_pD3DEffect->GetTechniqueByName(m_szTechniqueName.c_str());

  m_pD3DInstancedTechnique = m_pD3DEffect->GetTechniqueByName(m_szInstancedTechniqueName.c_str());

  m_pD3DAlphaTechnique = m_pD3DEffect->GetTechniqueByName(m_szD3DAlphaTechniqueName.c_str());

  if(m_pD3DTechnique)
  {
    m_pD3DEffect->SetTechnique(m_pD3DTechnique);
  }

  return true;
}
示例#16
0
bool CEffect::LoadEffect()
{
	LPD3DXBUFFER l_ErrorBuffer=NULL;

	std::string extension = "";

#ifdef _DEBUG
	extension = "_d.fxo";
#else
	extension = ".fxo";
#endif

	HRESULT l_HR=D3DXCreateEffectFromFile(CORE->GetRenderManager()->GetDevice(), (m_FileName + extension).c_str(), NULL,
		NULL, D3DXSHADER_DEBUG, NULL, &m_Effect, &l_ErrorBuffer);
	
	if(FAILED(l_HR) || l_ErrorBuffer)
	{
		std::string l_Err = "";
		if( l_ErrorBuffer != NULL )
		{
			LPVOID l_ErrPointer = l_ErrorBuffer->GetBufferPointer();
			l_Err = static_cast<char*>( l_ErrPointer );
		}
		else
		{
			l_Err = "Error al cargar el efecto: " + m_FileName;
		}
		
		std::string msg_error = "CEffect::LoadEffect->" + l_Err;
		LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str());
		CHECKED_RELEASE(l_ErrorBuffer);

		return false;
	}

	//Matrices
	GetParameterBySemantic("PROJECTION", m_ProjectionMatrixParameter, false);
	GetParameterBySemantic("VIEW", m_ViewMatrixParameter, false);
	GetParameterBySemantic("WORLD", m_WorldMatrixParameter, false);
	GetParameterBySemantic("WORLDVIEWPROJECTION", m_WorldViewProjectionMatrixParameter, false);
	GetParameterBySemantic("VIEWPROJECTION", m_ViewProjectionMatrixParameter, false);
	GetParameterBySemantic("VIEWINVERSE", m_ViewInverseMatrixParameter, false);
	GetParameterBySemantic("PROJECTIONINVERSE", m_ProjInverseMatrixParameter, false);
	GetParameterBySemantic("VIEWPROJECTIONINVERSE", m_ViewProjectionInverseMatrixParameter, false);
	
	//Prev Matrices
	GetParameterBySemantic("VIEW_PREV", m_PrevViewMatrixParameter, false);
	GetParameterBySemantic("PROJECTION_PREV", m_PrevProjectionMatrixParameter, false);
	GetParameterBySemantic("VIEWPROJECTION_PREV", m_PrevViewProjectionMatrixParameter, false);
	
	//Camera
	GetParameterBySemantic("CAMERA_POSITION", m_CameraPositionParameter, false);

	//Lights
	GetParameterBySemantic("Num_Lights", m_NumLightsParameter, false);
	GetParameterBySemantic("Lights_Type", m_LightsTypeParameter, false);
	GetParameterBySemantic("Lights_Position", m_LightsPositionParameter, false);
	GetParameterBySemantic("Lights_Direction", m_LightsDirectionParameter, false);
	GetParameterBySemantic("Lights_Color", m_LightsColorParameter, false);
	GetParameterBySemantic("Lights_StartAtt", m_LightsStartRangeAttenuationParameter, false);
	GetParameterBySemantic("Lights_EndAtt", m_LightsEndRangeAttenuationParameter, false);
	GetParameterBySemantic("Lights_Angle", m_LightsAngleParameter, false);
	GetParameterBySemantic("Lights_FallOff", m_LightsFallOffParameter, false);
	GetParameterBySemantic("Lights_Intensity", m_LightIntensityParameter, false);
	GetParameterBySemantic("Lights_LinNearFar", m_LightLinNearFarParameter, false);
	GetParameterBySemantic("Lights_Shadow_LinNearFar", m_ShadowLightLinNearFarParameter, false);
	
	//Time
	GetParameterBySemantic("TIME", m_TimeParameter, false);

	//Bones
	GetParameterBySemantic("BONES", m_BonesParameter, false);

	//Shadows
	GetParameterBySemantic("SHADOW_VIEW", m_ShadowViewParameter, false);
	GetParameterBySemantic("SHADOW_WORLDVIEW", m_ShadowWorldViewMatrixParameter, false);
	GetParameterBySemantic("SHADOW_VIEWPROJECTION", m_ShadowViewProjectionMatrixParameter, false);
	GetParameterBySemantic("SHADOW_CAMERA_POSITION", m_ShadowCameraPositionParameter, false);
	GetParameterBySemantic("SHADOW_WORLDVIEWPROJECTION", m_ShadowWorldViewProjectionMatrixParameter, false);
	GetParameterBySemantic("Lights_Shadow_Static_Enable", m_LightShadowStaticEnableParameter, false);
	GetParameterBySemantic("Lights_Shadow_Dynamic_Enable", m_LightShadowDynamicEnableParameter, false);

	GetParameterBySemantic("STATIC_SHADOW_MAP_1", m_StaticShadowMapSamplerParameter[0], false);
	GetParameterBySemantic("STATIC_SHADOW_MAP_2", m_StaticShadowMapSamplerParameter[1], false);
	GetParameterBySemantic("STATIC_SHADOW_MAP_3", m_StaticShadowMapSamplerParameter[2], false);
	GetParameterBySemantic("STATIC_SHADOW_MAP_4", m_StaticShadowMapSamplerParameter[3], false);

	GetParameterBySemantic("DYNAMIC_SHADOW_MAP_1", m_DynamicShadowMapSamplerParameter[0], false);
	GetParameterBySemantic("DYNAMIC_SHADOW_MAP_2", m_DynamicShadowMapSamplerParameter[1], false);
	GetParameterBySemantic("DYNAMIC_SHADOW_MAP_3", m_DynamicShadowMapSamplerParameter[2], false);
	GetParameterBySemantic("DYNAMIC_SHADOW_MAP_4", m_DynamicShadowMapSamplerParameter[3], false);

	//Cascade
	GetParameterBySemantic("CASCADE_SHADOW_VIEWPROJECTION", m_CascadeShadowViewProjectionParameter, false);
	GetParameterBySemantic("CASCADE_DISTANCES", m_CascadeDistancesParameter, false);
	GetParameterBySemantic("CASCADE_SHADOW_MAP_PIXEL_SIZE", m_CascadeShadowMapPixelSizeParameter, false);

	//Misc
	GetParameterBySemantic("HALFPIXEL", m_HalfPixelParameter, false);
	GetParameterBySemantic("RENDER_TARGET_SIZE", m_RenderTargetSizeParameter, false);
	GetParameterBySemantic("ELAPSED_TIME", m_ElapsedTimeParameter, false);
	GetParameterBySemantic("TOTAL_ELAPSED_TIME", m_TotalElapsedTimeParameter, false);
	GetParameterBySemantic("TEXTURE_DIM", m_TextureDimParameter, false);

	//Parameters
	for(uint16 i=0; i<MAX_PARAMS_BY_EFFECT; ++i)
	{
		std::stringstream out;
		out << i;
		std::string l_Name = "PARAMETER" + out.str();
		D3DXHANDLE l_Handle = NULL;
		GetParameterBySemantic(l_Name, l_Handle, false);
		m_Parameters[i] = l_Handle;
	}

 	return true;
}
示例#17
0
void CRenderTarget::Release()
{
  CHECKED_RELEASE(m_pDepthStencilSurface);
}
示例#18
0
void CEffect::Unload()
{
	SetNullParameters();
	CHECKED_RELEASE( m_Effect );		
}
CEffectGeometryShader::~CEffectGeometryShader()
{
	CHECKED_RELEASE( m_GeometryShader );
}
示例#20
0
void CTexture::Unload()
{
	CHECKED_RELEASE(m_Texture);
}
void CEffectVertexShader::destroy()
{
	CHECKED_RELEASE( m_VertexShader );
	CHECKED_RELEASE( m_VertexLayout );
}