本文整理汇总了C++中CD3DFont类的典型用法代码示例。如果您正苦于以下问题:C++ CD3DFont类的具体用法?C++ CD3DFont怎么用?C++ CD3DFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CD3DFont类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawUrl
static bool drawUrl(float x, float y, const char* msg)
{
CD3DFont* fnt = g_font1;
// news text
SIZE ts = GetTextExtent(fnt, msg);
r3dRECT r = {x, y, (float)ts.cx, (float)ts.cy};
r3dColor clr = r3dColor(105, 105, 105);
// selection and underline
if(insideRect(r, g_mx, g_my)) {
clr = r3dColor(255, 255, 255);
r3dDrawBox2D(x, y + (float)ts.cy, (float)ts.cx, 1, clr);
if(g_mb) {
return true;
}
}
fnt->PrintF(x, y, clr, "%s", msg);
return false;
}
示例2: ComputeTangentsAndBinormals
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
// Init the font
m_pFont->InitDeviceObjects( m_pd3dDevice );
// Load texture map. Note that this is a special textures, which has a
// height field stored in the alpha channel
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("emboss1.tga"),
&m_pEmbossTexture, D3DFMT_A8R8G8B8 ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Load geometry
if( FAILED( m_pObject->Create( m_pd3dDevice, _T("tiger.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Set attributes for the geometry
m_pObject->SetFVF( m_pd3dDevice, D3DFVF_EMBOSSVERTEX );
m_pObject->UseMeshMaterials( FALSE );
// Compute the object's tangents and binormals, whaich are needed for the
// emboss-tecnhique's texture-coordinate shifting calculations
ComputeTangentsAndBinormals();
return S_OK;
}
示例3:
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Restore device-memory objects and state after a device is created or
// resized.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
// Restore the device objects for the meshes and fonts
m_pTerrain->RestoreDeviceObjects( m_pd3dDevice );
m_pSkyBox->RestoreDeviceObjects( m_pd3dDevice );
m_pFont->RestoreDeviceObjects();
// Set the transform matrices (view and world are updated per frame)
D3DXMATRIX matProj;
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Set up the default texture states
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
return S_OK;
}
示例4:
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc: Called when the device-dependent objects are about to be lost.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
m_pObject->InvalidateDeviceObjects();
return S_OK;
}
示例5: memcpy
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
HRESULT hr;
m_pFont->InitDeviceObjects( m_pd3dDevice );
ilInit();
iluInit();
ilutInit();
ilutD3D8TexFromFile(m_pd3dDevice, __argv[1], &m_pTexture);
//D3DXCreateTextureFromFile(m_pd3dDevice, __argv[1], &m_pTexture);
// Create a vertex buffer
{
if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( 4*sizeof(VERTEX),
D3DUSAGE_WRITEONLY,
D3DFVF_VERTEX,
D3DPOOL_MANAGED, &m_pVB ) ) )
return hr;
VERTEX* pVertices;
m_pVB->Lock( 0, 4*sizeof(VERTEX), (BYTE**)&pVertices, 0 );
memcpy( pVertices, g_vVertices, sizeof(VERTEX)*4 );
m_pVB->Unlock();
}
return S_OK;
}
示例6: ShutdownUtils
void ShutdownUtils()
{
linear_copy_sampler.reset();
point_copy_sampler.reset();
font.Shutdown();
SAFE_DELETE(util_vbuf);
}
示例7: InitUtils
void InitUtils()
{
util_vbuf = new UtilVertexBuffer(65535);
float border[4] = { 0.f, 0.f, 0.f, 0.f };
D3D11_SAMPLER_DESC samDesc = CD3D11_SAMPLER_DESC(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_BORDER, D3D11_TEXTURE_ADDRESS_BORDER, D3D11_TEXTURE_ADDRESS_BORDER, 0.f, 1, D3D11_COMPARISON_ALWAYS, border, 0.f, 0.f);
HRESULT hr = D3D::device->CreateSamplerState(&samDesc, ToAddr(point_copy_sampler));
if (FAILED(hr)) PanicAlert("Failed to create sampler state at %s %d\n", __FILE__, __LINE__);
else SetDebugObjectName(point_copy_sampler.get(), "point copy sampler state");
samDesc = CD3D11_SAMPLER_DESC(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_BORDER, D3D11_TEXTURE_ADDRESS_BORDER, D3D11_TEXTURE_ADDRESS_BORDER, 0.f, 1, D3D11_COMPARISON_ALWAYS, border, 0.f, 0.f);
hr = D3D::device->CreateSamplerState(&samDesc, ToAddr(linear_copy_sampler));
if (FAILED(hr)) PanicAlert("Failed to create sampler state at %s %d\n", __FILE__, __LINE__);
else SetDebugObjectName(linear_copy_sampler.get(), "linear copy sampler state");
// cached data used to avoid unnecessarily reloading the vertex buffers
memset(&tex_quad_data, 0, sizeof(tex_quad_data));
memset(&draw_quad_data, 0, sizeof(draw_quad_data));
memset(&clear_quad_data, 0, sizeof(clear_quad_data));
// make sure to properly load the vertex data whenever the corresponding functions get called the first time
stq_observer = stsq_observer = cq_observer = clearq_observer = true;
util_vbuf->AddWrapObserver(&stq_observer);
util_vbuf->AddWrapObserver(&stsq_observer);
util_vbuf->AddWrapObserver(&cq_observer);
util_vbuf->AddWrapObserver(&clearq_observer);
font.Init();
}
示例8:
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Called when the app is exiting, or the device is being changed,
// this function deletes any device dependent objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::DeleteDeviceObjects()
{
m_pFont->DeleteDeviceObjects();
SAFE_RELEASE( m_pTexture );
SAFE_RELEASE( m_pVB );
return S_OK;
}
示例9: DrawTrees
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Called once per frame, the call is the entry point for 3d
// rendering. This function sets up render states, clears the
// viewport, and renders the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
// Clear the viewport
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L );
// Begin the scene
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
{
// Render the Skybox
{
// Center view matrix for skybox and disable zbuffer
D3DXMATRIX matView, matViewSave;
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSave );
matView = matViewSave;
matView._41 = 0.0f; matView._42 = -0.3f; matView._43 = 0.0f;
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
// Some cards do not disable writing to Z when
// D3DRS_ZENABLE is FALSE. So do it explicitly
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
// Render the skybox
m_pSkyBox->Render( m_pd3dDevice );
// Restore the render states
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matViewSave );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE);
}
// Draw the terrain
m_pTerrain->Render( m_pd3dDevice );
// Draw the trees
DrawTrees();
// Output statistics
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
// End the scene.
m_pd3dDevice->EndScene();
}
return S_OK;
}
示例10:
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
m_MeshAttrSorted.ReleaseLocalMeshes();
m_MeshStripReordered.ReleaseLocalMeshes();
m_MeshVertexCacheOptimized.ReleaseLocalMeshes();
return S_OK;
}
示例11:
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Called when the app is exiting, or the device is being changed,
// this function deletes any device dependent objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::DeleteDeviceObjects()
{
m_pFont->DeleteDeviceObjects();
m_pShinyTeapot->Destroy();
m_pSkyBox->Destroy();
SAFE_RELEASE( m_pSphereMap );
SAFE_RELEASE( m_pEffect );
return S_OK;
}
示例12:
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Called when the app is exiting, or the device is being changed,
// this function deletes any device dependent objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::DeleteDeviceObjects()
{
m_pFont->DeleteDeviceObjects();
SAFE_RELEASE( m_pBackgroundTexture );
SAFE_RELEASE( m_pBumpMapTexture );
SAFE_RELEASE( m_pBackgroundVB );
SAFE_RELEASE( m_pLensVB );
return S_OK;
}
示例13:
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
HRESULT hr;
m_pFont->InvalidateDeviceObjects();
m_pFontSmall->InvalidateDeviceObjects();
if(FAILED(hr = m_Water.OnLostDevice()))
return hr;
if(FAILED(hr = m_Environment.OnLostDevice()))
return hr;
SAFE_RELEASE(m_pRenderToSurface);
SAFE_RELEASE(m_pEffect);
SAFE_RELEASE(m_pCausticSurf);
SAFE_RELEASE(m_pCausticTex);
return S_OK;
}
示例14: CheckMenuItem
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
HRESULT hr = S_OK;
LPD3DXMESH pMeshSysMem = NULL;
LPD3DXBUFFER pAdjacencyBuffer = NULL;
// Initialize the font
m_pFont->InitDeviceObjects( m_pd3dDevice );
// check current display setting
CheckMenuItem( GetMenu(m_hWnd), ID_OPTIONS_DISPLAY1 + (m_cObjectsPerSide-1), MF_CHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWNONOPTIMIZEDMESH, (!m_bShowStripReordered && !m_bShowVertexCacheOptimized) ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWVCACHEOPTIMIZED, m_bShowVertexCacheOptimized ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWSTRIPREORDERED, m_bShowStripReordered ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWTRILIST, (!m_bShowStrips && !m_bShowSingleStrip) ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWONESTRIP, m_bShowSingleStrip ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWMANYSTRIPS, m_bShowStrips ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_DYNAMICVB, (m_dwMemoryOptions == D3DXMESH_DYNAMIC) ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( GetMenu(m_hWnd), IDM_FORCE32BYTEVERTEX, m_bForce32ByteFVF ? MF_CHECKED : MF_UNCHECKED );
hr = LoadMeshData(&pMeshSysMem, &pAdjacencyBuffer);
if (FAILED(hr))
{
// ignore load errors, just draw blank screen if mesh is invalid
hr = S_OK;
goto End;
}
hr = OptimizeMeshData(pMeshSysMem, pAdjacencyBuffer, D3DXMESHOPT_ATTRSORT, &m_MeshAttrSorted);
if (FAILED(hr))
goto End;
hr = OptimizeMeshData(pMeshSysMem, pAdjacencyBuffer, D3DXMESHOPT_STRIPREORDER, &m_MeshStripReordered);
if (FAILED(hr))
goto End;
hr = OptimizeMeshData(pMeshSysMem, pAdjacencyBuffer, D3DXMESHOPT_VERTEXCACHE, &m_MeshVertexCacheOptimized);
if (FAILED(hr))
goto End;
End:
SAFE_RELEASE( pMeshSysMem );
SAFE_RELEASE( pAdjacencyBuffer );
return hr;
}
示例15: ApplyEnvironmentMap
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Restore device-memory objects and state after a device is created or
// resized.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
// Restore device objects
m_pObject->RestoreDeviceObjects( m_pd3dDevice );
m_pFont->RestoreDeviceObjects();
// Set up the textures
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
// Set the view and projection matrices
D3DXMATRIX matView, matProj;
D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, 3.5f );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMatrixLookAtLH( &matView, &vFromPt, &vLookatPt, &vUpVec );
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 1000.0f );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Setup a material
D3DMATERIAL8 mtrl;
D3DUtil_InitMaterial( mtrl, 1.0f, 1.0f, 1.0f );
m_pd3dDevice->SetMaterial( &mtrl );
// Set up the light
D3DUtil_InitLight( m_Light, D3DLIGHT_POINT, 5.0f, 5.0f, -20.0f );
m_Light.Attenuation0 = 1.0f;
m_pd3dDevice->SetLight( 0, &m_Light );
m_pd3dDevice->LightEnable( 0, TRUE );
// Set miscellaneous render states
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00444444 );
ApplyEnvironmentMap();
return S_OK;
}