Пример #1
0
bool BlondeIndexBufferDX::Fill( void* data )
{
	if (EngineGlobals::renderAPI_DirectX && EngineGlobals::renderAPI_DirectXVersion == 9)
	{
		void * bufferPointer;

		HRESULT result = indexBufferDx9->Lock(0, numIndices * indexSize, &bufferPointer, 0);

		if (FAILED(result))
		{
			EngineMessageHandler::SendMessageErrorConsole("Error locking the index buffer for writing.");
			return false;
		}

		memcpy(bufferPointer, data, indexSize * numIndices);

		indexBufferDx9->Unlock();

		return true;
	}
	else if(EngineGlobals::renderAPI_DirectX && EngineGlobals::renderAPI_DirectXVersion == 10)
	{
		// Get the DirectX 10 device.
		ID3D10Device* pDevice = (ID3D10Device*) BlondeGraphics::GetCurrentDevice();

		pDevice->UpdateSubresource(indexBufferDx10, 0, NULL, data, 0, 0);

		return true;
	}

	return false;
}
Пример #2
0
bool CGutFontUniCodeDX10::AccessTexture(WCHAR c, int &x, int &y)
{
	bool bUpdateTexture = CGutFontUniCode::AccessTexture(c, x, y);

	if ( bUpdateTexture )
	{
		ID3D10Device *pDevice = GutGetGraphicsDeviceDX10();

		float tX = (float)x / (float)m_iLayoutW;
		float tY = (float)y / (float)m_iLayoutH;
		float tW = 1.0f/(float)m_iLayoutW;
		float tH = 1.0f/(float)m_iLayoutH;

		int left = tX * m_iTextureW;
		int width = tW * m_iTextureW;
		int right = left + width;
		int top = tY * m_iTextureH;
		int height = tH * m_iTextureH;
		int bottom = top + height;

		unsigned char *pBuffer = new unsigned char[width*height];
		unsigned char *buffer = pBuffer;

		for ( int y=0; y<height; y++ )
		{
			for ( int x=0; x<width; x++ )
			{
				COLORREF rgb = GetPixel(m_MemDC, x, y);

				buffer[0] = GetRValue(rgb);

				buffer++;
			}
		}

		D3D10_BOX box;

		box.left = left;
		box.right = right;
		box.top = top;
		box.bottom = bottom;
		box.front = 0;
		box.back = 1;

		pDevice->UpdateSubresource(
			m_pFontTexture2D, 0, 
			&box, pBuffer, 
			width,
			width*height);

		delete [] pBuffer;

	}

	return true;
}