Esempio n. 1
0
void shutdownChannel(
  SOCKET aSocket,
  bool afSendNotification)
{
  DWORD dwShutdownToken = SCHANNEL_SHUTDOWN;
  SecBufferDesc shutDownBufferDesc;
  SecBuffer shutDownBuffers[1];
  shutDownBufferDesc.cBuffers = 1;
  shutDownBufferDesc.pBuffers = shutDownBuffers;
  shutDownBufferDesc.ulVersion = SECBUFFER_VERSION;
  shutDownBuffers[0].pvBuffer = &dwShutdownToken;
  shutDownBuffers[0].BufferType = SECBUFFER_TOKEN;
  shutDownBuffers[0].cbBuffer = sizeof(dwShutdownToken);

  ::ApplyControlToken(&g_hContext, &shutDownBufferDesc);

  std::vector<BYTE> vBuff(c_dwMaxMessage, 0);
  shutDownBuffers[0].BufferType = SECBUFFER_TOKEN;
  shutDownBuffers[0].pvBuffer = &vBuff[0];
  shutDownBuffers[0].cbBuffer = c_dwMaxMessage;

  ULONG ulContextAttr = 0;
  TimeStamp tsLifetime;
  SECURITY_STATUS ssResult = ::InitializeSecurityContext(
    &g_hCred, 
    &g_hContext, 
    NULL,
    0,//ISC_REQ_ALLOCATE_MEMORY, // mb another flags
    0, 
    0, 
    NULL, 
    0, 
    NULL,
    &shutDownBufferDesc, 
    &ulContextAttr, 
    &tsLifetime);
  if(ssResult < 0)
  {
    std::cout << std::hex 
      << "error in ::InitializeSecurityContext = " << ssResult << '\n';
    return;
  }

  if(afSendNotification)
  {
    bool fResult = SendMsg(
      aSocket,
      static_cast<BYTE*>(shutDownBuffers[0].pvBuffer),
      shutDownBuffers[0].cbBuffer);
    if(!fResult)
    {
      std::cout << "cannot send shutdown message\n";
    }
  }
}
		void RocketDocument3D::RecalculateBatch(RocketBatchInfo& batchInfo)
		{
			Urho3D::SharedPtr<VertexBuffer> vBuff(new VertexBuffer(context_));
			if (batchInfo.texture)
			{
				vBuff->SetSize(batchInfo.vertices.Size(), MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1, true);
			}
			else
			{
				vBuff->SetSize(batchInfo.vertices.Size(), MASK_POSITION | MASK_COLOR, true);
			}

			Vector2 invScreenSize(1.0f / _rocketContext->GetDimensions().x, 1.0f / _rocketContext->GetDimensions().y);
			float* dest = (float*)vBuff->Lock(0, batchInfo.vertices.Size(), true);
			for (Urho3D::Vector<RocketVertexInfo>::Iterator itr = batchInfo.vertices.Begin(); itr != batchInfo.vertices.End(); ++itr)
			{
				*dest++ = ((*itr).position.x_ + batchInfo.position.x_ - (_rocketContext->GetDimensions().x / 2.f)) / 2.f;
				*dest++ = ((*itr).position.y_ + batchInfo.position.y_ - (_rocketContext->GetDimensions().y / 2.f)) / -2.f;
				*dest++ = batchInfo.position.z_;

				*((unsigned*)dest) = (*itr).color.ToUInt(); dest++;

				if (batchInfo.texture) {
					*dest++ = (*itr).textureCoordinates.x_;
					*dest++ = (*itr).textureCoordinates.y_;
				}
			}
			vBuff->Unlock();

			Urho3D::SharedPtr<IndexBuffer> iBuff(new IndexBuffer(context_));
			iBuff->SetSize(batchInfo.indicies.Size() * 3, true);

			// indices
			unsigned* indices_stream = (unsigned*)iBuff->Lock(0, batchInfo.indicies.Size() * 3, true);
			for (Urho3D::Vector<Urho3D::Vector3>::Iterator itr = batchInfo.indicies.Begin(); itr != batchInfo.indicies.End(); ++itr)
			{
				*indices_stream++ = (unsigned int)(*itr).x_;
				*indices_stream++ = (unsigned int)(*itr).y_;
				*indices_stream++ = (unsigned int)(*itr).z_;
			}

			iBuff->Unlock();

			if (!batchInfo.batch)
			{
				batchInfo.batch = new Urho3D::SourceBatch();
				batchInfo.batch->geometry_ = new Geometry(context_);
				batchInfo.batch->geometryType_ = GEOM_STATIC;
			}

			if (batchInfo.texture)
			{
				Urho3D::XMLFile* file = GetSubsystem<Urho3D::ResourceCache>()->GetResource<Urho3D::XMLFile>("Materials/RocketDocument.xml");
				batchInfo.batch->material_ = new Urho3D::Material(context_);
				batchInfo.batch->material_->Load(file->GetRoot());
				
				batchInfo.batch->material_->SetTexture(TU_DIFFUSE, batchInfo.texture);
				
			}
			else
			{
				batchInfo.batch->material_ = GetSubsystem<Urho3D::ResourceCache>()->GetResource<Urho3D::Material>("Materials/RocketDocumentNoTexture.xml");
				
			}

			batchInfo.batch->material_->SetCullMode(CULL_NONE);

			batchInfo.batch->geometry_->SetVertexBuffer(0, vBuff);
			batchInfo.batch->geometry_->SetIndexBuffer(iBuff);

			//Draw indexed geometry
			batchInfo.batch->geometry_->SetDrawRange(TRIANGLE_LIST, 0, iBuff->GetIndexCount(), 0, vBuff->GetVertexCount());
		}