void CShaderManager::UnloadShader( HSHADER hShader )
{
	LPD3DXEFFECT fxShader = GetShader( hShader );
	if( fxShader == NULL ) return;

	fxShader->Release();
	m_vEffects[ hShader ] = NULL;
}
void Cleanup()
{
	// 폰트를 release 한다.
	if (gpFont)
	{
		gpFont->Release();
		gpFont = NULL;
	}

	// 모델을 release 한다.
	if (gpSphere)
	{
		gpSphere->Release();
		gpSphere = NULL;
	}

	// 쉐이더를 release 한다.
	if (gpNormalMappingShader)
	{
		gpNormalMappingShader->Release();
		gpNormalMappingShader = NULL;
	}

	// 텍스처를 release 한다.
	if (gpStoneDM)
	{
		gpStoneDM->Release();
		gpStoneDM = NULL;
	}

	if (gpStoneSM)
	{
		gpStoneSM->Release();
		gpStoneSM = NULL;
	}

	if (gpStoneNM)
	{
		gpStoneNM->Release();
		gpStoneNM = NULL;
	}

	// D3D를 release 한다.
	if (gpD3DDevice)
	{
		gpD3DDevice->Release();
		gpD3DDevice = NULL;
	}

	if (gpD3D)
	{
		gpD3D->Release();
		gpD3D = NULL;
	}
}
示例#3
0
	void Destroy()
	{
		itLst	_F = mpEft.begin();
		itLst	_L = mpEft.end();

		for(; _F != _L; ++_F)
		{
			LPD3DXEFFECT pEft = _F->second;
			pEft->Release();
		}

		mpEft.clear();
	}
示例#4
0
void Cleanup()
{
	// 폰트를 release 한다.
	if(gpFont)
	{
		gpFont->Release();
		gpFont = NULL;
	}

	// 모델을 release 한다.
	if (gpSphere) {
		gpSphere->Release();
		gpSphere = NULL;
	}

	// 쉐이더를 release 한다.
	if (gpTextureMappingShader) {
		gpTextureMappingShader->Release();
		gpTextureMappingShader = NULL;
	}

	// 텍스처를 release 한다.
	if (gpEarthDM) {
		gpEarthDM->Release();
		gpEarthDM = NULL;
	}

	// D3D를 release 한다.
    if(gpD3DDevice)
	{
        gpD3DDevice->Release();
		gpD3DDevice = NULL;
	}

    if(gpD3D)
	{
        gpD3D->Release();
		gpD3D = NULL;
	}
}
示例#5
0
//The user-provided entry point for a graphical Windows-based application.
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine, int nShowCmd)
{
	// Fill out the WNDCLASS structure
	WNDCLASS wc;
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc = windowMessageCallback;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = ::GetModuleHandle(NULL);
	wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
	wc.hCursor = ::LoadCursor(0, IDC_ARROW);
	wc.hbrBackground = static_cast<HBRUSH>(::GetStockObject(BLACK_BRUSH));
	wc.lpszMenuName = 0;
	wc.lpszClassName = gClassName;

	// Register the WNDCLASS description 
	if (!::RegisterClass(&wc))
	{
		return false;
	}

	// Create the window
	HWND hwnd = ::CreateWindow(gClassName, TEXT("client"),
		WS_OVERLAPPEDWINDOW,
		0, 0, 512, 512,
		GetDesktopWindow(), 0, ::GetModuleHandle(0), 0);
	if (hwnd ==0)
	{
		return 0;
	}

	// Show the window
	::ShowWindow(hwnd, SW_NORMAL);
	// Update the window
	::UpdateWindow(hwnd);

	//
	IDirect3D9* d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
	if (NULL == d3d9)
	{
		return 0;
	}
	D3DPRESENT_PARAMETERS pp;
	memset(&pp, 0, sizeof(D3DPRESENT_PARAMETERS ));
	pp.BackBufferWidth = 0;
	pp.BackBufferHeight = 0;
	pp.BackBufferFormat = D3DFMT_UNKNOWN;
	pp.BackBufferCount = 1;
	pp.MultiSampleType = D3DMULTISAMPLE_NONE;
	pp.MultiSampleQuality = 0;
	pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	pp.hDeviceWindow = hwnd;
	pp.Windowed = TRUE;
	pp.EnableAutoDepthStencil = TRUE;
	pp.AutoDepthStencilFormat = D3DFMT_D24S8;
	pp.Flags = 0;
	pp.FullScreen_RefreshRateInHz = 0;
	pp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
	d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &gDevice);
	if (gDevice == NULL)
	{
		return 0;
	}
	D3DXCreateEffectFromFile(gDevice, TEXT("e:/ZenBin/data/shader/Position.fx"), NULL, NULL, D3DXSHADER_DEBUG, NULL, &gEffect, NULL);	
	//
	D3DXCreateTextureFromFileEx(gDevice, TEXT("e:/ZenBin/data/image/AID_hportal.bmp"), D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &gTexture);
	// Message Structure
	MSG msg;
	::ZeroMemory(&msg, sizeof(msg));
	// Loop until getting a WM_QUIT message
	while(true)
	{
		if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
			{
				break;
			}
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		else
		{
			gDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x000020, 1, 0);
			gDevice->BeginScene();
			gDevice->SetFVF(gVertexFVF);
			sVertex v[4];
			size_t intdex = 0;
			v[intdex].x = -0.5f;
			v[intdex].y = 0.5f;
			v[intdex].z = 0.0f;
			v[intdex].diffuse = D3DCOLOR_RGBA(0, 100, 0, 0);
			v[intdex].u = 0;
			v[intdex].v = 0;

			intdex = 1;
			v[intdex].x = 0.5f;
			v[intdex].y = 0.5f;
			v[intdex].z = 0.0f;
			v[intdex].diffuse = D3DCOLOR_RGBA(0, 100, 0, 0);
			v[intdex].u = 1;
			v[intdex].v = 0;

			intdex = 2;
			v[intdex].x = -0.5f;
			v[intdex].y = -0.5f;
			v[intdex].z = 0.0f;
			v[intdex].diffuse = D3DCOLOR_RGBA(0, 100, 0, 0);
			v[intdex].u = 0;
			v[intdex].v = 1;

			intdex = 3;
			v[intdex].x = 0.5f;
			v[intdex].y = -0.5f;
			v[intdex].z = 0.0f;
			v[intdex].diffuse = D3DCOLOR_RGBA(0, 100, 0, 0);
			v[intdex].u = 1;
			v[intdex].v = 1;
			gEffect->SetTexture("lay0", gTexture);
			UINT pPasses = 0;
			gEffect->SetTechnique("PP0");
			gEffect->Begin(&pPasses, D3DXFX_DONOTSAVESTATE);
			for (int i = 0; i != pPasses; ++i)
			{
				gEffect->BeginPass(i);
				gDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(sVertex));
				gEffect->EndPass();
			}
			gEffect->End();
			gDevice->EndScene();
			gDevice->Present(NULL, NULL, 0, NULL);		
		}
	}
	//
	if (gTexture)
	{
		gTexture->Release();
		gTexture = NULL;
	}
	//
	if (gEffect)
	{
		gEffect->Release();
		gEffect = NULL;
	}
	//
	if (gDevice)
	{
		gDevice->Release();
		gDevice = NULL;
	}
	//
	d3d9->Release();
	d3d9 = NULL;
	return 0;
}
void Cleanup()
{
	// 폰트를 release 한다.
	if (gpFont)
	{
		gpFont->Release();
		gpFont = NULL;
	}

	// 모델을 release 한다.
	if (gpTeapot)
	{
		gpTeapot->Release();
		gpTeapot = NULL;
	}

	// 쉐이더를 release 한다.
	if (gpEnvironmentMappingShader)
	{
		gpEnvironmentMappingShader->Release();
		gpEnvironmentMappingShader = NULL;
	}

	// 텍스처를 release 한다.
	if (gpStoneDM)
	{
		gpStoneDM->Release();
		gpStoneDM = NULL;
	}

	if (gpStoneSM)
	{
		gpStoneSM->Release();
		gpStoneSM = NULL;
	}

	if (gpStoneNM)
	{
		gpStoneNM->Release();
		gpStoneNM = NULL;
	}

	if (gpSnowENV)
	{
		gpSnowENV->Release();
		gpSnowENV = NULL;
	}

	// D3D를 release 한다.
	if (gpD3DDevice)
	{
		gpD3DDevice->Release();
		gpD3DDevice = NULL;
	}

	if (gpD3D)
	{
		gpD3D->Release();
		gpD3D = NULL;
	}
}
示例#7
0
//The user-provided entry point for a graphical Windows-based application.
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine, int nShowCmd)
{
	// Fill out the WNDCLASS structure
	WNDCLASS wc;
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc = windowMessageCallback;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = ::GetModuleHandle(NULL);
	wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
	wc.hCursor = ::LoadCursor(0, IDC_ARROW);
	wc.hbrBackground = static_cast<HBRUSH>(::GetStockObject(BLACK_BRUSH));
	wc.lpszMenuName = 0;
	wc.lpszClassName = gClassName;

	// Register the WNDCLASS description 
	if (!::RegisterClass(&wc))
	{
		return false;
	}

	// Create the window
	HWND hwnd = ::CreateWindow(gClassName, TEXT("client"),
		WS_OVERLAPPEDWINDOW,
		0, 0, 512, 512,
		GetDesktopWindow(), 0, ::GetModuleHandle(0), 0);
	if (hwnd ==0)
	{
		return 0;
	}

	// Show the window
	::ShowWindow(hwnd, SW_NORMAL);
	// Update the window
	::UpdateWindow(hwnd);

	//
	IDirect3D9* d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
	if (NULL == d3d9)
	{
		return 0;
	}
	D3DPRESENT_PARAMETERS pp;
	memset(&pp, 0, sizeof(D3DPRESENT_PARAMETERS ));
	pp.BackBufferWidth = 0;
	pp.BackBufferHeight = 0;
	pp.BackBufferFormat = D3DFMT_UNKNOWN;
	pp.BackBufferCount = 1;
	pp.MultiSampleType = D3DMULTISAMPLE_NONE;
	pp.MultiSampleQuality = 0;
	pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	pp.hDeviceWindow = hwnd;
	pp.Windowed = TRUE;
	pp.EnableAutoDepthStencil = TRUE;
	pp.AutoDepthStencilFormat = D3DFMT_D24S8;
	pp.Flags = 0;
	pp.FullScreen_RefreshRateInHz = 0;
	pp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
	d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &gDevice);
	if (gDevice == NULL)
	{
		return 0;
	}
	D3DXCreateEffectFromFile(gDevice, TEXT("e:/ZenBin/data/shader/Position.fx"), NULL, NULL, D3DXSHADER_DEBUG, NULL, &gEffect, NULL);	
	//
	D3DXCreateTextureFromFileEx(gDevice, TEXT("e:/ZenBin/data/image/AID_hportal.bmp"), D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &gTexture);
	int verticesNum = pow((double)2, (double)gMaxLOD) + 1;
	//
	gDevice->CreateVertexBuffer(verticesNum*verticesNum*sizeof(sVertex), 0, gVertexFVF, D3DPOOL_MANAGED, &gVB, 0);
	//
	gDevice->CreateIndexBuffer((verticesNum - 1)*(verticesNum - 1)*2*3*2, 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &gIB, 0);
	//
	std::vector<sVertex> vertices;
	for (size_t z = 0; z != verticesNum; z++)
	for (size_t x = 0; x != verticesNum; x++)
	{
		sVertex v;
		v.x = x*3;
		v.z = z*3;
		v.y = 0;
		//v.u = v.x*0.01f;
		//v.v = v.y*0.01f;
		vertices.push_back(v);
	}
	{
		void* data;
		gVB->Lock(0, 0, &data, 0);
		memcpy(data, &vertices[0], vertices.size()*sizeof(sVertex));
		gVB->Unlock();
	}
	generateLOD(0);
	// Message Structure
	MSG msg;
	::ZeroMemory(&msg, sizeof(msg));
	// Loop until getting a WM_QUIT message
	while(true)
	{
		if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
			{
				break;
			}
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		else
		{
			gDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x000020, 1, 0);
			gDevice->BeginScene();
			gDevice->SetFVF(gVertexFVF);
			gDevice->SetStreamSource(0, gVB, 0, sizeof(sVertex));
			gDevice->SetIndices(gIB);
			gEffect->SetTexture("lay0", gTexture);
			UINT pPasses = 0;
			gEffect->SetTechnique("PP0");
			gViewMatrix.column(0, Vector4(1, 0, 0, 0));
			gViewMatrix.column(1, Vector4(0, 0, 1, 0));
			gViewMatrix.column(2, Vector4(0, -1, 0, 150));
			gViewMatrix.column(3, Vector4(0, 0, 0, 1));
			gEffect->SetMatrix("gView", &gViewMatrix);
			D3DXMatrixPerspectiveFovLH(&gProjectionMatrix, 1.5, 1, 0.01, 1000);
			gEffect->SetMatrix("gProjection", &gProjectionMatrix);
			gEffect->Begin(&pPasses, D3DXFX_DONOTSAVESTATE);
			for (int i = 0; i != pPasses; ++i)
			{
				gEffect->BeginPass(i);
				gDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, gMaxLOD*gMaxLOD, 0, gIndices.size()/3);
				gEffect->EndPass();
			}
			gEffect->End();
			gDevice->EndScene();
			gDevice->Present(NULL, NULL, 0, NULL);		
		}
	}
	//
	if (gIB)
	{
		gIB->Release();
		gIB = NULL;
	}
	//
	if (gVB)
	{
		gVB->Release();
		gVB = NULL;
	}
	//
	if (gTexture)
	{
		gTexture->Release();
		gTexture = NULL;
	}
	//
	if (gEffect)
	{
		gEffect->Release();
		gEffect = NULL;
	}
	//
	if (gDevice)
	{
		gDevice->Release();
		gDevice = NULL;
	}
	//
	d3d9->Release();
	d3d9 = NULL;
	return 0;
}
示例#8
0
void Cleanup()
{
	// release fonts
	if (gpFont)
	{
		gpFont->Release();
		gpFont = NULL;
	}

	// release models
	if (gpTeapot)
	{
		gpTeapot->Release();
		gpTeapot = NULL;
	}

	// release shaders
	if (gpEnvironmentMappingShader)
	{
		gpEnvironmentMappingShader->Release();
		gpEnvironmentMappingShader = NULL;
	}

	if (gpNoEffect)
	{
		gpNoEffect->Release();
		gpNoEffect = NULL;
	}

	if (gpGrayScale)
	{
		gpGrayScale->Release();
		gpGrayScale = NULL;
	}

	if (gpSepia)
	{
		gpSepia->Release();
		gpSepia = NULL;
	}

	// release textures
	if (gpStoneDM)
	{
		gpStoneDM->Release();
		gpStoneDM = NULL;
	}

	if (gpStoneSM)
	{
		gpStoneSM->Release();
		gpStoneSM = NULL;
	}

	if (gpStoneNM)
	{
		gpStoneNM->Release();
		gpStoneNM = NULL;
	}

	if (gpSnowENV)
	{
		gpSnowENV->Release();
		gpSnowENV = NULL;
	}

	// Release the fullscreen quad
	if (gpFullscreenQuadDecl)
	{
		gpFullscreenQuadDecl->Release();
		gpFullscreenQuadDecl = NULL;
	}

	if (gpFullscreenQuadVB)
	{
		gpFullscreenQuadVB->Release();
		gpFullscreenQuadVB = NULL;
	}

	if (gpFullscreenQuadIB)
	{
		gpFullscreenQuadIB->Release();
		gpFullscreenQuadIB = NULL;
	}

	// release the render target
	if (gpSceneRenderTarget)
	{
		gpSceneRenderTarget->Release();
		gpSceneRenderTarget = NULL;
	}

	// release D3D
	if (gpD3DDevice)
	{
		gpD3DDevice->Release();
		gpD3DDevice = NULL;
	}

	if (gpD3D)
	{
		gpD3D->Release();
		gpD3D = NULL;
	}
}