Esempio n. 1
0
void Scene::Render(HWND hwnd)
{
	HRESULT hr = CreateGraphicsResources(hwnd);
	if (FAILED(hr))
	{
		return;
	}

	assert(m_pRenderTarget != NULL);

	m_pRenderTarget->BeginDraw();

	RenderScene();

	hr = m_pRenderTarget->EndDraw();
	if (hr == D2DERR_RECREATE_TARGET)
	{
		DiscardDeviceDependentResources();
	}
}
Esempio n. 2
0
HRESULT ui::UIListBoxItem::Render(graphics::D3DInteropHelper *pD3DInteropHelper, ID2D1RenderTarget *pRenderTarget) {
#ifdef DEBUG_UILISTBOXITEM
  LOG_ENTER(SEVERITY_LEVEL_DEBUG);
#endif
  if (m_textChanged) {
    __RecreateAllTextLayout(pD3DInteropHelper, pRenderTarget);
    m_textChanged = false;
  }
  if (m_resourceChanged) {
    DiscardDeviceDependentResources();
    CreateDeviceDependentResources(pD3DInteropHelper, pRenderTarget);
    m_resourceChanged = true;
  }

  m_bodyRect->Render(pD3DInteropHelper, pRenderTarget, 1.0f);

  if (!m_bitmap->IsLoaded()) {
    m_bitmap->Load(pRenderTarget, pD3DInteropHelper->GetWICImagingFactory());
  }
  pRenderTarget->DrawBitmap(m_bitmap->GetBitmap(), m_bitmapLayoutRect.ToRectF());
  pRenderTarget->DrawTextLayout(D2D1::Point2F(m_mainTextLayoutRect.x, m_mainTextLayoutRect.y), m_mainTextLayout,
                                m_textBrushSet->Get(L"mainTextBrush")->GetBrush());
  pRenderTarget->DrawTextLayout(D2D1::Point2F(m_subText1LayoutRect.x, m_subText1LayoutRect.y), m_subText1Layout,
                                m_textBrushSet->Get(L"subText1Brush")->GetBrush());
  pRenderTarget->DrawTextLayout(D2D1::Point2F(m_subText2LayoutRect.x, m_subText2LayoutRect.y), m_subText2Layout,
                                m_textBrushSet->Get(L"subText2Brush")->GetBrush());

//     CComPtr<ID2D1SolidColorBrush> redBrush = nullptr;
//     pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Red), D2D1::BrushProperties(), &redBrush);
//     LOG(SEVERITY_LEVEL_DEBUG) << L"width = " << GetWidth() << L", height = " << GetHeight();
//     pRenderTarget->DrawRectangle(D2D1::RectF(0.0f, 0.0f, GetWidth(), GetHeight()), redBrush);

#ifdef DEBUG_UILISTBOXITEM
  LOG_LEAVE(SEVERITY_LEVEL_DEBUG);
#endif
  return S_OK;
}