示例#1
0
bool MAIN_APP::Run()
{
	Time.Signal();

	Renderer::Render(Time.Delta());
	return true;
}
示例#2
0
文件: XFile.cpp 项目: hgl888/nashtest
XBOOL XFileFinder::GetFileTime(XPCTSTR strFile, XTime &time, XU8 ts)
{
    if(!FindFirst(strFile)) return XFALSE;
	switch(ts)
	{
	default:
	case XTM_CREATE:
		 time.SetTime(ftCreationTime);break;
	case XTM_ACCESS:
		 time.SetTime(ftLastAccessTime);break;
	case XTM_MODIFY:
		 time.SetTime(ftLastWriteTime);break;
	}
	return XTRUE;
}
示例#3
0
void XCatch::ResetTime()
{
	XU8 s=XFile::XBINARY|XFile::XREAD|XFile::XWRITE;

	if(!m_file.Open(m_strFile,s)) return;
	XCHeader hd;
	m_file.Read(&hd,sizeof(hd));
	XTime time;
	time.SetCurrentTime();
	hd.nTime=time.GetTime();
	m_file.Seek(0,XFile::XSEEK_SET);
	m_file.Write(&hd,sizeof(hd));

	m_file.Close();
}
示例#4
0
XU8 XClient::Connect(CONNECTREQ &data,XU8 nCharset,XU8 bSync)
{
	if(m_hConnect.IsEvent(0))
		return 0;//XFALSE;

	XU8 nApp = GetAppProto();
	m_nProtoType = nApp;
	if(m_pInfo->nProtocol != XPROTO_UDP && m_pConnect!=XNULL )
	{
		m_pConnect->DisConnect();
	}
	m_con.Reset(XFALSE);
	if(data.data.GetSize())
	{
		XU8Array&out=m_con.outData;
		out.Append(data.data);
		if(data.strContentType.IsEmpty())
		{
			XContentType type(XCNT::CAPPLICATION,XCNT::TX_WWW_FORM_URLENCODED);
			m_con.strContentType=type.GetTypeString();//strCntTypeURL;
		}
		else
		{
			m_con.strContentType=data.strContentType;
		}
	}
	m_con.URL=data.URL;
	m_con.strRefer=data.strRefer;
	m_con.nMethod=data.nMethod;
	m_con.strHeaders.Append(data.strHeaders);

	//m_res.Reset(nCharset);
	//{//for DEBUG
	//	CONNECTINFO*pCon=GetConnectInfo();
	//	RESPONSEINFO*pInfo=GetResponseInfo();
	//	if(strcmp(m_con.URL.m_strURL,"C:/game.dat") == 0)
     //       int a = 0;//pInfo->strFilterURL="D:\\WorkAS3\\debug.flt";
	//}
	XTime time;
	XU32 l=0;
	XBOOL bFilter=XFALSE;
	if(!IsNeedCache()) bFilter=true;
	bool bStatic=false;
	XU8 nType = bFilter?XCatch::XC_NONE:m_catch.CatchDetect(m_con,time,l,data.bForward,bStatic);
	if(m_con.nMethod!=XEM::GET)
		bStatic=false;
	if(nType==XCatch::XC_OK)
	{
		if(bSync&&l<RECBUFFER&&m_catch.GetCatchData())
		{
			return DATAOK;
		} 
		else if(m_pConnect!=&m_catch)
		{
			XTime nowTime;
			nowTime.SetCurrentTime();
			if(!bStatic||nowTime.GetDay()-time.GetDay()>4)
			{
				XString8 strTime;
				time.GetTime(strTime);
				XEH h;
				XSortString8::ESetValue(m_con.strHeaders,h[XEH::IF_MODIFIED_SINCE],strTime);
			}
			else
			{
				m_pConnectOld=m_pConnect;
				m_pConnect=&m_catch;
				nApp=GetAppProto();
			}
		}
	}
	m_res.Reset(nCharset);
	XU8 nNew=GetAppProto();
	m_nProtoType=nNew;
	if(nApp!=nNew||m_pConnect==XNULL)//||bNewPort)
	{
		if(m_pConnect!=XNULL&&m_pConnect!=&m_catch) 
			delete m_pConnect;
		m_pConnect=XNULL;
		switch(nNew)
		{
		case XAPP_HTTP:
			//sjj
#ifdef _USERSSL_
			m_pConnect=new XConnectHttp(this, XFALSE);
            break;
        case XAPP_HTTPS:
            m_pConnect=new XConnectHttp(this, XTRUE);
#else
			m_pConnect=new XConnectHttp(this);
#endif
            break;
                
		case XAPP_FILE:
			m_pConnect=new XConnectFile(this);
			break;
		case XAPP_RES:
			m_pConnect=new XConnectRes(this);
			break;
		case XAPP_SOCKET:
			m_pConnect=new XConnectTCP(this);
			break;
		}
	}

	if(m_pConnect!=XNULL)
		m_pConnect->SetStatus(XPROC_BEGIN);
	m_hPosted.ResetEvent();
	m_hCancel.ResetEvent();
	m_hConnect.SetEvent();

	return 1;
}
示例#5
0
bool DEMO_APP::Run()
{
	theTime.Signal();

	float dt = (float)theTime.Delta();

	devContext->OMSetRenderTargets(1, &anotherView, DepthStencilView);
	devContext->RSSetViewports(1, &viewPort);

	float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
	devContext->ClearRenderTargetView(anotherView, ClearColor);
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);

	scene[0] = Inverse4x4(secondCamera);

	D3D11_MAPPED_SUBRESOURCE sceneMap;
	ZeroMemory(&sceneMap, sizeof(sceneMap));
	devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap);
	memcpy(sceneMap.pData, scene, sizeof(scene));
	devContext->Unmap(sceneMatrixBuffer, 0);

	devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer);
	devContext->PSSetConstantBuffers(0, 1, &lightBuff);
	devContext->PSSetConstantBuffers(1, 1, &ambientBuff);
	devContext->PSSetConstantBuffers(2, 1, &ptltBuff);
	devContext->PSSetConstantBuffers(3, 1, &spotBuff);

	devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer);

	//Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0];
	//Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1];
	//Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2];
	//Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3];

	//SKYBOX RENDERING/////
	devContext->RSSetState(pOtherState);
	//SkyBox.worldMatrix = viewMatrix;

	SkyBox.worldMatrix.M[3][0] = secondCamera.M[3][0];
	SkyBox.worldMatrix.M[3][1] = secondCamera.M[3][1];
	SkyBox.worldMatrix.M[3][2] = secondCamera.M[3][2];

	SkyBox.Render();
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	///////////////////////

	devContext->RSSetState(pRasterState);

	Pyramid.Render();
	Quad.Render();
	Tree.Render();
	Tree2.Render();
	Tree1.Render();

	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	QuadSeed.Render();
	devContext->GenerateMips(QuadSeed.pShaderResource);

	/////////////////////////////////////////////////////////////////////////////////////////////////////////
	devContext->OMSetRenderTargets(1, &postProcessView, DepthStencilView);
	devContext->RSSetViewports(1, &viewPort);

	//float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
	devContext->ClearRenderTargetView(postProcessView, ClearColor);
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);

	scene[0] = Inverse4x4(viewMatrix);

	//D3D11_MAPPED_SUBRESOURCE sceneMap;
	ZeroMemory(&sceneMap, sizeof(sceneMap));
	devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap);
	memcpy(sceneMap.pData, scene, sizeof(scene));
	devContext->Unmap(sceneMatrixBuffer, 0);

	devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer);
	devContext->PSSetConstantBuffers(0, 1, &lightBuff);
	devContext->PSSetConstantBuffers(1, 1, &ambientBuff);
	devContext->PSSetConstantBuffers(2, 1, &ptltBuff);
	devContext->PSSetConstantBuffers(3, 1, &spotBuff);

	devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer);

	//Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0];
	//Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1];
	//Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2];
	//Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3];

	//SKYBOX RENDERING/////
	devContext->RSSetState(pOtherState);
	//SkyBox.worldMatrix = viewMatrix;

	SkyBox.worldMatrix.M[3][0] = viewMatrix.M[3][0];
	SkyBox.worldMatrix.M[3][1] = viewMatrix.M[3][1];
	SkyBox.worldMatrix.M[3][2] = viewMatrix.M[3][2];

	SkyBox.Render();
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	///////////////////////

	devContext->RSSetState(pRasterState);

	Pyramid.Render();
	Quad.Render();
	Tree.Render();
	Tree1.Render();
	Tree2.Render();

	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	QuadSeed.Render();
	devContext->GenerateMips(QuadSeed.pShaderResource);

	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), postTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	PostQuad.Render();

	/////////////////////////////////////////////////////////////////
	devContext->OMSetRenderTargets(1, &targetView, DepthStencilView);

	//devContext->RSSetViewports(1, &viewPort);

	//float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
	devContext->ClearRenderTargetView(targetView, ClearColor);
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);

	MoveCamera(5.0f, 200.0f, dt);


	D3D11_MAPPED_SUBRESOURCE ambMap;
	ZeroMemory(&ambMap, sizeof(ambMap));
	devContext->Map(ambientBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ambMap);
	memcpy(ambMap.pData, &ambientLight, sizeof(ambientLight));
	devContext->Unmap(ambientBuff, 0);

	D3D11_MAPPED_SUBRESOURCE lightMap;
	ZeroMemory(&lightMap, sizeof(lightMap));
	devContext->Map(lightBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &lightMap);
	memcpy(lightMap.pData, &theLight, sizeof(theLight));
	devContext->Unmap(lightBuff, 0);

	D3D11_MAPPED_SUBRESOURCE ptLtMap;
	ZeroMemory(&ptLtMap, sizeof(ptLtMap));
	devContext->Map(ptltBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ptLtMap);
	memcpy(ptLtMap.pData, &thePtLight, sizeof(thePtLight));
	devContext->Unmap(ptltBuff, 0);

	D3D11_MAPPED_SUBRESOURCE spotMap;
	ZeroMemory(&spotMap, sizeof(spotMap));
	devContext->Map(spotBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &spotMap);
	memcpy(spotMap.pData, &theSpotLight, sizeof(theSpotLight));
	devContext->Unmap(spotBuff, 0);

	scene[0] = Inverse4x4(viewMatrix);
	SkyBox.worldMatrix.M[3][0] = viewMatrix.M[3][0];
	SkyBox.worldMatrix.M[3][1] = viewMatrix.M[3][1];
	SkyBox.worldMatrix.M[3][2] = viewMatrix.M[3][2];

	//D3D11_MAPPED_SUBRESOURCE sceneMap;
	ZeroMemory(&sceneMap, sizeof(sceneMap));
	devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap);
	memcpy(sceneMap.pData, scene, sizeof(scene));
	devContext->Unmap(sceneMatrixBuffer, 0);

	devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer);
	devContext->PSSetConstantBuffers(0, 1, &lightBuff);
	devContext->PSSetConstantBuffers(1, 1, &ambientBuff);
	devContext->PSSetConstantBuffers(2, 1, &ptltBuff);
	devContext->PSSetConstantBuffers(3, 1, &spotBuff);

	devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer);

	//Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0];
	//Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1];
	//Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2];
	//Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3];

	//SKYBOX RENDERING/////
	devContext->RSSetState(pOtherState);
	//SkyBox.worldMatrix = viewMatrix;

	SkyBox.Render();
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	///////////////////////

	devContext->RSSetState(pRasterState);

	Pyramid.Render();
	Quad.Render();
	Tree.Render();
	Tree1.Render();
	Tree2.Render();

	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	QuadSeed.Render();
	devContext->GenerateMips(QuadSeed.pShaderResource);

	//WHY BROKEN?
	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), postTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	PostQuad.Render();


	/////////////////////2nd VIEWPORT/////////////////////////////////////////////////////////////////////////////////////////////////
	devContext->OMSetRenderTargets(1, &anotherView, DepthStencilView);
	devContext->RSSetViewports(1, &otherPort);

	//float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
	devContext->ClearRenderTargetView(anotherView, ClearColor);
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);

	scene[0] = secondCamera;

	//D3D11_MAPPED_SUBRESOURCE sceneMap;
	ZeroMemory(&sceneMap, sizeof(sceneMap));
	devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap);
	memcpy(sceneMap.pData, scene, sizeof(scene));
	devContext->Unmap(sceneMatrixBuffer, 0);

	devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer);
	devContext->PSSetConstantBuffers(0, 1, &lightBuff);
	devContext->PSSetConstantBuffers(1, 1, &ambientBuff);
	devContext->PSSetConstantBuffers(2, 1, &ptltBuff);
	devContext->PSSetConstantBuffers(3, 1, &spotBuff);

	devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer);

	//Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0];
	//Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1];
	//Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2];
	//Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3];

	//SKYBOX RENDERING/////
	devContext->RSSetState(pOtherState);
	//SkyBox.worldMatrix = viewMatrix;

	SkyBox.worldMatrix.M[3][0] = secondCamera.M[3][0];
	SkyBox.worldMatrix.M[3][1] = secondCamera.M[3][1];
	SkyBox.worldMatrix.M[3][2] = secondCamera.M[3][2];

	SkyBox.Render();
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	///////////////////////

	devContext->RSSetState(pRasterState);

	Pyramid.Render();
	Quad.Render();
	Tree.Render();
	Tree1.Render();
	Tree2.Render();

	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	QuadSeed.Render();
	devContext->GenerateMips(QuadSeed.pShaderResource);
	//PostQuad.Render();

	/////////////////////////////////////////////////////////////////
	devContext->OMSetRenderTargets(1, &targetView, DepthStencilView);

	//devContext->RSSetViewports(1, &viewPort);

	//float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
	//devContext->ClearRenderTargetView(targetView, ClearColor);
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);

	//MoveCamera(5.0f, 200.0f, dt);


	//D3D11_MAPPED_SUBRESOURCE ambMap;
	ZeroMemory(&ambMap, sizeof(ambMap));
	devContext->Map(ambientBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ambMap);
	memcpy(ambMap.pData, &ambientLight, sizeof(ambientLight));
	devContext->Unmap(ambientBuff, 0);

	//D3D11_MAPPED_SUBRESOURCE lightMap;
	ZeroMemory(&lightMap, sizeof(lightMap));
	devContext->Map(lightBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &lightMap);
	memcpy(lightMap.pData, &theLight, sizeof(theLight));
	devContext->Unmap(lightBuff, 0);

	//D3D11_MAPPED_SUBRESOURCE ptLtMap;
	ZeroMemory(&ptLtMap, sizeof(ptLtMap));
	devContext->Map(ptltBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ptLtMap);
	memcpy(ptLtMap.pData, &thePtLight, sizeof(thePtLight));
	devContext->Unmap(ptltBuff, 0);

	//D3D11_MAPPED_SUBRESOURCE spotMap;
	ZeroMemory(&spotMap, sizeof(spotMap));
	devContext->Map(spotBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &spotMap);
	memcpy(spotMap.pData, &theSpotLight, sizeof(theSpotLight));
	devContext->Unmap(spotBuff, 0);

	scene[0] = secondCamera;//Inverse4x4(viewMatrix);

	//D3D11_MAPPED_SUBRESOURCE sceneMap;
	ZeroMemory(&sceneMap, sizeof(sceneMap));
	devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap);
	memcpy(sceneMap.pData, scene, sizeof(scene));
	devContext->Unmap(sceneMatrixBuffer, 0);

	devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer);
	devContext->PSSetConstantBuffers(0, 1, &lightBuff);
	devContext->PSSetConstantBuffers(1, 1, &ambientBuff);
	devContext->PSSetConstantBuffers(2, 1, &ptltBuff);
	devContext->PSSetConstantBuffers(3, 1, &spotBuff);

	devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer);

	Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0];
	Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1];
	Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2];
	Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3];

	//SKYBOX RENDERING/////
	devContext->RSSetState(pOtherState);
	//SkyBox.worldMatrix = viewMatrix;

	SkyBox.worldMatrix.M[3][0] = secondCamera.M[3][0];
	SkyBox.worldMatrix.M[3][1] = secondCamera.M[3][1];
	SkyBox.worldMatrix.M[3][2] = secondCamera.M[3][2];

	SkyBox.Render();
	devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	///////////////////////

	devContext->RSSetState(pRasterState);

	Pyramid.Render();
	Quad.Render();
	Tree.Render();
	Tree1.Render();
	Tree2.Render();

	devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
	QuadSeed.Render();
	devContext->GenerateMips(QuadSeed.pShaderResource);

	swapChain->Present(0, 0);

	return true;
}