本文整理汇总了C++中LPDIRECT3DDEVICE9::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::Clear方法的具体用法?C++ LPDIRECT3DDEVICE9::Clear怎么用?C++ LPDIRECT3DDEVICE9::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
//랜더
void Render(int timeDelta)
{
//화면 청소
if (SUCCEEDED(g_pDevice->Clear(
0, //청소할 영역의 D3DRECT 배열 갯수 ( 전체 클리어 0 )
NULL, //청소할 영역의 D3DRECT 배열 포인터 ( 전체 클리어 NULL )
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, //청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
D3DCOLOR_XRGB(0,0,0), //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
)))
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
//r.SetTranslate(Vector3(0, 0, -498)); // teapot
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&g_LocalTm);
g_pDevice->SetMaterial(&g_Mtrl);
if (g_Mesh)
g_Mesh->DrawSubset(0);
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
示例2: render
void render()
{
assert(g_pd3dDevice);
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
D3DCOLOR color[3];
color[0] = D3DCOLOR_XRGB(255, 0, 0);
color[1] = D3DCOLOR_XRGB(0, 255, 0);
color[2] = D3DCOLOR_XRGB(0, 0, 255);
int i = 0;
int step = 50;
int delta = 0;
int max_delta = 2;
g_pd3dDevice->BeginScene();
{
RECT rect(*g_pRect);
while(rect.top < rect.bottom) {
delta = (rand() % max_delta) - max_delta / 2;
rect.top += delta;
g_pFont->DrawText(NULL, "This text is created using ID3DXFont =)))", -1, &rect, DT_TOP | DT_LEFT, color[i]);
i = ++i % 3;
rect.top += step;
}
}
g_pd3dDevice->EndScene();
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
camera();
}
示例3: Render
void Render()
{
if(g_pD3DDevice==NULL) return;
//Clear the back buffer to a black color
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
//Begin the scene
g_pD3DDevice->BeginScene();
SetupRotation();
SetupCamera();
SetupPerspective();
//Rendering triangles
int triCount=0;
g_pD3DDevice->SetStreamSource(0, g_pVertexBuffer, 0, sizeof(CUSTOMVERTEX));
g_pD3DDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
triCount+=g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
char msg[256];
sprintf(msg, "每桢渲染的三角形数:%d", triCount);
g_pFont->DrawText(msg, 5, 5, D3DCOLOR_XRGB(0, 255, 0));
//End the scene
g_pD3DDevice->EndScene();
//Flip
g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
示例4: Render
VOID Render(float timeDelta)
{
SetupMatrix() ;
g_totalTime += timeDelta ;
float x = cosf(g_totalTime) * 8.0f ;
float y = sinf(g_totalTime) * 4.0f ;
D3DXVECTOR3 pos(x, y, 20) ;
g_Balls->Update(timeDelta, &pos) ;
// Clear the back-buffer to a RED color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Draw teapot
//g_pTeapotMesh->DrawSubset(0) ;
g_Balls->Render() ;
// End the scene
g_pd3dDevice->EndScene();
}
// Present the back-buffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例5: Render
//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
static float time = 0;
D3DXMATRIX viewproj;
D3DXMatrixMultiply(&viewproj, &view, &proj);
D3DXMatrixScaling(&world, 0.1f, 0.1f, 0.1f);
time += elapsedtime;
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
device->SetTransform(D3DTS_WORLD, &world);
device->SetTransform(D3DTS_VIEW, &view);
device->SetTransform(D3DTS_PROJECTION, &proj);
mesh.Update(elapsedtime, &world);
effect->SetMatrix("matViewProj", &viewproj);
if( SUCCEEDED(device->BeginScene()) )
{
mesh.Draw();
device->EndScene();
}
device->Present(NULL, NULL, NULL, NULL);
}
示例6: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render(bool b_AutoRotation, bool b_WireframeMode)
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Setup the world, view, and projection matrices
// SetupMatrices();
if (b_AutoRotation) SetupMatrices();
g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, (b_WireframeMode) ? D3DFILL_WIREFRAME : D3DFILL_SOLID);
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, (b_WireframeMode) ? D3DCULL_NONE : D3DCULL_CCW);
// D3DRenderer are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i = 0; i < g_dwNumMaterials; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
// g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例7: render
VOID render(){
g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(192, 192, 192), 1.0f, 0);
if(SUCCEEDED(g_pDevice->BeginScene())){
setWorldMatrix();
//First, Render the not transparent part
for(DWORD i=0; i<g_dwNumMaterials; ++i){
if(g_pMeshMaterials[i].Diffuse.a == 1.0f){
g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}
}
//Second , Render the transparent part
for(DWORD i=0; i<g_dwNumMaterials; ++i){
if(g_pMeshMaterials[i].Diffuse.a != 1.0f){
g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}
}
g_pDevice->EndScene();
}
g_pDevice->Present(NULL, NULL, NULL, NULL);
}
示例8: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Setup the world, view, and projection matrices
SetupMatrices();
// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i=0; i<g_dwNumMaterials; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例9: if
// ---------- framework : display ----------
bool rtvsD3dApp::display (LPDIRECT3DDEVICE9 pd3dDevice)
{
// clear backbuffers
pd3dDevice->Clear( 0,
NULL,
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_COLORVALUE(0.0f,0.3f,0.7f,1.0f),
1.0f,
0);
// check if should render
if (m_antShouldRender) { // ant says render
if (
!m_pTracer->m_shouldRender // tracer isn't rendering
&& !m_pTracer->m_isRenderDone // tracer isn't done
) {
// tell it to render
m_pTracer->startRender();
}
else if (
!m_pTracer->m_shouldRender // tracer isn't rendering
&& m_pTracer->m_isRenderDone // tracer is done
) {
// reset and tell it to render
m_pTracer->resetRender(pTexture);
m_pTracer->startRender();
}
}
else // ant says don't render
{
if(m_pTracer->m_shouldRender) // tracer is rendering
m_pTracer->m_shouldRender = false; // tell it to stop
}
// if tracer should be rendering
if(m_pTracer->m_shouldRender)
{
// trace line by line & check if done
m_antShouldRender = m_pTracer->traceNextLine();
// try to render
returnvalue = m_pTracer->render(pTexture);
if (FAILED(returnvalue))
return false;
}
// display solid textured quad
pd3dDevice->SetMaterial( &quadMtrl );
pd3dDevice->SetTexture( 0, pTexture );
pd3dDevice->SetStreamSource( 0, pQuadVertexBuffer, 0, sizeof(QuadVertex) );
pd3dDevice->SetFVF( QuadVertex::FVF_Flags );
pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, numQuadTriangles );
TwDraw(); // draw the tweak bar GUI
// ok
return true;
}
示例10: RenderFrameDX9
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
// 取得視窗大小
int w, h;
GutGetWindowSize(w, h);
// 清除畫面
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(100, 100, 100, 255), 1.0f, 0);
// 開始下繪圖指令
device->BeginScene();
// view matrix
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 object_matrix = g_Control.GetObjectMatrix();
g_view_matrix = object_matrix * view_matrix;
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *)&g_view_matrix);
// projection matrix
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *)&g_projection_matrix);
// render objects
RenderSolarSystemDX9();
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例11: Render
//////////////////////////////////////////////////////////////////////////
// 화면 그리기
//////////////////////////////////////////////////////////////////////////
VOID Render()
{
if ( NULL == g_pd3dDevice )
{
return;
}
// 후면 버퍼 지우기
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 20, 0, 0 ), 1.0f, 0 );
// 렌더링 시작
if ( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// 실제 렌더링 명령들이 나열될 곳
//////////////////////////////////////////////////////////////////////////
// 이 내부는 짧고 간결할 수록 좋다
//////////////////////////////////////////////////////////////////////////
// 행렬 설정
SetupMatrices();
// 버텍스 내용물 그리기
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
// 렌더링 종료
g_pd3dDevice->EndScene();
}
// 버퍼 스왑!
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例12: Render
void Render(float timeDelta)
{
if (!g_bActive)
{
Sleep(50) ;
}
SetupMatrix(timeDelta) ;
// Clear the back-buffer to a RED color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(10,66,55), 1.0f, 0 );
// Begin the scene
if(SUCCEEDED(g_pd3dDevice->BeginScene()))
{
g_pd3dDevice->SetVertexShader(g_pVertexShader);
g_pd3dDevice->SetPixelShader(g_pPixelShader);
// Draw teapot
g_pTeapotMesh->DrawSubset(0) ;
// End the scene
g_pd3dDevice->EndScene();
}
// Present the back-buffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例13: Render
/**-----------------------------------------------------------------------------
* 화면 그리기
*------------------------------------------------------------------------------
*/
VOID Render()
{
/// 후면버퍼와 Z버퍼 초기화
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );
/// 애니메이션 행렬설정
Animate();
/// 렌더링 시작
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
g_pd3dDevice->SetTexture( 0, g_pTexDiffuse ); /// 0번 텍스쳐 스테이지에 텍스쳐 고정(색깔맵)
g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); /// 0번 텍스처 스테이지의 확대 필터
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 ); /// 0번 텍스처 : 0번 텍스처 인덱스 사용
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
DrawMesh( &g_matAni );
/// 렌더링 종료
g_pd3dDevice->EndScene();
}
/// 후면버퍼를 보이는 화면으로!
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例14: RenderFrameDX9
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
device->SetRenderState(D3DRS_LIGHTING, FALSE);
// 設定轉換矩陣
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
// 開始下繪圖指令
device->BeginScene();
SetupLightingDX9();
g_Model_DX9.Render();
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例15: RenderFrameDX9
// `使用Direct3D9來繪圖`
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// `消除畫面`
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
// `開始下繪圖指令`
device->BeginScene();
// `設定資料格式`
device->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL);
// `套用shader`
device->SetVertexShader(g_pSelected_VS);
device->SetPixelShader(g_pVertexColor_PS);
// `設定光源`
SetupLightingDX9();
// `設定轉換矩陣`
Matrix4x4 world_view_proj_matrix = g_world_matrix * g_view_proj_matrix;
device->SetVertexShaderConstantF(0, &world_view_proj_matrix[0][0], 4);
device->SetVertexShaderConstantF(4, &g_world_matrix[0][0], 4);
// `鏡頭位置, 計算Specular會用到.`
device->SetVertexShaderConstantF(8, &g_eye[0], 1);
// `畫出格子`
device->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, g_iNumGridVertices, g_iNumGridTriangles,
g_pGridIndices, D3DFMT_INDEX16, g_pGridVertices, sizeof(Vertex_V3N3) );
// `宣告所有的繪圖指令都下完了`
device->EndScene();
// `把背景backbuffer的畫面呈現出來`
device->Present( NULL, NULL, NULL, NULL );
}