コード例 #1
0
//-----------------------------------------------------------------------------
void D3D9HardwarePixelBuffer::bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *volume, IDirect3DBaseTexture9 *mipTex)
{
    D3D9_DEVICE_ACCESS_CRITICAL_SECTION

    BufferResources* bufferResources = getBufferResources(dev);
    bool isNewBuffer = false;

    if (bufferResources == NULL)
    {
        bufferResources = createBufferResources();
        mMapDeviceToBufferResources[dev] = bufferResources;
        isNewBuffer = true;
    }

    bufferResources->mipTex = mipTex;
    bufferResources->volume = volume;
    bufferResources->volume->AddRef();
    
    D3DVOLUME_DESC desc;
    if(volume->GetDesc(&desc) != D3D_OK)
        OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Could not get volume information",
         "D3D9HardwarePixelBuffer::D3D9HardwarePixelBuffer");
    mWidth = desc.Width;
    mHeight = desc.Height;
    mDepth = desc.Depth;
    mFormat = D3D9Mappings::_getPF(desc.Format);
    // Default
    mRowPitch = mWidth;
    mSlicePitch = mHeight*mWidth;
    mSizeInBytes = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);

    if (isNewBuffer && mOwnerTexture->isManuallyLoaded())
    {
        DeviceToBufferResourcesIterator it = mMapDeviceToBufferResources.begin();
        
        while (it != mMapDeviceToBufferResources.end())
        {
            if (it->second != bufferResources &&
                it->second->volume != NULL &&
                it->first->TestCooperativeLevel() == D3D_OK &&
                dev->TestCooperativeLevel() == D3D_OK)
            {
                Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
                PixelBox dstBox(fullBufferBox, mFormat);

                dstBox.data = OGRE_MALLOC(getSizeInBytes(), MEMCATEGORY_RESOURCE);
                blitToMemory(fullBufferBox, dstBox, it->second, it->first);
                blitFromMemory(dstBox, fullBufferBox, bufferResources);
                OGRE_FREE(dstBox.data, MEMCATEGORY_RESOURCE);
                break;
            }
            ++it;           
        }               
    }
}
コード例 #2
0
ファイル: GUIFontTTFDX.cpp プロジェクト: shinose/kodi-qplay
bool CGUIFontTTFDX::CopyCharToTexture(FT_BitmapGlyph bitGlyph, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
{
  FT_Bitmap bitmap = bitGlyph->bitmap;

  ID3D11DeviceContext* pContext = g_Windowing.GetImmediateContext();
  if (m_speedupTexture && m_speedupTexture->Get() && pContext && bitmap.buffer)
  {
    CD3D11_BOX dstBox(x1, y1, 0, x2, y2, 1);
    pContext->UpdateSubresource(m_speedupTexture->Get(), 0, &dstBox, bitmap.buffer, bitmap.pitch, 0);
    return true;
  }

  return false;
}