示例#1
0
HRESULT PreviewGenerator::ShowPreviewWithPreviewHandler(IStream *stream, CLSID cls)
{
	DWORD dwRet = ERROR_BAD_ARGUMENTS;
	if (iPHandler)
	{
		iPHandler->Unload();
		SAFERELEASE(iPHandler);
		
	}
	IInitializeWithStream	*iIStream;
	HRESULT hr = CoCreateInstance(cls, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IPreviewHandler, (LPVOID*)&iPHandler);
	if (hr == S_OK)
	{
		hr = iPHandler->QueryInterface(IID_IInitializeWithStream, (LPVOID*)&iIStream);
	}
	else
	{
		return hr;
	}
	if ( iIStream)
	{
		hr = iIStream->Initialize(stream, STGM_READ);
	}
	if (iPHandler &&  hr == S_OK)
		hr = DoPreview();

	SAFERELEASE(iIStream);
	return hr;
}
STDMETHODIMP CPolyTool::OnToolChanging(VARIANT varHint)
{
	HRESULT hr = S_OK;
	long lCount;
	HWND hWnd;


	if (nTimerID)
	{
		m_pUIView->get_HWND(&hWnd);

		KillTimer(hWnd, nTimerID);
		nTimerID = 0;
	}

	if(NULL != m_pBoundary)
	{

		hr = m_pCurrentBoundaryList->get_Count(&lCount);
		if( FAILED(hr) ) goto EXIT_FAIL;

		m_pCurrentBoundaryList->RemoveAt( lCount-1 );
		
		SAFERELEASE(m_pCurrentThing);
		SAFERELEASE(m_pBoundary);
		SAFERELEASE(m_pCurrentThingFrame);
		SAFERELEASE(m_pCurrentBoundaryList);

		m_cVertices = 0;
	}
EXIT_FAIL:

	return S_OK;
}
示例#3
0
void Console::cleanup() {
	SDLOG(2, "Console cleanup\n")
	device = NULL;
	SAFERELEASE(vertexDeclaration);
	SAFERELEASE(effect);
	SAFERELEASE(fontTex);
}
示例#4
0
HRESULT CGraphics::UninitializeDisplay(void)
{
	Invalidate();

	SAFERELEASE(m_Device);
	SAFERELEASE(m_Direct3D);

	if(IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
	{
		_aligned_free(m_Levels);
		_aligned_free(m_LevelsBuffer);
		_aligned_free(m_Waveform);
		_aligned_free(m_WaveformBuffer);
	}
	else
	{
		free(m_Levels);
		free(m_LevelsBuffer);
		free(m_Waveform);
		free(m_WaveformBuffer);
	}

	m_Levels = NULL;
	m_LevelsBuffer = NULL;
	m_Waveform = NULL;
	m_WaveformBuffer = NULL;

	m_Hwnd = NULL;

	return S_OK;
}
示例#5
0
文件: Audio.cpp 项目: m1h4/Visualizer
HRESULT CAudio::UninitializeCapture(void)
{
	ENTER_SECTION(this);

	StopCapture();

	// Check if uninitialized
	if(!m_Capture)
		return S_FALSE;

	// Tell the thread to close
	PostThreadMessage(m_CaptureId,WM_QUIT,NULL,NULL);

	if(WaitForSingleObject(m_Capture,2000) == WAIT_TIMEOUT)
		TerminateThread(m_Capture,0x000000FF);

	CloseHandle(m_Capture);
	m_Capture = NULL;
	m_CaptureId = NULL;

	SAFERELEASE(m_CaptureBuffer);
	SAFERELEASE(m_SoundCapture);

	return S_OK;
}
示例#6
0
void DS2Plugin::prePresent() {
	SAFERELEASE(zBufferSurf);
	SAFERELEASE(normalSurf);
	SAFERELEASE(hdrRT);
	aaStepStarted = false;
	aoDone = false;
}
//
// fill the room node of the tree
//
void CThingTreeCtrl::FillRoomNode()
{
	HRESULT hr = S_OK;
	IThing *pUser = NULL;
	IThing *pRoom = NULL;

	if (!m_pWorld)
		return;

	if (FAILED(hr = m_pWorld->get_User(&pUser)))
		goto exit;

	if (!pUser || FAILED(hr = pUser->get_Container(&pRoom)))
		goto exit;

	if (!pRoom)
		goto exit;

	m_hRoom = AddThingToTree(TVI_ROOT, pRoom);
	if (m_hRoom)
		AddContentsToTree(m_hRoom, pRoom);

	m_treeCtrl.Expand(m_hRoom, TVE_EXPAND);
	m_treeCtrl.SortChildren(m_hRoom);

exit:
	SAFERELEASE(pUser);
	SAFERELEASE(pRoom);
}
HRESULT RSManager::redirectSetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {

	if(dumpingFrame) {
		IDirect3DSurface9* rt;
		d3ddev->GetRenderTarget(RenderTargetIndex, &rt);
		if(rt) {
			dumpSurface(format("framedump_preswitch%03u_target%d_pointer%p", renderTargetSwitches, RenderTargetIndex, rt).c_str(), rt);
		}
		SAFERELEASE(rt);
	}

	HRESULT hr = plugin->redirectSetRenderTarget(RenderTargetIndex, pRenderTarget);
	renderTargetSwitches++;

	if(dumpingFrame) {
		IDirect3DSurface9* rt;
		d3ddev->GetRenderTarget(RenderTargetIndex, &rt);
		if(rt) {
			dumpSurface(format("framedump_postswitch%03u_target%d_pointer%p", renderTargetSwitches, RenderTargetIndex, rt).c_str(), rt);
		}
		SAFERELEASE(rt);
	}

	return hr;
}
HRESULT C2DThingCoordTransformer::StoreThingCoords(IThing * pThing)
{
	HRESULT hr = S_OK;
	IThing* pTmpParentThing = NULL;

	m_bDoTransform = TRUE;

	if(NULL == pThing)
	{
		m_bDoTransform = FALSE;
		hr = E_INVALIDARG;
		goto EXIT_FAIL;
	}

	SAFERELEASE(m_pThing);
	m_pThing = pThing;
	SAFEADDREF(m_pThing);

	IdentityMatrix(&m_d3dMatrix);
	IdentityMatrix(&m_d3dInverseMatrix);

	hr = m_pThing->get_Container(&pTmpParentThing);
	if ( SUCCEEDED(hr) && pTmpParentThing)
	{
		BuildTransformation(pThing, pTmpParentThing);
	}

	goto EXIT_SUCCESS2;

EXIT_FAIL:
	ASSERT(0); 
EXIT_SUCCESS2:
	SAFERELEASE(pTmpParentThing);
	return hr;
}
STDMETHODIMP CAvatarProfileObject::UnMarshall(IUnMarshallBuffer* pbuffer)
{
	HRESULT hr = S_OK;

	ASSERT(pbuffer);

	//clear current data.
	SAFERELEASE(m_pBannedObjects);
	SAFERELEASE(m_pKeys);
	SAFERELEASE(m_pAvatar);

	hr = CAvatarProfileObjectBase::UnMarshall(pbuffer);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	hr = m_pWorld->UnMarshallObjectProperty(pbuffer, (IObjectProperty**)&m_pBannedObjects);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	hr = m_pWorld->UnMarshallObjectProperty(pbuffer, (IObjectProperty**)&m_pKeys);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	hr = m_pWorld->UnMarshallObjectProperty(pbuffer, (IObjectProperty**)&m_pAvatar);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

ERROR_ENCOUNTERED:
	return hr;
}
STDMETHODIMP CAvatarProfileObject::ReadFromDisk(BSTR bstrFilename)
{
	//clear current data.
	SAFERELEASE(m_pBannedObjects);
	SAFERELEASE(m_pKeys);

	//load into buffer.
	IUnMarshallBuffer *pbuffer = NULL;

	HRESULT hr = CoCreateInstance(CLSID_UnMarshallBuffer, NULL, CLSCTX_INPROC_SERVER,
		IID_IUnMarshallBuffer, (LPVOID*)&pbuffer);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	hr = pbuffer->ReadFromDisk(bstrFilename);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	//load into current object.
	hr = UnMarshall(pbuffer);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

ERROR_ENCOUNTERED:
	if (FAILED(hr))
		Reset();

	SAFERELEASE(pbuffer);

	return hr;
}
STDMETHODIMP CAvatarProfileObject::Reset(void)
{
	HRESULT	hr = S_OK;

	SAFERELEASE(m_pBannedObjects);
	SAFERELEASE(m_pKeys);

	// banned objects
	if (m_pWorld == NULL)
		return VWOBJECT_E_INVALIDWORLD;

	hr = CreatePropertyList(m_pWorld, &m_pBannedObjects);
	if (FAILED(hr) || (!m_pBannedObjects))
		goto ERROR_ENCOUNTERED;

	// keys - the actual values
	hr = CreatePropertyMap(m_pWorld, &m_pKeys);
	if (FAILED(hr) || (!m_pKeys))
		goto ERROR_ENCOUNTERED;

ERROR_ENCOUNTERED:
	if (FAILED(hr))
	{
		SAFERELEASE(m_pBannedObjects);
		SAFERELEASE(m_pKeys);
	}

	return hr;
}
示例#13
0
HRESULT DS2Plugin::redirectSetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
	// At this point, we can grab the z (RT1) and normal (RT0) RTs
	if(RenderTargetIndex == 1 && pRenderTarget == NULL && zBufferSurf == NULL) {
		SAFERELEASE(zBufferSurf);
		SAFERELEASE(normalSurf);
		d3ddev->GetRenderTarget(1, &zBufferSurf);
		d3ddev->GetRenderTarget(0, &normalSurf);
	}
	// If previous RT was D3DFMT_A16B16G16R16F, store RT
	else if(((doAO && ssao) || (doBloom && bloom)) && !aoDone && !hdrRT && RenderTargetIndex == 0 && zBufferSurf != NULL && defaultState != NULL) {
		IDirect3DSurface9* prevRT = NULL;
		d3ddev->GetRenderTarget(0, &prevRT);
		if(prevRT) {
			D3DSURFACE_DESC desc;
			prevRT->GetDesc(&desc);
			if(desc.Format == D3DFMT_A16B16G16R16F && (desc.Width == manager.getRenderWidth() || desc.Height == manager.getRenderHeight()) && !aoDone) {
				// store RT for later use
				hdrRT = prevRT;
			}
			else {
				SAFERELEASE(prevRT);
			}
		}
	}
	return GamePlugin::redirectSetRenderTarget(RenderTargetIndex, pRenderTarget);
}
示例#14
0
文件: Shader.cpp 项目: q4r/QEngine
Shader::~Shader(void){
	SAFERELEASE(vsBuffer);
	SAFERELEASE(psBuffer);

	SAFERELEASE(matrixBuffer);
	SAFERELEASE(lightBuffer);
	LOG("Shader: destructor");
}
示例#15
0
//--------------------------------------------------------------------------------------
DepthTexture::~DepthTexture() {
	if(!m_isRESZ) {
		if(m_pTexture != NULL) NvAPI_D3D9_UnregisterResource(m_pTexture);
		if(m_pSurface != NULL) NvAPI_D3D9_UnregisterResource(m_pSurface);
	}
	SAFERELEASE(m_pSurface);
	SAFERELEASE(m_pTexture);
}
BOOL CPolyTool::OnKeyDown( UINT nVirtKey, LPARAM lKeyData )
{
	HRESULT hr = S_OK;
	VARIANT_BOOL vbBool = VARIANT_TRUE;
	long lCount;

	if (nVirtKey == VK_BACK)
	{
		if(NULL != m_pBoundary)
		{
			if (m_cVertices > 2 )
			{
				hr = m_pBoundary->DeleteVertex(m_cVertices - 1);
				if( FAILED(hr) ) goto EXIT_FAIL;

//				if(vbBool != VARIANT_TRUE)
//					MessageBeep(MB_ICONASTERISK);
//				else
//				{
					m_cVertices--;
					InvokeToolEvent(TOOLEVENT_BOUNDARYUPDATE, m_pBoundary, bstrNULL, bstrNULL, bstrNULL, VARIANT_FALSE);
//				}

			}
			else
			{
				hr = m_pCurrentBoundaryList->get_Count(&lCount);
				if( FAILED(hr) ) goto EXIT_FAIL;

				hr = m_pCurrentBoundaryList->RemoveAt( lCount-1 );
				if( FAILED(hr) ) goto EXIT_FAIL;

				m_cVertices = 0;

//				ClipCursor(NULL);
//				ReleaseCapture();

				SAFERELEASE(m_pCurrentThing);
				SAFERELEASE(m_pBoundary);
				SAFERELEASE(m_pCurrentThingFrame);
				SAFERELEASE(m_pCurrentBoundaryList);
				
			}
			return TRUE;
		}
	}
	else if (nVirtKey == VK_RETURN && m_cVertices > 2)
	{
		ClosePolygon(0, CPoint(0,0));
		return TRUE;
	}

	//MessageBeep(-1);


EXIT_FAIL:
	return FALSE; 
}
//The function recursively builds up the transformation of the pThing 
//until it's in room-space coordinates
HRESULT C2DThingCoordTransformer::BuildTransformation(IThing * pThing, IThing * pParentThing)
{
	IVector * pVector = NULL;
	HRESULT hr = S_OK;
	IThing* pTmpParentThing = NULL;
	D3DRMMATRIX4D tmpMatrix;
	float flScaleX, flScaleY, flScaleZ;
	float flThingX, flThingY, flThingZ, // Position of current Thing having cells edited
	      flThingDirX, flThingDirY, flThingDirZ; // Orientation of current Thing having cells edited

	if (!pThing || !pParentThing)
		goto EXIT_FAIL;

	// Store the position Vector of the Thing
	hr = pThing->get_ObjectProperty(bstrPosition, (IObjectProperty **) &pVector);
	if( FAILED(hr) || !pVector) goto EXIT_FAIL;
	hr = pVector->get(&flThingX, &flThingY, &flThingZ);
	if( FAILED(hr) ) goto EXIT_FAIL;
	SAFERELEASE(pVector);

	// Get the Scale Vector of the Thing
	hr = pThing->get_ObjectProperty(bstrScale, (IObjectProperty **) &pVector);
	if( FAILED(hr) || !pVector) goto EXIT_FAIL;
	hr = pVector->get(&flScaleX, &flScaleY, &flScaleZ);
	if( FAILED(hr) ) goto EXIT_FAIL;
	SAFERELEASE(pVector);

	// Store the Direction Vector of the Thing
	hr = pThing->get_ObjectProperty(bstrDirection, (IObjectProperty **) &pVector);
	if( FAILED(hr) ) goto EXIT_FAIL;
	hr = pVector->get(&flThingDirX, &flThingDirY, &flThingDirZ);
	if( FAILED(hr) ) goto EXIT_FAIL;
	SAFERELEASE(pVector);

	IdentityMatrix(&tmpMatrix);
	ScaleMatrix(&tmpMatrix, flScaleX, flScaleY, flScaleZ);
	RotateMatrix(&tmpMatrix, flThingDirX, flThingDirY, flThingDirZ);
	TranslateMatrix(&tmpMatrix, flThingX, flThingY, flThingZ);
	PostMultiplyMatrix(&m_d3dMatrix, &tmpMatrix);

	IdentityMatrix(&tmpMatrix);
	TranslateMatrix(&tmpMatrix, -flThingX, -flThingY, -flThingZ);
	InverseRotateMatrix(&tmpMatrix, flThingDirX, flThingDirY, flThingDirZ);
	ScaleMatrix(&tmpMatrix, 1.0f / flScaleX, 1.0f / flScaleY, 1.0f / flScaleZ);
	PostMultiplyMatrix(&m_d3dInverseMatrix, &tmpMatrix);

	hr = pParentThing->get_Container(&pTmpParentThing);
	if ( SUCCEEDED(hr) && pTmpParentThing)
	{
		BuildTransformation(pParentThing, pTmpParentThing);
	}


EXIT_FAIL:
	SAFERELEASE(pTmpParentThing);
	SAFERELEASE(pVector);
	return hr;
}
示例#18
0
HRESULT CGraphics::Invalidate(void)
{
	SAFERELEASE(m_SpriteBuffer);
	SAFERELEASE(m_LineBuffer);
	SAFERELEASE(m_BlurTexture);
	SAFERELEASE(m_VisualizationTexture);

	return S_OK;
}
CSimpleFusionBindSink::~CSimpleFusionBindSink()
{
    SAFERELEASE(_pBind);
    SAFERELEASE(_pdbglog);

    if (_hEvent) {
        SAFEDELETE(_hEvent);
    }
}
CPolyTool::~CPolyTool()
{
	TRACE("CPolyTool::~CPolyTool\n");
	SAFERELEASE(m_piEditorViewControl);
	SAFERELEASE(m_pCurrentThing);
	SAFERELEASE(m_pCurrentBoundaryList);
	SAFERELEASE(m_pCurrentThingFrame);
	SAFERELEASE(m_pExecuteUndo);
}
//
// AddContentsToTree
// given a thing and a HTREEITEM
// goes through the contents of the thing and adds them to the tree
void CThingTreeCtrl::AddContentsToTree(HTREEITEM hParent, IThing *pParent)
{
	if (!pParent)
		return;

	HRESULT hr = S_OK;
	IPropertyList *pContents = NULL;
	long lCount, i;
	IObjectProperty *pProp = NULL;
	IThing *pThing = NULL;
	HTREEITEM hCurrentItem;
	VARIANT_BOOL vbStub = VARIANT_FALSE;

	if (FAILED(hr = pParent->get_Contents(&pContents)))
		goto exit;

	if (!pContents)
		goto exit;

	if (FAILED(hr = pContents->get_Count(&lCount)))
		goto exit;

	for (i = 0; i < lCount; i++)
	{
		if (FAILED(hr = pContents->get_ObjectPropertyExt(i, IID_IThing, (IObjectProperty **) &pProp)))
			goto exit;
		
		if (!pProp)
			goto exit;
		
		if (FAILED(hr = pProp->QueryInterface(IID_IThing, (LPVOID*)&pThing)))
			goto exit;

		if (FAILED(hr = pThing->get_IsStub(&vbStub)))
			goto exit;
		
		if (vbStub == VARIANT_TRUE)
			goto exit;

		// add the thing to the the tree
		hCurrentItem = AddThingToTree(hParent, pThing);
		if (!hCurrentItem)
			goto exit;

		AddContentsToTree(hCurrentItem, pThing);
		m_treeCtrl.SortChildren(hCurrentItem);
		SAFERELEASE(pProp);
		SAFERELEASE(pThing);
		pThing = NULL;
	}

exit:
	SAFERELEASE(pProp);
	SAFERELEASE(pThing);
	SAFERELEASE(pContents);
}
示例#22
0
Node *
ReadFile
(
   const char * fileName
)
{
   IStream * pStream;
   IXmlReader * pReader;

   HANDLE fileHandle = CreateFile(fileName, FILE_GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
   if (fileHandle == INVALID_HANDLE_VALUE)
   {
      Fatal("Cannot open XML file %s", fileName);
   }

   if (FAILED(CreateStreamOnHandle(fileHandle, &pStream)))
   {
      Fatal("Cannot create stream from file");
   }

   if (FAILED(CreateXmlReader(__uuidof(IXmlReader), (void**) &pReader, nullptr)))
   {
      Fatal("Cannot create XML reader");
   }

   if (FAILED(pReader->SetProperty(XmlReaderProperty_DtdProcessing, DtdProcessing_Prohibit)))
   {
      Fatal("Cannot prohibit DTD processing");
   }

   if (FAILED(pReader->SetInput(pStream)))
   {
      Fatal("Cannot set XML reader input");
   }

   Node * topNode;
   if (FAILED(ParseXml(pReader, &topNode)))
   {
      unsigned int line, linePos;
      pReader->GetLineNumber(&line);
      pReader->GetLinePosition(&linePos);
      fprintf(
         stderr,
         "Error on line %d, position %d in \"%s\".\n",
         line,
         linePos,
         fileName);
      Fatal("Error parsing XML");
   }

   SAFERELEASE(pReader);
   SAFERELEASE(pStream);
   CloseHandle(fileHandle);

   return topNode;
}
CVWScale3DTool::~CVWScale3DTool()
{
	DeletePtrListElements(&m_TransformList);

	SAFERELEASE(m_pRMCameraFrame);
	SAFERELEASE(m_piEditorViewControl);
	SAFERELEASE(m_pVector);
	SAFERELEASE(m_pVWRenderRoot);
	SAFERELEASE(m_pWorld);
}
示例#24
0
DS2Plugin::~DS2Plugin() {
	SAFERELEASE(defaultState);
	SAFERELEASE(zBufferSurf);
	SAFERELEASE(hdrRT);
	SAFEDELETE(dof);
	SAFEDELETE(fxaa);
	SAFEDELETE(smaa);
	SAFEDELETE(ssao);
	SAFEDELETE(post);
	SAFEDELETE(bloom);
}
HRESULT CRotate2DTool::OnDoneRotating()
{
	BOOL bHandled = FALSE; 
	IVWUndoItem		*pVWUndoItem = NULL;
	HRESULT hr = S_OK;
	CRotateObject * pCTrans = NULL;
	int numRotated = 0, nCount;
	IPropertyList* pBoundaryList = NULL;
	CComBSTR bstr1, bstr2, bstr3;
	CString tmpStr;

	if (!m_TransformList.IsEmpty())
	{
		for( POSITION pos = m_TransformList.GetHeadPosition(); pos != NULL; )
		{
			bHandled = TRUE;
			pCTrans = m_TransformList.GetNext( pos );
			if(NULL != pCTrans)
			{
				CComVariant pvarBoundary;

				//Notify BoundaryList that the boundary has changed
				hr = pCTrans->m_pPickData->get_BoundaryIndex(&nCount);
				if (FAILED(hr)) goto FAIL_EXIT;

				hr = pCTrans->m_pPickData->get_BoundaryList(&pBoundaryList);
				if (FAILED(hr)) goto FAIL_EXIT;

				hr = m_pWorld->CloneProperty( CComVariant(pCTrans->m_pBoundary), &pvarBoundary);
				if (FAILED(hr)) goto FAIL_EXIT;
					
				hr = pBoundaryList->put_Property(nCount, pvarBoundary);
				if (FAILED(hr)) goto FAIL_EXIT;

				tmpStr = "0.0";
				bstr1 = tmpStr;
				tmpStr = "";
				bstr2 = tmpStr;
				bstr3 = tmpStr;

				InvokeToolEvent(TOOLEVENT_2DOBJECTROTATED, pCTrans->m_pPickData, bstr1, bstr2, bstr3, VARIANT_TRUE); 

				SAFERELEASE(pBoundaryList);
			}
		}
		bHandled = TRUE;
	}

FAIL_EXIT:
	SAFERELEASE(pBoundaryList);

	return bHandled;
}
示例#26
0
void Console::initialize(IDirect3DDevice9* device, int w, int h) {
	SDLOG(0, "Initializing Console on device %p\n", device);
	width = w;
	height = h;
	this->device = device;
	
	// Create font
	SDLOG(2, " - creating console font\n");
	SAFERELEASE(fontTex);
	FILE* ff = fopen(getAssetFileName("font.ttf").c_str(), "rb");
	unsigned char* ttf_buffer = new unsigned char[1<<20];
	unsigned char* temp_bitmap = new unsigned char[BMPSIZE*BMPSIZE];
	fread(ttf_buffer, 1, 1<<20, ff);
	fclose(ff);
	stbtt_BakeFontBitmap(ttf_buffer, 0, 40.0, temp_bitmap, BMPSIZE, BMPSIZE, 32, 96, cdata); // no guarantee this fits!
	device->CreateTexture(BMPSIZE, BMPSIZE, 0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8, D3DPOOL_DEFAULT, &fontTex, NULL);
	IDirect3DTexture9 *tempTex;
	device->CreateTexture(BMPSIZE, BMPSIZE, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_SYSTEMMEM, &tempTex, NULL);
	D3DLOCKED_RECT rect;
	tempTex->LockRect(0, &rect, NULL, 0);
	memcpy(rect.pBits, temp_bitmap, BMPSIZE*BMPSIZE);
	tempTex->UnlockRect(0);
	device->UpdateTexture(tempTex, fontTex);
	tempTex->Release();
	delete ttf_buffer;
	delete temp_bitmap;
	
	// Create vertex decl
	SDLOG(2, " - creating console vertex decl\n");
	SAFERELEASE(vertexDeclaration);
	device->CreateVertexDeclaration(vertexElements , &vertexDeclaration);

	// Load effect from file
	SDLOG(2, " - loading console effect file\n");
	SAFERELEASE(effect);
	vector<D3DXMACRO> defines;
	std::stringstream s;
	D3DXMACRO null = { NULL, NULL };
	defines.push_back(null);
	DWORD flags = D3DXFX_NOT_CLONEABLE | D3DXSHADER_OPTIMIZATION_LEVEL3;

	SDLOG(2, " - actually load effect\n");	
	ID3DXBuffer* errors;
	HRESULT hr = D3DXCreateEffectFromFile(device, getAssetFileName("console.fx").c_str(), &defines.front(), NULL, flags, NULL, &effect, &errors);
	if(hr != D3D_OK) SDLOG(0, "ERRORS:\n %s\n", errors->GetBufferPointer());

	// get handles
	rectColorHandle = effect->GetParameterByName(NULL, "rectColor");
	textTex2DHandle = effect->GetParameterByName(NULL, "textTex2D");

	SDLOG(0, " - done\n");
}
示例#27
0
void RSManager::releaseResources() {
	SDLOG(0, "RenderstateManager releasing resources\n");
	SAFERELEASE(rgbaBuffer1Surf);
	SAFERELEASE(rgbaBuffer1Tex);
	SAFERELEASE(depthStencilSurf);
	SAFERELEASE(prevStateBlock);
	SAFEDELETE(smaa);
	SAFEDELETE(fxaa);
	SAFEDELETE(ssao);
	SAFEDELETE(gauss);
	SAFEDELETE(hud);
	SDLOG(0, "RenderstateManager resource release completed\n");
}
STDMETHODIMP CAvatarProfileObject::Terminate(void)
{
#ifdef _DEBUG
	VWTRACE(m_pWorld, "VWOBJECT", TRACE_ALLOCATION, "CAvatarProfileObject::Terminate, this 0x%0x\n", this);
#endif

	CAvatarProfileObjectBase::Terminate();

	SAFERELEASE(m_pBannedObjects);
	SAFERELEASE(m_pKeys);
	SAFERELEASE(m_pAvatar);

	return S_OK;
}
void RSManagerDX9::releaseResources() {
	SDLOG(0, "RenderstateManager release: going into neutral state\n");
	for(int i = 0; i < 16; ++i) d3ddev->SetTexture(i, NULL);
	IDirect3DSurface9 *bb = NULL;
	d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb);
	d3ddev->SetRenderTarget(0, bb);
	SAFERELEASE(bb);
	SAFERELEASE(hookedSwapChain0);

	SDLOG(0, "RenderstateManager releasing resources\n");
	SAFEDELETE(plugin);
	perfMonitor.reset(NULL);
	SAFERELEASE(depthStencilSurf);
	extraBuffer.reset(NULL);
	imgWriter.reset(NULL);
	scaler.reset(NULL);
	SAFERELEASE(prevStateBlock);
	SAFERELEASE(initStateBlock);
	SAFERELEASE(prevVDecl);
	SAFERELEASE(prevDepthStencilSurf);
	SAFERELEASE(prevRenderTarget);
	backBuffers.clear();
	console.cleanup();

	SDLOG(0, "RenderstateManager resource release completed\n");
}
void RSManager::releaseResources() {
	SDLOG(0, "RenderstateManager release: going into neutral state\n");
	for(int i = 0; i < 16; ++i) d3ddev->SetTexture(i, NULL);
	IDirect3DSurface9 *bb = NULL;
	d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb);
	d3ddev->SetRenderTarget(0, bb);
	SAFERELEASE(bb);
	SDLOG(0, "RenderstateManager releasing resources\n");
	SAFEDELETE(plugin);
	SAFEDELETE(scaler);
	SAFEDELETE(perfMonitor);
	SAFERELEASE(depthStencilSurf);
	extraBuffer.reset(NULL);
	SAFERELEASE(prevStateBlock);
	SAFERELEASE(prevVDecl);
	SAFERELEASE(prevDepthStencilSurf);
	SAFERELEASE(prevRenderTarget);
	if(backBuffers && backBufferTextures) {
		for(unsigned i = 0; i < numBackBuffers; ++i) {
			SAFERELEASE(backBufferTextures[i]);
			SAFERELEASE(backBuffers[i]);
		}
	}
	SAFEDELETEARR(backBuffers);
	SAFEDELETEARR(backBufferTextures);
	console.cleanup();
	SDLOG(0, "RenderstateManager resource release completed\n");
}