Exemplo n.º 1
0
HRESULT DBOXFont::DrawText(const STRTYPE Text , long TextLenght , int x , int y)
{
    if(Font == NULL) return DBOXFONTE_;

    LPDIRECT3DDEVICE9 device;
    D3DVIEWPORT9		Vp;
    RECT Rect;

    Font->GetDevice(&device);
    device->GetViewport(&Vp);

    int MaxX = Vp.Width;
    int MaxY = Vp.Height;

    if((x > (int)(MaxX)) || (y > (int)(MaxY))) return DBOXFONTE_;

    Rect.left = x;
    Rect.right = MaxX;

    Rect.top = y;
    Rect.bottom = MaxY;

    HRESULT hr = Font->DrawText(NULL , Text , TextLenght, &Rect , DT_TOP|DT_LEFT , Color);
    if(FAILED(hr))return DBOXFONTE_;
    return DBOXFONT_OK;
}
Exemplo n.º 2
0
HRESULT DBOXFont::DrawText(const STRTYPE Text , int x , int y)
{
    if(Font == NULL) return DBOXFONTE_;

    LPDIRECT3DDEVICE9 device;
    D3DVIEWPORT9		Vp;
    RECT Rect;

    Font->GetDevice(&device);
    device->GetViewport(&Vp);

    int MaxX = Vp.Width;
    int MaxY = Vp.Height;

    if((x > (int)(MaxX)) || (y > (int)(MaxY))) return DBOXFONTE_;

    Rect.left = x;
    Rect.right = MaxX;

    Rect.top = y;
    Rect.bottom = MaxY;

    UINT StrLenght = 0;
    for(int i = 0;; i++)
    {
        if(Text[i] != L'\0')StrLenght += 1;
        else break;
    }
    HRESULT hr = Font->DrawText(NULL , Text , (int)(StrLenght) , &Rect , DT_TOP|DT_LEFT , Color);
    if(FAILED(hr))return DBOXFONTE_;
    return DBOXFONT_OK;

}
Exemplo n.º 3
0
void RageDisplay_D3D::SetZBias( float f )
{
	//g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, (int) SCALE( f, 0.0f, 1.0f, 0, 30 ) );
	D3DVIEWPORT9 viewData;
	g_pd3dDevice->GetViewport( &viewData );
	viewData.MinZ = SCALE( f, 0.0f, 1.0f, 0.05f, 0.0f );
	viewData.MaxZ = SCALE( f, 0.0f, 1.0f, 1.0f, 0.95f );
	g_pd3dDevice->SetViewport( &viewData );
}
Exemplo n.º 4
0
// カメラの初期化
void Camera::Initialize()
{
	d3dDevice->GetViewport(&viewport);
	d3dDevice->SetViewport(&viewport);

	// アスペクト比の計算
	aspect = (float)viewport.Width / (float)viewport.Height;

	DebugLog("カメラを初期化しました。\n");
}
/**
* Inits a full screen vertex buffer containing 4 vertices.
***/
void OculusRenderer::InitDefaultVertexBuffer(LPDIRECT3DDEVICE9 pcDevice)
{
	// get the viewport
	D3DVIEWPORT9 sViewport;
	pcDevice->GetViewport(&sViewport);

	// create vertex buffer
	pcDevice->CreateVertexBuffer(sizeof(TEXVERTEX) * 4, NULL,
		D3DFVF_TEXVERTEX, D3DPOOL_MANAGED, &m_pcVertexBufferDefault, NULL);

	// ..and lock
	TEXVERTEX* vertices;
	m_pcVertexBufferDefault->Lock(0, 0, (void**)&vertices, NULL);

	RECT* rDest = new RECT();
	rDest->left = 0;
	rDest->right = int(sViewport.Width);
	rDest->top = 0;
	rDest->bottom = int(sViewport.Height);

	//Setup vertices
	vertices[0].x = (float) rDest->left - 0.5f;
	vertices[0].y = (float) rDest->top - 0.5f;
	vertices[0].z = 0.0f;
	vertices[0].rhw = 1.0f;
	vertices[0].u = 0.0f;
	vertices[0].v = 0.0f;

	vertices[1].x = (float) rDest->right - 0.5f;
	vertices[1].y = (float) rDest->top - 0.5f;
	vertices[1].z = 0.0f;
	vertices[1].rhw = 1.0f;
	vertices[1].u = 1.0f;
	vertices[1].v = 0.0f;

	vertices[2].x = (float) rDest->right - 0.5f;
	vertices[2].y = (float) rDest->bottom - 0.5f;
	vertices[2].z = 0.0f;
	vertices[2].rhw = 1.0f;
	vertices[2].u = 1.0f;	
	vertices[2].v = 1.0f;

	vertices[3].x = (float) rDest->left - 0.5f;
	vertices[3].y = (float) rDest->bottom - 0.5f;
	vertices[3].z = 0.0f;
	vertices[3].rhw = 1.0f;
	vertices[3].u = 0.0f;
	vertices[3].v = 1.0f;

	m_pcVertexBufferDefault->Unlock();
}
Exemplo n.º 6
0
static void myAdditions(LPDIRECT3DDEVICE9 Device_Interface)
{
	D3DXVECTOR3 imagepos;
	BOOL currentState = (BOOL)(GetAsyncKeyState(VK_INSERT) & 0x8000);

	//Switch ON and OFF
	if(!currentState && oldState) //Si la touche passe de enfoncée à relevée
		DRAW_CROSSHAIR ^= TRUE;
	oldState = currentState;

	if(DRAW_CROSSHAIR)
	{
		//Checks / Init =============================================================================================================
		if(imagetex == NULL)
		{	
			if(!SUCCEEDED(D3DXCreateTextureFromFileEx(Device_Interface, "crosshair.png", D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &imageInfo, NULL, &imagetex)))
			{
				DRAW_CROSSHAIR = FALSE;
				return;
			}
		}
		if(sprite == NULL)
		{
			if(!SUCCEEDED(D3DXCreateSprite(Device_Interface, &sprite)))
			{
				DRAW_CROSSHAIR = FALSE;
				return;
			}
		}
		//=============================================================================================================

		if(SUCCEEDED(Device_Interface->BeginScene()))
		{
			//RESOLUTION ?
			D3DVIEWPORT9 vp;
			Device_Interface->GetViewport(&vp);

			imagepos.x = (vp.Width - imageInfo.Width)/2.0f;		//coord x of our sprite
			imagepos.y = (vp.Height - imageInfo.Height)/2.0f;		//coord y of out sprite
			imagepos.z = 0.0f;	

			if(SUCCEEDED(sprite->Begin(D3DXSPRITE_ALPHABLEND)))
			{
				sprite->Draw(imagetex, NULL, NULL, &imagepos, 0xFFFFFFFF);
				sprite->End();
			}
			Device_Interface->EndScene();
		}
	}
}
Exemplo n.º 7
0
RAY CPicking::CalcPickingRay(LPDIRECT3DDEVICE9 _device, HWND _hWnd, int x, int y)
{
	RAY ray;	
	
	RECT rt;
	GetClientRect(_hWnd, &rt);

	
	float px = 0.0f;
	float py = 0.0f;
	
	//get viewport 
	D3DVIEWPORT9 vp;
	_device->GetViewport(&vp);
	
	//get projection
	D3DXMATRIX proj;
	_device->GetTransform(D3DTS_PROJECTION, &proj);

	//px = ( ((2.0f*x) / vp.Width) - 1.0f ) / proj(0,0);
	//py = ( ((-2.0f*y) / vp.Height) + 1.0f ) / proj(1,1);
	
	px = ( ((2.0f*x) / vp.Width) - 1.0f );
	py = ( ((-2.0f*y) / vp.Height) + 1.0f );
	px /= proj._11;
	py /= proj._22;

	ray.origin = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	ray.direction = D3DXVECTOR3(px, py, 1.0f);
	
	D3DXMATRIX view;
	_device->GetTransform(D3DTS_VIEW, &view);
	
	D3DXMATRIX viewInverse;
	D3DXMatrixInverse(&viewInverse, 0, &view);	

	// 광선의 원점을 변환한다 w = 1
	D3DXVec3TransformCoord(&ray.origin, &ray.origin, &viewInverse);
	// 광선의 방향을 변환한다 w = 0
	D3DXVec3TransformNormal(&ray.direction, &ray.direction, &viewInverse);
	
	// 방향을 정규화
	D3DXVec3Normalize(&ray.direction, &ray.direction);

	return ray;
}
Exemplo n.º 8
0
    HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
    {
		if(g_pTexRed == NULL) D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&red, sizeof(red), &g_pTexRed);
		if(g_pTexOrange == NULL) D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&orange, sizeof(orange), &g_pTexOrange);

		if(g_pFont == NULL) D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &g_pFont);
		if(g_pLine == NULL) D3DXCreateLine(pDevice, &g_pLine);

		pDevice->GetViewport(&g_ViewPort);

		if(g_pFont != NULL && g_pLine != NULL)
		{
			ModelRecLoggerMenu();
		
			if(g_uiTimer > GetTickCount())
			{
				DrawString(g_ViewPort.Width/2,g_ViewPort.Height/2, 0xFF00FF00, "Values Saved");
			}
		}

		return oEndScene(pDevice);
    }
Exemplo n.º 9
0
HRESULT HookIDirect3DDevice9::GetViewport(LPVOID _this,
										  D3DVIEWPORT9* pViewport)
{
	LOG_API();
	return pD3Dev->GetViewport(pViewport);
}
Exemplo n.º 10
0
HRESULT KG3DGraphicsEngine::ScreenShotImpl()
{
    HRESULT hResult  = E_FAIL;
    HRESULT hRetCode = E_FAIL;

    IDirect3DSurface9* pFrameSurface = NULL;
    IDirect3DTexture9* pTextureSys = NULL;
    ID3DXBuffer* pBuffer = NULL;
    D3DVIEWPORT9 ViewPort;
    RECT RectView;

    ASSERT(m_eShotImageType != D3DXIFF_FORCE_DWORD);

    hRetCode = g_pd3dDevice->GetRenderTarget(0, &pFrameSurface);
    KG_COM_PROCESS_ERROR(hRetCode);

    g_pd3dDevice->GetViewport(&ViewPort);
    SetRect(&RectView, ViewPort.X, ViewPort.Y, ViewPort.X + ViewPort.Width, ViewPort.Y + ViewPort.Height);

    if (m_eShotImageType == D3DXIFF_JPG)
    {
        D3DSURFACE_DESC SurfaceDesc;
        D3DLOCKED_RECT LockRect;
        
        hRetCode = D3DXSaveSurfaceToFileInMemory(&pBuffer, D3DXIFF_BMP, pFrameSurface, NULL, &RectView);
        KG_COM_PROCESS_ERROR(hRetCode);

        hRetCode = D3DXCreateTextureFromFileInMemoryEx(g_pd3dDevice, 
            pBuffer->GetBufferPointer(), 
            pBuffer->GetBufferSize(),
            ViewPort.Width,
            ViewPort.Height,
            1,
            0,
            D3DFMT_A8R8G8B8,
            D3DPOOL_SCRATCH,
            D3DX_DEFAULT,
            D3DX_DEFAULT,
            0,
            NULL,
            NULL,
            &pTextureSys);
        KG_COM_PROCESS_ERROR(hRetCode);


        /*
        hRetCode = D3DXSaveSurfaceToFile(TEXT("__temp_shot.bmp"), D3DXIFF_BMP, pFrameSurface, NULL, &RectView);
        KG_COM_PROCESS_ERROR(hRetCode);

        hRetCode = D3DXCreateTextureFromFileEx(g_pd3dDevice, 
            TEXT("__temp_shot.bmp"), 
            ViewPort.Width,
            ViewPort.Height,
            1,
            0,
            D3DFMT_A8R8G8B8,
            D3DPOOL_SCRATCH,
            D3DX_DEFAULT,
            D3DX_DEFAULT,
            0,
            NULL,
            NULL,
            &pTextureSys);
        KG_COM_PROCESS_ERROR(hRetCode); */

        pTextureSys->GetLevelDesc(0, &SurfaceDesc);

        if (SUCCEEDED(pTextureSys->LockRect(0, &LockRect, NULL, D3DLOCK_NOSYSLOCK)))
        {
            struct _Rgba { BYTE r; BYTE g; BYTE b; BYTE a;};
            struct _Rgb  { BYTE b; BYTE g; BYTE r; };
            _Rgb* pRgb = new _Rgb[SurfaceDesc.Height * SurfaceDesc.Width];

            for (UINT v = 0; v < SurfaceDesc.Height; ++v)
            {
                _Rgba* pRgba = (_Rgba*)((BYTE*)LockRect.pBits + LockRect.Pitch * v);

                for (UINT u = 0; u < SurfaceDesc.Width; ++u)
                {
                    pRgb[v * SurfaceDesc.Width + u].r = pRgba[u].r;
                    pRgb[v * SurfaceDesc.Width + u].g = pRgba[u].g;
                    pRgb[v * SurfaceDesc.Width + u].b = pRgba[u].b;
                }
            }

            JpegFile::RGBToJpegFile(m_szShotPath, (BYTE*)pRgb, SurfaceDesc.Width, SurfaceDesc.Height, TRUE, m_nShotImageQuty);

            delete[] pRgb;
            pTextureSys->UnlockRect(0);
        }
        else
        {
            KG_PROCESS_ERROR(FALSE);
        }
    }
    else
    {
        hRetCode = D3DXSaveSurfaceToFile(m_szShotPath, m_eShotImageType, pFrameSurface, NULL, &RectView);
        KG_COM_PROCESS_ERROR(hRetCode);
    }

    hResult = S_OK;
Exit0 :
    SAFE_RELEASE(pBuffer);
    SAFE_RELEASE(pTextureSys);
    SAFE_RELEASE(pFrameSurface);
    return hResult;
}
Exemplo n.º 11
0
//-------------------------------------------------------------
// 座標変換を行う
// 引数
//		pD3DDevice : IDirect3DDevice9 インターフェイスへのポインタ
//-------------------------------------------------------------
void Renderer::Transform(LPDIRECT3DDEVICE9 pD3DDevice)
{
	// デバイスのチェック
	if(pD3DDevice == 0)
	{
		return;	// デバイスへのポインタが無い
	}

	HRESULT hr = 0;

	// ビューイング行列の初期化
	//-------------------------------------------------------------
	// 何もしないマトリックス(単位行列)を生成
	// D3DXMATRIX *D3DXMatrixIdentity(D3DXMATRIX *pOut);
	// 引数
	//		pOut	: 単位行列を格納するD3DXMATRIX構造体へのポインタ
	// 戻り値
	//		単位行列である D3DXMATRIX 構造体へのポインタ
	//		この戻り値はpOutの戻り値と同じである
	//-------------------------------------------------------------
	D3DXMatrixIdentity( &m_view);
	// カメラの位置と方向を設定
	//-------------------------------------------------------------
	//D3DXMATRIX *D3DXMatrixLookAtLH(D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye,
	//								 const D3DXVECTOR3 *pAt, const D3DXVECTOR3 *pUp);
	// 引数
	//		pOut	: 演算結果のビューイング行列を格納するD3DXMATRIX構造体へのポインタ
	//		pEye	: カメラの位置
	//		pAt		: カメラの注視対象の位置
	//		pUp		: カメラの上の向き
	// 戻り値
	//		ビューイング行列であるD3DXMATRIX構造体へのポインタ
	//		この戻り値はpOutの戻り値と同じである
	//-------------------------------------------------------------
	D3DXMatrixLookAtLH( &m_view, &D3DXVECTOR3((float)CPos.x, (float)CPos.y, (float)CPos.z), 
								 &D3DXVECTOR3((float)CFocus.x, (float)CFocus.y, (float)CFocus.z), 
								 &D3DXVECTOR3(0.0f, 1.0f, 0.0f));


	/*D3DXMatrixRotationYawPitchRoll(&m_view,(FLOAT)C_Xangle,(FLOAT)C_Yangle,(FLOAT)C_Zangle);
	D3DXMatrixTranslation(&m_view_M,(FLOAT)C_x,(FLOAT)C_y,(FLOAT)C_z);
	D3DXMatrixMultiply(&m_view,&m_view,&m_view_M);*/


	// カメラの設定
	//-------------------------------------------------------------
	// レンダリングパイプラインにマトリックスを設定
	// HRESULT IDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State,
	//										  const D3DMATRIX *pMatrix);
	// 引数
	//		State	: 変更対象のデバイスステートメント変数
	//		pMatrix	: 設定するマトリックス
	// 戻り値
	//		成功したらD3D_OK
	//-------------------------------------------------------------
	pD3DDevice->SetTransform(D3DTS_VIEW, &m_view);


	D3DVIEWPORT9    vp;
	//-------------------------------------------------------------
	// ビューポートの取得
	// HRESULT IDirect3DDevice9::GetViewport(D3DVIEWPORT9 *pViewport);
	// 引数
	//		pViewport	: ビューポートの情報を格納する構造体へのポインタ
	// 戻り値
	//		成功したらD3D_OK
	//-------------------------------------------------------------
	hr = pD3DDevice->GetViewport(&vp);
	if(FAILED(hr))
	{
		return;	// 取得失敗
	}

	// アスペクト比の計算
	float aspect;
	aspect = (float)vp.Width / (float)vp.Height;

	// 射影行列の初期化
	D3DXMatrixIdentity(&m_proj);
	// カメラのパラメータの設定
	//-------------------------------------------------------------
	//D3DXMATRIX *D3DXMatrixLookAtLH(D3DXMATRIX *pOut, float fovY, 
	//								 float Aspect,float zn, float zf);
	// 引数
	//		pOut	: 演算結果の射影行列を格納するD3DXMATRIX構造体へのポインタ
	//		fovY	: カメラの画角
	//		Aspect	: アスペクト比
	//		zn		: Nearプレーン
	//		zf		: Farプレーン
	// 戻り値
	//		射影行列であるD3DXMATRIX構造体へのポインタ
	//		この戻り値はpOutの戻り値と同じである
	//-------------------------------------------------------------
	D3DXMatrixPerspectiveFovLH(&m_proj, D3DXToRadian(45.0f), aspect, 5.0f, 10000.0f);

	// 射影行列の設定
	// レンダリングパイプラインにマトリックスを設定
	pD3DDevice->SetTransform(D3DTS_PROJECTION, &m_proj);

}
Exemplo n.º 12
0
BOOL FSGetViewPort(render_viewport_t *returnViewPort)
{
	return lpD3DDevice->GetViewport( (D3DVIEWPORT9*) returnViewPort ) == D3D_OK;
}
Exemplo n.º 13
0
HRESULT KGraphicsEngine::Render2SmallerTexture()
{
	LPTEXTURE pTexBuffer  = NULL;
	LPTEXTURE pTexSmaller = NULL;
	LPTEXTURE pTexBlur    = NULL;

	if (FAILED(g_cTextureTable.GetTexture(&pTexBuffer,m_BufferTextureID)))
		return E_FAIL;
	if (FAILED(g_cTextureTable.GetTexture(&pTexSmaller,m_SmallerTextureID)))
		return E_FAIL;
	if (FAILED(g_cTextureTable.GetTexture(&pTexBlur,m_BlurTextureID)))
		return E_FAIL;
	if(!pTexBuffer->m_lpTexture)
		return E_FAIL;
	if(!pTexSmaller->m_lpTexture)
		return E_FAIL;
	if(!pTexBlur->m_lpTexture)
		return E_FAIL;
	D3DSURFACE_DESC Desc;
	if(FAILED(pTexSmaller->m_lpTexture->GetLevelDesc(0,&Desc)))
		return E_FAIL;
	D3DSURFACE_DESC DescBlur;
	if(FAILED(pTexBlur->m_lpTexture->GetLevelDesc(0,&DescBlur)))
		return E_FAIL;

	LPDIRECT3DSURFACE9 lpSurfaceSmaller = NULL;
	if(FAILED(pTexSmaller->m_lpTexture->GetSurfaceLevel(0,&lpSurfaceSmaller)))
		return E_FAIL;
	lpSurfaceSmaller->Release();
	LPDIRECT3DSURFACE9 lpSurfaceBlur = NULL;
	if(FAILED(pTexBlur->m_lpTexture->GetSurfaceLevel(0,&lpSurfaceBlur)))
		return E_FAIL;
	lpSurfaceBlur->Release();

	D3DXMATRIX Mat_View_Save;
	D3DXMATRIX Mat_Proj_Save;
	LPDIRECT3DSURFACE9 lpSurfaceSave = NULL;
	D3DVIEWPORT9 ViewPort,ViewPortBlur,ViewPortSave;
	//////////////////////////////////////////////////////////////////////////
	//Save back buffer & transform & viewport
	g_pd3dDevice->GetRenderTarget(0,&lpSurfaceSave);
	lpSurfaceSave->Release();
	g_pd3dDevice->GetTransform( D3DTS_VIEW, &Mat_View_Save );
	g_pd3dDevice->GetTransform( D3DTS_PROJECTION, &Mat_Proj_Save );
	g_pd3dDevice->GetViewport(&ViewPortSave);


	//////////////////////////////////////////////////////////////////////////

	ViewPort.X = 0;ViewPort.Y = 0;
	ViewPort.Width = Desc.Width;
	ViewPort.Height = Desc.Height;
	ViewPort.MinZ = 0;ViewPort.MaxZ = 1.0f;

	ViewPortBlur.X = 0;ViewPortBlur.Y = 0;
	ViewPortBlur.Width  = DescBlur.Width;
	ViewPortBlur.Height = DescBlur.Height;
	ViewPortBlur.MinZ = 0;ViewPortBlur.MaxZ = 1.0f;

	D3DXVECTOR2 A(0,0);
	D3DXVECTOR2 C((float)Desc.Width,(float)Desc.Height);

	D3DXVECTOR2 A1(0,0);
	D3DXVECTOR2 C1((float)DescBlur.Width,(float)DescBlur.Height);

	//////////////////////////////////////////////////////////////////////////
	g_pd3dDevice->SetViewport(&ViewPort);
	g_pd3dDevice->SetRenderTarget(0,lpSurfaceSmaller);
	//////////////////////////////////////////////////////////////////////////
	//reade began to render
	//g_pd3dDevice->BeginScene();

	g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 
		0x00000000, 1.0f, 0 );

	g_pd3dDevice->SetRenderState( D3DRS_CULLMODE,  D3DCULL_NONE );
	float K = 2;
	D3DXVECTOR2 T1( K,K);
	D3DXVECTOR2 T2(-K,K);

	g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
	g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

	DWORD Color = m_lpCurScene->m_Glow.m_GateColor;
	g_cTextureTable.SetTexture(0,m_BufferTextureID);
	g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SUBTRACT);
	g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
	g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);

	/*g_cTextureTable.SetTexture(1,m_BufferTextureID);
	g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
	g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE);
	g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT);*/

	g_cGraphicsTool.DrawScreenRectNormal(&A,&C,0.0f,Color,Color,Color,Color);

	//g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	//g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
	//g_cGraphicsTool.DrawScreenRect(&A,&C,0.0f,Color,m_SmallerTextureID);
	//g_cGraphicsTool.DrawScreenRect(&(A-T1),&(C+T1),0.0f,Color,m_SmallerTextureID);

	//g_cGraphicsTool.DrawScreenRect(&A,&C,0.0f,Color,m_BufferTextureID);
	/*g_cGraphicsTool.DrawScreenRect(&(A-T1),&(C-T1),0.0f,Color,m_BufferTextureID);
	g_cGraphicsTool.DrawScreenRect(&(A+T1),&(C+T1),0.0f,Color,m_BufferTextureID);
	g_cGraphicsTool.DrawScreenRect(&(A-T2),&(C-T2),0.0f,Color,m_BufferTextureID);
	g_cGraphicsTool.DrawScreenRect(&(A+T2),&(C+T2),0.0f,Color,m_BufferTextureID);*/

	if(1)
	{
		//////////////////////////////////////////////////////////////////////////
		Color = 0x30FFFFFF;
		for(int i=0;i<8;i++)
		{
			g_pd3dDevice->SetViewport(&ViewPortBlur);
			g_pd3dDevice->SetRenderTarget(0,lpSurfaceBlur);

			//if(i==0)
			{
				g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 
					0x00000000, 1.0f, 0 );
			}

			g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
			g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
			g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

			g_cGraphicsTool.DrawScreenRect(&A1,&C1,0.0f,0xFFFFFFFF,m_SmallerTextureID);

			g_pd3dDevice->SetViewport(&ViewPort);
			g_pd3dDevice->SetRenderTarget(0,lpSurfaceSmaller);

			g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
			g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
			g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_BLENDFACTOR);
			g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR,0x60606060);

			g_cGraphicsTool.DrawScreenRect(&(A-T1),&(C+T1),0.0f,Color,m_BlurTextureID);
		}
	}
	else
	{


		//g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR,0x60606060);

		for(int i=0;i<10;i++)
		{
			g_pd3dDevice->SetViewport(&ViewPortBlur);
			g_pd3dDevice->SetRenderTarget(0,lpSurfaceBlur);

			g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 
				0x00000000, 1.0f, 0 );

			g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
			g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
			g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

			g_cGraphicsTool.DrawScreenRect(&A1,&C1,0.0f,0xFFFFFFFF,m_SmallerTextureID);

			g_pd3dDevice->SetViewport(&ViewPort);
			g_pd3dDevice->SetRenderTarget(0,lpSurfaceSmaller);

			g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
			g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
			g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);

			Color = 0x00FFFFFF|(255-i*25)<<24;
			float K = 5;
			T1 = D3DXVECTOR2(K*i,K*i);
			T2 = D3DXVECTOR2(-K*i,K*i);

			g_cGraphicsTool.DrawScreenRect(&(A-T2),&(C-T2),0.0f,Color,m_BlurTextureID);
			/*g_cGraphicsTool.DrawScreenRect(&(A+T1),&(C+T1),0.0f,Color,m_BlurTextureID);
			g_cGraphicsTool.DrawScreenRect(&(A-T2),&(C-T2),0.0f,Color,m_BlurTextureID);
			g_cGraphicsTool.DrawScreenRect(&(A+T2),&(C+T2),0.0f,Color,m_BlurTextureID);*/
		}

		/*g_pd3dDevice->SetViewport(&ViewPortBlur);
		g_pd3dDevice->SetRenderTarget(0,lpSurfaceBlur);
		g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 
			0x00000000, 1.0f, 0 );
		g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
		g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
		g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

		g_cGraphicsTool.DrawScreenRect(&A1,&C1,0.0f,0xFFFFFFFF,m_SmallerTextureID);
		g_pd3dDevice->SetViewport(&ViewPort);
		g_pd3dDevice->SetRenderTarget(0,lpSurfaceSmaller);

		g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
		g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
		g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_BLENDFACTOR);
		g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR,0x60606060);*/
		
		Color = 0x30FFFFFF;
		g_cGraphicsTool.DrawScreenRect(&(A),&(C),0.0f,Color,m_BlurTextureID);

	}
	


	//g_pd3dDevice->EndScene();
	//////////////////////////////////////////////////////////////////////////
	//Restore
	g_pd3dDevice->SetTransform( D3DTS_VIEW, &Mat_View_Save );
	g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &Mat_Proj_Save );
	g_pd3dDevice->SetRenderTarget(0,lpSurfaceSave);
	g_pd3dDevice->SetViewport(&ViewPortSave);

	g_cTextureTable.SetTexture(1,NULL);
	g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
	g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE);
	g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT);

	return S_OK;
}