Esempio n. 1
0
 void Label::SetCharacterSpacing(float aCharacterSpacing, double aDuration, EasingFunction aEasingFunction, bool aReverse, int aRepeatCount)
 {
     if(aDuration == 0.0)
     {
         m_CharacterSpacing = aCharacterSpacing;
         ResizeRenderTarget();
     }
     else
     {
         if(m_CharacterSpacing != aCharacterSpacing)
         {
             m_TweenCharacterSpacing.Set(m_CharacterSpacing, aCharacterSpacing, aDuration, aEasingFunction, aReverse, aRepeatCount);
         }
     }
 }
Esempio n. 2
0
 void Label::SetText(const string& aText)
 {
     //We can't modify the render target while it is bound
     if(m_RenderTarget != nullptr && m_RenderTarget->IsBound() == true)
     {
         Error(false, "Failed to set Label text, the render target is already bound");
         return;
     }
     
     //Is the text the exact same, if so return
     if(m_Text == aText)
     {
         return;
     }
 
     //Set the text
     m_Text = string(aText);
     
     //Resize the render target
     ResizeRenderTarget();
 }
Esempio n. 3
0
/// <summary>
/// Ensure render target is created
/// </summary>
/// <returns>Indicates success or failure</returns>
HRESULT ImageRenderer::EnsureRenderTarget()
{
    // Create render target properties
    D2D1_RENDER_TARGET_PROPERTIES rtProps = D2D1::RenderTargetProperties();
    rtProps.type        = D2D1_RENDER_TARGET_TYPE_DEFAULT;
    rtProps.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE);
    rtProps.usage       = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE;
    rtProps.minLevel    = D2D1_FEATURE_LEVEL_DEFAULT;

    // Create a hWnd render target, in order to render to the window set in initialize.
    D2D1_SIZE_U client = GetClientSize(m_hWnd);
    HRESULT hr = g_pD2DFactory->CreateHwndRenderTarget(rtProps,
                                                       D2D1::HwndRenderTargetProperties(m_hWnd, client),
                                                       &m_pRenderTarget);

    if (SUCCEEDED(hr))
    {
        // Set render target to client area
        ResizeRenderTarget(client.width, client.height);
    }

    return hr;
}