Ejemplo n.º 1
0
void	CRendererDX::Text( spCBaseFont _spFont, const std::string &_text, const Base::Math::CVector4 &_color, const Base::Math::CRect &_rect, uint32 _flags )
{
    ASSERT( _text != "" );

	if( _spFont == NULL )
		return;

	const fp4 w05 = (fp4)m_spDisplay->Width() * 0.5f;
	const fp4 h05 = (fp4)m_spDisplay->Height() * 0.5f;
	Base::Math::CRect _r( lerpMacro( -w05, w05, _rect.m_X0 ), lerpMacro( -h05, h05, _rect.m_Y0 ), lerpMacro( -w05, w05, _rect.m_X1 ), lerpMacro( -h05, h05, _rect.m_Y1 ) );

	RECT r = { (LONG)_r.m_X0, (LONG)_r.m_Y0, (LONG)_r.m_X1, (LONG)_r.m_Y1, };

    DWORD d3dFlags = DT_NOCLIP;

	if( _flags & CBaseFont::Bottom )		d3dFlags |= DT_BOTTOM; // bug if CBaseFont::Bottom == 0 because of check _flag & 0 != 0
    if( _flags & CBaseFont::Top )			d3dFlags |= DT_TOP;
    if( _flags & CBaseFont::Center )		d3dFlags |= DT_CENTER;
    if( _flags & CBaseFont::Left )			d3dFlags |= DT_LEFT;
    if( _flags & CBaseFont::Right )			d3dFlags |= DT_RIGHT;
    if( _flags & CBaseFont::VCenter )		d3dFlags |= DT_VCENTER;
    if( _flags & CBaseFont::NoClip )		d3dFlags |= DT_NOCLIP;
    if( _flags & CBaseFont::ExpandTabs )	d3dFlags |= DT_EXPANDTABS;
    if( _flags & CBaseFont::WordBreak )		d3dFlags |= DT_WORDBREAK;

	DWORD d3dColor = D3DCOLOR_COLORVALUE( _color.m_X, _color.m_Y, _color.m_Z, _color.m_W );

	spCFontDX	spDXFont = _spFont;
	ID3DXFont	*pDXFont = spDXFont->GetDXFont();
    ASSERT( pDXFont );

    m_pSprite->Begin( D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE | D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DO_NOT_ADDREF_TEXTURE );
    pDXFont->DrawTextA( m_pSprite, (const char *)_text.c_str(), -1, &r, d3dFlags, d3dColor );
    m_pSprite->End();
}
Ejemplo n.º 2
0
void RCDrawText::execute( Renderer& renderer )
{
   DX9Renderer& dxRenderer = static_cast< DX9Renderer& >( renderer );

   ID3DXFont* dxFont = dxRenderer.getFont( m_font );
   if ( !dxFont )
   {
      return;
   }

   // draw text
   static int textLen = -1;

   DWORD format = DT_WORDBREAK;
   switch( m_justification )
   {
   case TJ_LEFT:     format |= DT_LEFT;   break;
   case TJ_CENTERED: format |= DT_CENTER; break;
   case TJ_RIGHT:    format |= DT_RIGHT;  break;
   default: break;
   }

   dxFont->DrawText( NULL,
      m_text.c_str(), 
      textLen, 
      &m_overlaySize, 
      format, 
      D3DCOLOR_RGBA( ( ( int )( m_color.r * 255 ) ), 
      ( ( int )( m_color.g * 255 ) ),
      ( ( int )( m_color.b * 255 ) ),
      ( ( int )( m_color.a * 255 ) ) ) );
}
Ejemplo n.º 3
0
HRESULT APPLICATION::Render()
{
    // Clear the viewport
    m_pDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0L );

    // Begin the scene 
    if(SUCCEEDED(m_pDevice->BeginScene()))
    {
		if(m_wireframe)m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);	
		else m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

		//Render either of the meshes
		if(m_activeMesh == 0)
			m_mesh1.Render();
		else m_mesh2.Render();

		RECT r[] = {{10, 10, 0, 0}, {10, 30, 0, 0}};
		m_pFont->DrawText(NULL, "Space: Next Object", -1, &r[0], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "W: Toggle Wireframe", -1, &r[1], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);

        // End the scene.
		m_pDevice->EndScene();
		m_pDevice->Present(0, 0, 0, 0);
    }

	return S_OK;
}
Ejemplo n.º 4
0
HRESULT APPLICATION::Render()
{
    // Clear the viewport
    m_pDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0L );

    // Begin the scene 
    if(SUCCEEDED(m_pDevice->BeginScene()))
    {
		if(m_wireframe)m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);	
		else m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

		m_terrain.Render();

		RECT r[] = {{10, 10, 0, 0}, {10, 30, 0, 0}, {10, 50, 0, 0}, {400, 10, 0, 0}, {600, 10, 0, 0}};
		m_pFont->DrawText(NULL, "W: Toggle Wireframe", -1, &r[0], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "+/-: Zoom In/Out", -1, &r[1], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "SPACE: Randomize Map", -1, &r[2], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "F5: Save Terrain", -1, &r[3], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "F6: Load Terrain", -1, &r[4], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);

        // End the scene.
		m_pDevice->EndScene();
		m_pDevice->Present(0, 0, 0, 0);
    }

	return S_OK;
}
Ejemplo n.º 5
0
int D9Draw::TextWidth(const wchar_t* text, unsigned long font) {
	ID3DXFont* nativeFont = reinterpret_cast<ID3DXFont*>(font);

	RECT sizeRect = { 0, 0, 0, 0 };
	nativeFont->DrawTextW(NULL, text, wcslen(text), &sizeRect, DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0));
	return sizeRect.right - sizeRect.left;
}
Ejemplo n.º 6
0
void D9Draw::DrawTextW(const wchar_t* text, unsigned long font, util::Color color, util::Vector2 pos) {
	RECT tpos;
	tpos.left = (long)pos.x;
	tpos.top = (long)pos.y;

	ID3DXFont* nativeFont = reinterpret_cast<ID3DXFont*>(font);
	nativeFont->DrawTextW(0, text, wcslen(text), &tpos, DT_NOCLIP, color.GetD3DColor());
}
Ejemplo n.º 7
0
void FontManager::FMClean()
{
	for(Fonts::iterator it = m_fonts.begin(); it != m_fonts.end(); ++it)
	{
		ID3DXFont* font = it->second;
		font->Release();
	}
}
Ejemplo n.º 8
0
spCBaseFont	CRendererDX::NewFont( CFontDescription &_desc )
{
	CBaseFont *pFont = new CFontDX( m_pDevice );
	pFont->FontDescription( _desc );
	pFont->Create();
	ID3DXFont *font = ((CFontDX *) pFont)->GetDXFont();
	font->AddRef();
	m_Fonts.push_back(font);
	return pFont;
}
Ejemplo n.º 9
0
void DrawMyText( IDirect3DDevice9* g_pD3DDevice, char* StrokaTexta, int x, int y, int x1, int y1, D3DCOLOR MyColor )
{
	RECT  Rec;
	HFONT hFont;
	ID3DXFont* pFont = 0; 
	hFont = CreateFont(30, 10, 0, 0, FW_NORMAL, FALSE, FALSE, 0, 1, 0, 0, 0, DEFAULT_PITCH | FF_MODERN, "Arial");
	Rec.left   = x;
	Rec.top    = y;
	Rec.right  = x1;
	Rec.bottom = y1;
	D3DXCreateFont( g_pD3DDevice, 30, 10, FW_NORMAL, 0, FALSE, 0, 0, 0, DEFAULT_PITCH | FF_MODERN, "Arial", &pFont );
	pFont->DrawText(0, StrokaTexta, -1, &Rec, DT_WORDBREAK, MyColor);
	if (pFont)
		pFont->Release();
}
Ejemplo n.º 10
0
HRESULT APPLICATION::Cleanup()
{
	try
	{
		m_pFont->Release();
		m_pFontMouse->Release();

		m_objects.clear();

		m_pDevice->Release();

		debug.Print("Application terminated");
	}
	catch(...){}

	return S_OK;
}
Ejemplo n.º 11
0
void Game::onLostDevice()
{
	HR(mFX->OnLostDevice());
	HR(mFont->OnLostDevice());

	gMyGameWorld->OnLostDevice();
	mSprite->OnLostDevice();
}
Ejemplo n.º 12
0
void CGraphics::DrawText(unsigned int uiLeft, unsigned int uiTop, unsigned int uiRight, unsigned int uiBottom, unsigned long ulColor, float fScaleX, float fScaleY, unsigned long ulFormat, unsigned int fontIndex, bool bShadow, const char * szText)
{
	// Is the sprite invalid?
	if(!m_pSprite)
		return;

	// Get the font
	ID3DXFont * pFont = GetFont(fontIndex);

	// Is the font invalid?
	if(!pFont)
		return;

	// Prevent the rect from getting scaled along with the size
	uiLeft = unsigned int ((float) uiLeft * (1.0f / fScaleX));
	uiTop = unsigned int ((float) uiTop * (1.0f / fScaleY));
	uiRight = unsigned int ((float) uiRight * (1.0f / fScaleX));
	uiBottom = unsigned int ((float) uiBottom * (1.0f / fScaleY));

	// Create the rect
	RECT rect;
	SetRect(&rect, uiLeft, uiTop, uiRight, uiBottom);

	D3DXMATRIX matrix;
	D3DXVECTOR2 scalingCentre(0.5f, 0.5f);
	D3DXVECTOR2 scaling(fScaleX, fScaleY);

	m_pSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);
	D3DXMatrixTransformation2D(&matrix, NULL, 0.0f, &scaling, NULL, 0.0f, NULL);

	m_pSprite->SetTransform(&matrix);

	// If we need to draw shadow do it now
	if (bShadow)
	{
		RECT shadow_rect;        
		SetRect(&shadow_rect, uiLeft + 1, uiTop + 1, uiRight + 1, uiBottom + 1);  
		pFont->DrawText(m_pSprite, szText, -1, &shadow_rect, ulFormat, D3DCOLOR_ARGB(255, 0, 0, 0));
	}

	// Draw the text
	pFont->DrawText(m_pSprite, szText, -1, &rect, ulFormat, ulColor);

	// End the sprite
    m_pSprite->End();
}
Ejemplo n.º 13
0
void Evolution::onResetDevice()
{
    mGfxStats->onResetDevice();
    HR(mFont->OnResetDevice());

    HR(mFX->OnResetDevice());

    buildProjMtx();
}
Ejemplo n.º 14
0
Base::Math::CVector2	CRendererDX::GetTextExtent( spCBaseFont _spFont, const std::string &_text )
{
    ASSERT( _text != "" );

	Base::Math::CVector2 result;

	if( _spFont == NULL )
		return result;

	uint32 width = 0;
    uint32 height = 0;

	fp4	dispWidth  = (fp4)m_spDisplay->Width();
    fp4	dispHeight = (fp4)m_spDisplay->Height();

	spCFontDX	spDXFont = _spFont;
	ID3DXFont	*pDXFont = spDXFont->GetDXFont();
    ASSERT( pDXFont );

    //	Make a copy of `text' and extend it by `.'.
	size_t textLength = _text.length();
	ASSERT( textLength < 2048 );

	static char	pTmp[ 2048 ];
    strcpy( pTmp, (const char *)_text.c_str() );
    pTmp[ textLength ] = '.';
    pTmp[ textLength + 1 ] = '\0';

    //	Determine extents of `.'.
    RECT dotRect = { 0, 0, 0, 0 };
    int32 h = pDXFont->DrawTextA( NULL, ".", -1, &dotRect, DT_LEFT | DT_NOCLIP | DT_CALCRECT, 0 );
    int32 dotWidth = dotRect.right - dotRect.left;

    RECT rect = { 0, 0, 0, 0 };
    h = pDXFont->DrawTextA( NULL, pTmp, -1, &rect, DT_LEFT | DT_NOCLIP | DT_CALCRECT, 0 );

    width = rect.right - rect.left - dotWidth;
    height = rect.bottom - rect.top;

	result = Base::Math::CVector2( (fp4(width) / dispWidth), (fp4(height) / dispHeight) );

	return( result );
}
Ejemplo n.º 15
0
void Game::onResetDevice()
{
	HR(mFX->OnResetDevice());
	HR(mFont->OnResetDevice());

	gMyGameWorld->OnResetDevice();
	mSprite->OnResetDevice();

	// The aspect ratio depends on the backbuffer dimensions, which can 
	// possibly change after a reset.  So rebuild the projection matrix.
	buildProjMtx();
}
Ejemplo n.º 16
0
HRESULT APPLICATION::Render()
{
    // Clear the viewport
    m_pDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0L );

    // Begin the scene 
    if(SUCCEEDED(m_pDevice->BeginScene()))
    {
		//Set camera
		D3DXMATRIX view, proj;
		D3DXMatrixLookAtLH(&view, &D3DXVECTOR3(0.0f, 10.0f, -50.0f), &D3DXVECTOR3(0.0f, 3.0f, 0.0f), &D3DXVECTOR3(0.0f, 1.0f, 0.0f));
		D3DXMatrixOrthoLH(&proj, 10.0f, 9.0f, 0.1f, 1000.0f);
		m_pDevice->SetTransform(D3DTS_VIEW, &view);
		m_pDevice->SetTransform(D3DTS_PROJECTION, &proj);

		if(m_wireframe)m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);	
		else m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

		m_farmer1.Render();
		m_farmer2.RenderProgressive();

		//Number of polygons
		char number[50];
		std::string text = itoa(m_farmer2.GetNumProgressiveFaces(), number, 10);
		text += " polygons (UP/DOWN Arrow)";
		
		RECT r[] = {{170, 520, 0, 0}, {530, 520, 0, 0}, {470, 540, 0, 0}, {130, 540, 0, 0}};
		m_pFont->DrawText(NULL, "Original", -1, &r[0], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "Progressive Mesh", -1, &r[1], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, text.c_str(), -1, &r[2], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "(W)ireframe On/Off", -1, &r[3], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);		

        // End the scene.
		m_pDevice->EndScene();
		m_pDevice->Present(0, 0, 0, 0);
    }

	return S_OK;
}
Ejemplo n.º 17
0
void Game::displayGfxStats()
{
	// Make static so memory is not allocated every frame.
	static char buffer[256];

	sprintf_s(buffer, "Frames Per Second = %.2f\n" "Milliseconds Per Frame = %.4f\n", mFPS, mMilliSecPerFrame);

	D3DCOLOR textColor = D3DCOLOR_XRGB(0, 0, 0);
	if ( gMyGameWorld->BackgroundRed() + gMyGameWorld->BackgroundGreen() + gMyGameWorld->BackgroundBlue() < 384 )
		textColor = D3DCOLOR_XRGB(255, 255, 255);

	RECT R = {5, 5, 0, 0};
	HR(mFont->DrawText(0, buffer, -1, &R, DT_NOCLIP, textColor));
}
Ejemplo n.º 18
0
HRESULT APPLICATION::Cleanup()
{
	try
	{
		m_mesh1.Release();
		m_mesh2.Release();

		m_pFont->Release();
		m_pDevice->Release();

		debug.Print("Application terminated");
	}
	catch(...){}

	return S_OK;
}
Ejemplo n.º 19
0
void HelloD3DApp::drawScene()
{
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0));

	RECT formatRect;
	GetClientRect(mhMainWnd, &formatRect);

	HR(gd3dDevice->BeginScene());

	mFont->DrawText(0, _T("Hello Direct3D"), -1, 
		&formatRect, DT_CENTER | DT_VCENTER, 
		D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256));

	HR(gd3dDevice->EndScene());
	HR(gd3dDevice->Present(0, 0, 0, 0));
}
Ejemplo n.º 20
0
HRESULT APPLICATION::Cleanup()
{
	try
	{
		m_terrain.Release();
		UnloadObjectResources();

		m_pFont->Release();

		m_pDevice->Release();

		debug.Print("Application terminated");
	}
	catch(...){}

	return S_OK;
}
Ejemplo n.º 21
0
HRESULT APPLICATION::Cleanup()
{
	try
	{
		m_pFont->Release();

		if(m_pFarmerMesh != NULL)
			m_pFarmerMesh->Release();

		m_pDevice->Release();

		debug.Print("Application terminated");
	}
	catch(...){}

	return S_OK;
}
Ejemplo n.º 22
0
HRESULT APPLICATION::Cleanup()
{
	try
	{
		if(m_pHeightMap != NULL)
		{
			delete m_pHeightMap;
			m_pHeightMap = NULL;
		}

		m_pFont->Release();
		m_pDevice->Release();

		debug.Print("Application terminated");
	}
	catch(...){}

	return S_OK;
}
Ejemplo n.º 23
0
HRESULT APPLICATION::Render()
{
    // Clear the viewport
    m_pDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L );

    // Begin the scene 
    if(SUCCEEDED(m_pDevice->BeginScene()))
    {
		if(m_pHeightMap != NULL)m_pHeightMap->Render();

		RECT r = {630, 10, 800, 30};
		m_pFont->DrawText(NULL, "Space: Change Image", -1, &r, DT_LEFT | DT_NOCLIP | DT_TOP, 0xffffffff);

        // End the scene.
		m_pDevice->EndScene();
		m_pDevice->Present(0, 0, 0, 0);
    }

	return S_OK;
}
Ejemplo n.º 24
0
void InitDX9App::drawScene()
{
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0));

	RECT formatRect;
	GetClientRect(mhMainWnd, &formatRect);

	HR(gd3dDevice->BeginScene());

	mFont->DrawText(0, L"Hello Direct3D 9", -1, &formatRect, DT_CENTER | DT_VCENTER,
		D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256));

	D3DXVECTOR2 line[] = {
		D3DXVECTOR2(0,0),
		D3DXVECTOR2(100.0f, 100.0f),
		D3DXVECTOR2(100.0f, 200.0f),
	};
	mLine->Begin();
	mLine->Draw(line, 3, D3DCOLOR_XRGB(255,0,0));
	mLine->End();

	HR(gd3dDevice->EndScene());
	HR(gd3dDevice->Present(0, 0, 0, 0));
}
Ejemplo n.º 25
0
void InitDX9App::onLostDevice()
{
	HR(mFont->OnLostDevice());
	HR(mLine->OnLostDevice());
}
Ejemplo n.º 26
0
void Evolution::drawScene()
{
    // Clear the backbuffer and depth buffer.
    HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0));

    HR(gd3dDevice->BeginScene());

    static char buffer[255];
    static RECT clientRect = {0, 0, 0, 0};
    GetClientRect(mhMainWnd, &clientRect);


    HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true));
    HR(gd3dDevice->SetRenderState(D3DRS_ALPHAREF, 25));
    HR(gd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER));

    if (foodList.size() != 0 || eggList.size() != 0)
        drawEggsFood();

    if (lifeformList.size() != 0)
        drawLifeforms();


    if (mbDrawInfo)
    {
        sprintf(buffer, "Carnivore: %d\n"
                "Carnivore Parts: %d\n"
                "Egg Cycle Length: %f\n"
                "Egg Time Length: %f\n"
                "Food Cycle Length: %f\n"
                "Lifetime Length: %f\n"
                "Sight Distance: %f\n"
                "Fear Distance: %f\n"
                "Pursuit Length: %f\n"
                "Speed: %f",
                mDrawInfo.carnivore,
                mDrawInfo.carnivoreParts,
                mDrawInfo.eggCycleLength,
                mDrawInfo.eggTimeLength,
                mDrawInfo.foodCycleLength,
                mDrawInfo.lifeTimeLength,
                mDrawInfo.sightDistance,
                mDrawInfo.fearDistance,
                mDrawInfo.pursuitLength,
                mDrawInfo.speed);
        RECT N = {clientRect.left, clientRect.top+(4*18), clientRect.left+300, clientRect.top+(14*18)};
        HR(mFont->DrawText(0, buffer, -1, &N, DT_LEFT | DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 0)));
    }

    /*if (foodList.size() + BellyFoods + eggList.size() != mMaxBio || BellyFoods < 0)
    {
    	sprintf(buffer, "BIOMASS LOST/GAINED");
    	RECT N = {clientRect.left, clientRect.top+(4*18), clientRect.left+300, clientRect.top+(13*18)};
    	HR(mFont->DrawText(0, buffer, -1, &N, DT_LEFT | DT_NOCLIP, D3DCOLOR_XRGB(255, 0, 0)));
    }*/

    mGfxStats->display();

    HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false));

    HR(gd3dDevice->EndScene());

    // Present the backbuffer.
    HR(gd3dDevice->Present(0, 0, 0, 0));
}
Ejemplo n.º 27
0
void HelloD3DApp::onResetDevice()
{
	HR(mFont->OnResetDevice());
}
Ejemplo n.º 28
0
void Evolution::onLostDevice()
{
    mGfxStats->onLostDevice();
    HR(mFont->OnResetDevice());
    HR(mFX->OnLostDevice());
}
Ejemplo n.º 29
0
void InitDX9App::onResetDevice()
{
	HR(mFont->OnResetDevice());
	HR(mFont->OnResetDevice());
}
Ejemplo n.º 30
0
HRESULT APPLICATION::Render()
{
	//Setup the viewport
	D3DVIEWPORT9 v, v2;
	v.Width = 800;
	v.Height = 600;
	v.X = 0;
	v.Y = 0;
	v.MaxZ = 1.0f;
	v.MinZ = 0.0f;
	m_pDevice->SetViewport(&v);
	v2 = v;

    // Clear the viewport
    m_pDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff4444ff, 1.0f, 0L );

    // Begin the scene 
    if(SUCCEEDED(m_pDevice->BeginScene()))
    {
		//Render big city
		m_city.Render(&m_camera);

		RECT r[] = {{10, 10, 0, 0}, {10, 30, 0, 0}, {10, 50, 0, 0}};
		m_pFont->DrawText(NULL, "Mouse Wheel: Change Camera Radius", -1, &r[0], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		m_pFont->DrawText(NULL, "Arrows: Change Camera Angle", -1, &r[1], DT_LEFT| DT_TOP | DT_NOCLIP, 0xff000000);
		
		//Render city overview, set viewport
		v.X = 550;
		v.Y = 20;
		v.Width = 230;
		v.Height = 230;
		m_pDevice->SetViewport(&v);
		m_pDevice->Clear(0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0L );

		//Setup camera view to orthogonal view looking down on city
		D3DXMATRIX viewTop, projectionTop;
		D3DXMatrixLookAtLH(&viewTop, &(m_city.GetCenter() + D3DXVECTOR3(0.0f, 100.0f, 0.0f)), &m_city.GetCenter(), &D3DXVECTOR3(0,0,1));
		D3DXMatrixOrthoLH(&projectionTop, m_city.m_size.x * TILE_SIZE, m_city.m_size.y * TILE_SIZE, 0.1f, 1000.0f);
		m_pDevice->SetTransform(D3DTS_VIEW, &viewTop);
		m_pDevice->SetTransform(D3DTS_PROJECTION, &projectionTop);
		
		//Draw city blocks that are in view
		m_city.Render(NULL);

		//Restore viewport
		m_pDevice->SetViewport(&v2);

		//Draw line around smaller window
		D3DXVECTOR2 outline[] = {D3DXVECTOR2(550, 20), D3DXVECTOR2(779, 20), D3DXVECTOR2(779, 249), D3DXVECTOR2(550, 249), D3DXVECTOR2(550, 20)};
		m_pLine->SetWidth(3.0f);
		m_pLine->Begin();
		m_pLine->Draw(outline, 5, 0xff000000);
		m_pLine->End();

		//Draw mouse
		m_mouse.Paint();

        // End the scene.
		m_pDevice->EndScene();
		m_pDevice->Present(0, 0, 0, 0);
    }

	return S_OK;
}