本文整理汇总了C++中LPDIRECT3DDEVICE9::Present方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::Present方法的具体用法?C++ LPDIRECT3DDEVICE9::Present怎么用?C++ LPDIRECT3DDEVICE9::Present使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::Present方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_1
//-----------------------------------------------------------------------------
// Name: render_1()
// Desc:
//-----------------------------------------------------------------------------
void render_1( void )
{
D3DXMATRIX matView;
D3DXMATRIX matWorld;
D3DXMATRIX matRotation;
D3DXMATRIX matTranslation;
// Now we can clear just view-port's portion of the buffer to green...
g_pd3dDevice_1->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE( 0.0f, 1.0f, 0.0f, 1.0f ), 1.0f, 0 );
g_pd3dDevice_1->BeginScene();
// For the left view-port, leave the view at the origin...
D3DXMatrixIdentity( &matView );
g_pd3dDevice_1->SetTransform( D3DTS_VIEW, &matView );
// ... and use the world matrix to spin and translate the teapot
// out where we can see it...
D3DXMatrixRotationYawPitchRoll( &matRotation, D3DXToRadian(g_fSpinX), D3DXToRadian(g_fSpinY), 0.0f );
D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 5.0f );
matWorld = matRotation * matTranslation;
g_pd3dDevice_1->SetTransform( D3DTS_WORLD, &matWorld );
g_pd3dDevice_1->SetMaterial( &g_teapotMtrl );
g_pTeapotMesh_1->DrawSubset(0);
g_pd3dDevice_1->EndScene();
// We're done! Now, we just call Present()
g_pd3dDevice_1->Present( NULL, NULL, NULL, NULL );
}
示例2: Game_Run
/*
* Game update function
*/
void Game_Run(HWND hwnd)
{
//make sure the Direct3D device is valid
if (!d3ddev) return;
//create pointer to the back buffer
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
//start rendering
if (d3ddev->BeginScene())
{
RECT rect;
rect.top = NULL;
rect.left = NULL;
rect.right = 950;
rect.bottom = 768;
RECT rect2;
rect2.top = 270;
rect2.left = 110;
rect2.right = 900;
rect2.bottom = 768;
d3ddev->StretchRect(surface, &rect2
, backbuffer, &rect, D3DTEXF_NONE);
//stop rendering
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
//check for escape key (to exit program)
if (KEY_DOWN(VK_ESCAPE))
PostMessage(hwnd, WM_DESTROY, 0, 0);
}
示例3: Render
//-----------------------------------------------------------------------------
// Desc: 渲染图形
//-----------------------------------------------------------------------------
VOID Render()
{
//设置是否启用图形反锯齿
if(antiAlisa)
g_pd3dDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS,TRUE);
else
g_pd3dDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS,FALSE);
//清空后台缓冲区
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(45, 50, 170)
, 1.0f, 0 );
//开始在后台缓冲区绘制图形
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
//在后台缓冲区绘制图形
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 );
}
示例4: 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(255, 255, 255), //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
)))
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
static float y = 0;
y += timeDelta / 1000.f;
// 각도가 2*PI 에 이르면 0으로 초기화한다.
if (y >= 6.28f)
y = 0;
Matrix44 rx, ry, r;
rx.SetRotationX(MATH_PI/4.f); // x축으로 45도 회전시킨다.
ry.SetRotationY(y); // y축으로 회전
r = rx*ry;
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&r);
g_pMesh->DrawSubset(0) ;
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
示例5: RenderScene
// Draw one frame of the scene
void RenderScene( float updateTime )
{
// Begin the scene
if (SUCCEEDED(g_pd3dDevice->BeginScene()))
{
// Clear the z buffer & stencil buffer - no need to clear back-buffer
// as the skybox will always fill the background
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,
0, 1.0f, 0 );
// Prepare camera
MainCamera->CalculateMatrices();
// Render all entities
EntityManager.RenderAllEntities( MainCamera );
// Draw on-screen text
RenderSceneText( updateTime );
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例6: RenderFrameDX9
// 使用DirectX 9來繪圖
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();
// 設定轉換矩陣
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);
// 在只傳入2維貼圖座標時, Direct3D使用3x3矩陣來轉換貼圖座標.
Matrix4x4 converted_matrix3x3 = g_texture_matrix;
converted_matrix3x3[2] = g_texture_matrix[3];
device->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *) &converted_matrix3x3);
//device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
//device->SetTexture(0, g_pTexture);
// 畫出矩形
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Quad, sizeof(Vertex_VT));
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例7: AdvanceAndDisplay
// Advances GFx animation and draws the scene.
void FxPlayerTiny::AdvanceAndDisplay()
{
// Clear the back buffer to a black color.
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(200,200,200), 1.0f, 0);
// *** GFx Rendering
if (pMovie)
{
// GRendererD3D9 does not modify D3DRS_FILLMODE, so we can set it here.
pDevice->SetRenderState(D3DRS_FILLMODE,
Wireframe ? D3DFILL_WIREFRAME : D3DFILL_SOLID);
UInt32 time = timeGetTime();
Float delta = ((Float)(time - MovieLastTime)) / 1000.0f;
// Advance time and display the movie.
if (!Paused)
pMovie->Advance(delta);
pMovie->Display();
MovieLastTime = time;
}
// Present the back buffer contents to the display.
pDevice->Present(NULL, NULL, NULL, NULL);
}
示例8: WndProc
//
// 함수: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// 목적: 주 창의 메시지를 처리합니다.
//
// WM_COMMAND - 응용 프로그램 메뉴를 처리합니다.
// WM_PAINT - 주 창을 그립니다.
// WM_DESTROY - 종료 메시지를 게시하고 반환합니다.
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// 메뉴 선택을 구문 분석합니다.
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
{
//화면 청소
if( SUCCEEDED( g_pDevice->Clear(
0, //청소할 영역의 D3DRECT 배열 갯수 ( 전체 클리어 0 )
NULL, //청소할 영역의 D3DRECT 배열 포인터 ( 전체 클리어 NULL )
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, //청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
0xffffff00, //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
) ) )
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
//여기서부터 랜더링 명령이 실행된다..
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
示例9: Display
//渲染函数
//
//
bool Display(float timeDelta)
{
timedelta=timeDelta;
if( Device )
{
//*************绘制区域*********************
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
Device->BeginScene ();
if(g_currentGUI == GUI_MAIN_SCREEN)
ProcessGUI(g_MainGUI, g_LMBDown, g_MouseX,g_MouseY, GUICallback);
else if(g_currentGUI == GUI_START_SCREEN)
ProcessGUI(g_StartGUI, g_LMBDown, g_MouseX,g_MouseY, GUICallback);
else if(g_currentGUI == GUI_LOAD_SCREEN)
ProcessGUI(g_ControlGUI , g_LMBDown, g_MouseX,g_MouseY, GUICallback);
else if(g_currentGUI == GUI_OPTION_SCREEN)
ProcessGUI(g_StoreGUI , g_LMBDown, g_MouseX,g_MouseY, GUICallback);
else
ProcessGUI(g_MainGUI, g_LMBDown, g_MouseX,g_MouseY, GUICallback);
Device->EndScene ();
Device->Present(0, 0, 0, 0);//提交后台缓存示翻转)
}
return true;
}
示例10: Render
void Render()
{
g_pd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
g_pd3dDevice->BeginScene();
D3DXMATRIXA16 matWorld;
D3DXMatrixRotationY(&matWorld, timeGetTime() / 1000.0f);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
D3DXVECTOR3 vEyePt(0.0f, 3.0f,-5.0f);
D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vUpVec(0.0f, 1.0f, 0.0f);
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);
for (DWORD i = 0; i < g_dwNumMaterials; i++)
{
g_pd3dDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pd3dDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}
g_pd3dDevice->EndScene();
g_pd3dDevice->Present(0, 0, 0, 0);
}
示例11: Render
//-----------------------------------------------------------------------------
// Desc: 渲染场景
//-----------------------------------------------------------------------------
VOID Render()
{
// 清除缓冲区
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
//开始渲染场景
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
SetWorldMatrix(); //设置世界矩阵
//逐块渲染网格模型
for( DWORD i=0; i<g_dwNumMaterials; i++ )
{
//设置材料和纹理
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
//渲染模型
g_pMesh->DrawSubset( i );
}
//场景渲染结束
g_pd3dDevice->EndScene();
}
//在屏幕上显示场景
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例12: RenderFrameDX9
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// 消除畫面
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
// 開始下繪圖指令
device->BeginScene();
// 設定座標轉換矩陣
Matrix4x4 view_matrix = GutMatrixLookAtRH(g_eye, g_lookat, g_up);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_world_matrix);
// 套用貼圖
device->SetTexture(0, g_pTexture);
// trilinear filter
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
// 自動產生貼圖座標
device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
//device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
// 使用自動normalize功能
device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
// 畫模型
// 傳入0代表不套用模型中的材質, 經由外部來設定.
g_Model_DX9.Render(0);
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例13: Loop
//ループ処理
bool Application::Loop()
{
MSG msg;
//前のフレームの描画を終了する
d3dDevice->EndScene();
//前のフレームの描画を反映する
d3dDevice->Present(0, 0, 0, 0);
//Windowsメッセージを処理する
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
//ウィンドウを閉じる
if (WM_QUIT == msg.message)
return false;
}
//画面のクリア
if (FAILED(d3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 60, 160), 1.0f, 0)))
return false;
//今のフレームの描画を開始する
d3dDevice->BeginScene();
return true;
}
示例14: Render
VOID Render()
{
SetupMatrix() ;
OnFrameMove() ;
g_pCamera->Update(0.1f, 1.0f) ;
// Clear the back-buffer to a RED color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
RenderTerrain() ;
RenderTree() ;
RenderTeapot() ;
// End the scene
g_pd3dDevice->EndScene();
}
// Present the back-buffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例15: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID CDlg::Render()
{
if (! SUCCEEDED( InitVB() )) {
return;
}
// Clear the backbuffer to a blue color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Draw the triangles in the vertex buffer. This is broken into a few
// steps. We are passing the vertices down a "stream", so first we need
// to specify the source of that stream, which is our vertex buffer. Then
// we need to let D3D know what vertex shader to use. Full, custom vertex
// shaders are an advanced topic, but in most cases the vertex shader is
// just the FVF, so that D3D knows what type of vertices we are dealing
// with. Finally, we call DrawPrimitive() which does the actual rendering
// of our geometry (in this case, just one triangle).
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
//g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, 3 );
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}