本文整理汇总了C++中LPDIRECT3DDEVICE9::EndScene方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::EndScene方法的具体用法?C++ LPDIRECT3DDEVICE9::EndScene怎么用?C++ LPDIRECT3DDEVICE9::EndScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::EndScene方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Direct3D_Render
//-----------------------------------【Direct3D_Render( )函数】-------------------------------
// 描述:使用Direct3D进行渲染
//--------------------------------------------------------------------------------------------------
void Direct3D_Render(HWND hwnd)
{
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之一】:清屏操作
//--------------------------------------------------------------------------------------
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_XRGB(50, 100, 250), 1.0f, 0);
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之二】:开始绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->BeginScene(); // 开始绘制
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之三】:正式绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_matWorld);
for (DWORD i = 0; i < g_dwNumMtrls; i++)
{
g_pd3dDevice->SetMaterial(&g_pMaterials[i]);
g_pd3dDevice->SetTexture(0, g_pTextures[i]);
g_pMesh->DrawSubset(i);
}
D3DXMATRIX matWorld;
D3DXMatrixTranslation(&matWorld, 0.0f, 0.0f, 0.0f);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
g_pd3dDevice->SetTexture(0, g_pTexture);
g_pd3dDevice->SetStreamSource(0, g_pVertexBuffer, 0, sizeof(CUSTOMVERTEX));
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
D3DXMATRIX TransMatrix, RotMatrix, FinalMatrix;
D3DXMatrixRotationX(&RotMatrix, -D3DX_PI * 0.5f);
g_pd3dDevice->SetMaterial(&g_MaterialCylinder);
for (int i = 0; i < 6; i++)
{
D3DXMatrixTranslation(&TransMatrix, -100.0f, 0.0f, -150.0f + (i * 75.0f));
FinalMatrix = RotMatrix * TransMatrix;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &FinalMatrix);
g_cylinder->DrawSubset(0);
D3DXMatrixTranslation(&TransMatrix, 100.0f, 0.0f, -150.0f + (i * 75.0f));
FinalMatrix = RotMatrix * TransMatrix;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &FinalMatrix);
g_cylinder->DrawSubset(0);
}
HelpText_Render(hwnd);
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之四】:结束绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->EndScene(); // 结束绘制
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之五】:显示翻转
//--------------------------------------------------------------------------------------
g_pd3dDevice->Present(NULL, NULL, NULL, NULL); // 翻转与显示
}
示例2: Render
//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
D3DXMATRIX view, proj;
D3DXMATRIX inv, vp, tmp;
D3DXMATRIX lightview, lightproj, lightvp;
D3DXVECTOR2 orient = cameraangle.smooth(alpha);
D3DXVECTOR4 lightpos(0, 0, -5, 0);
D3DXVECTOR3 look(0, 0.5f, 0), up(0, 1, 0);
D3DXVECTOR3 eye(0, 0, -5.2f);
D3DXVECTOR4 clipplanes(0, 0, 0, 0);
D3DXVECTOR4 texelsize(1.0f / SHADOWMAP_SIZE, 1.0f / SHADOWMAP_SIZE, 0, 0);
// setup camera
D3DXMatrixRotationYawPitchRoll(&tmp, orient.x, orient.y, 0);
D3DXVec3TransformCoord(&eye, &eye, &tmp);
D3DXMatrixLookAtLH(&view, &eye, &look, &up);
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, (float)screenwidth / (float)screenheight, 0.1f, 20);
D3DXMatrixMultiply(&vp, &view, &proj);
// setup light
orient = lightangle.smooth(alpha);
look = D3DXVECTOR3(0, 0, 0);
D3DXMatrixRotationYawPitchRoll(&tmp, orient.x, orient.y, 0);
D3DXVec4Transform(&lightpos, &lightpos, &tmp);
D3DXMatrixLookAtLH(&lightview, (D3DXVECTOR3*)&lightpos, &look, &up);
DXFitToBox(lightproj, clipplanes, lightview, scenebb);
D3DXMatrixMultiply(&lightvp, &lightview, &lightproj);
if( SUCCEEDED(device->BeginScene()) )
{
switch( shadowtech )
{
case 0:
RenderWithPCF(vp, eye, lightview, lightproj, lightpos, clipplanes, D3DXVECTOR4(0, 0, 0, 0));
break;
case 1:
RenderWithPCF(vp, eye, lightview, lightproj, lightpos, clipplanes, texelsize);
break;
case 2:
RenderWithIrregularPCF(vp, eye, lightview, lightproj, lightpos, clipplanes, texelsize);
break;
case 3:
RenderWithVariance(vp, eye, lightview, lightproj, lightpos, clipplanes);
break;
case 4:
RenderWithConvolution(vp, eye, lightview, lightproj, lightpos, clipplanes);
break;
case 5:
RenderWithExponential(vp, eye, lightview, lightproj, lightpos, clipplanes);
break;
case 6:
RenderWithExponentialVariance(vp, eye, lightview, lightproj, lightpos, clipplanes);
break;
case 7:
RenderWithPCSS(vp, eye, lightview, lightproj, lightpos, clipplanes, texelsize);
break;
default:
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
break;
}
// render text
device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
device->SetTexture(0, text);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float));
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_ZENABLE, TRUE);
device->EndScene();
}
device->Present(NULL, NULL, NULL, NULL);
}
示例3: 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() ) )
{
SetupCameraMatrices();
SetupLights((timeGetTime() / 1000) % 2);
SetupCylinderMatrices();
int TextureIndex = (timeGetTime() / 1000) % 2;
g_pd3dDevice->SetTexture(0, g_pTexture[TextureIndex]);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
#ifdef SHOW_HOW_TO_USE_TCI
D3DXMATRIXA16 mTextureTransform;
D3DXMATRIXA16 mProj;
D3DXMATRIXA16 mTrans;
D3DXMATRIXA16 mScale;
g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &mProj);
D3DXMatrixTranslation(&mTrans, 0.5f, 0.5f, 0.0f);
D3DXMatrixScaling(&mScale, 0.5f, -0.5f, 1.0f);
mTextureTransform = mProj * mScale * mTrans;
g_pd3dDevice->SetTransform(D3DTS_TEXTURE0, &mTextureTransform);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT4 | D3DTTFF_PROJECTED);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
#endif
g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2 * 50 - 2);
// Meshes are divided into subsets, one for each material. Render them in
// a loop
for (int loop = 0; loop < MESH_COUNT; ++loop)
{
// Setup the world, view, and projection matrices
SetupMeshesMatrices(loop);
for (DWORD i = 0; i < g_dwNumMaterials[loop]; i++)
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial(&g_pMeshMaterials[loop][i]);
g_pd3dDevice->SetTexture(0, g_pMeshTextures[loop][i]);
// Draw the mesh subset
g_pMesh[loop]->DrawSubset(0);
}
}
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例4: RenderFrameDX9
//.........这里部分代码省略.........
g_pTexture->GetSurfaceLevel(0, &pSurface);
device->SetRenderTarget(0, pSurface);
device->SetDepthStencilSurface(g_pDepthStencil);
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(255, 255, 255, 255), 1.0f, 0);
Vector4 vLightPos = g_Light.m_Position;
Vector4 vLightUp(0.0f, 1.0f, 0.0f);
Vector4 vLightLookat(0.0f, 0.0f, 0.0f);
// `把鏡頭放在光源的`
light_projection_matrix = GutMatrixPerspectiveRH_DirectX(60.0f, 1.0f, 0.1f, 100.0f);
light_view_matrix = GutMatrixLookAtRH(vLightPos, vLightLookat, vLightUp);
// `設定轉換矩陣`
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *)&light_projection_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *)&light_view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&world_matrix);
D3DCOLORVALUE zero = {0.0f, 0.0f, 0.0f, 1.0f};
sModelMaterial_DX9 material;
material.m_Material.Ambient = zero;
material.m_Material.Emissive = zero;
material.m_Material.Diffuse = zero;
material.m_Material.Specular = zero;
material.m_bCullFace = false;
material.Submit();
device->SetRenderState(D3DRS_LIGHTING, 0);
g_Model_DX9.Render(0);
pSurface->Release();
device->SetRenderTarget(0, pFrameBufferBackup);
device->SetDepthStencilSurface(pDepthBufferBackup);
}
// `把上一個步驟的結果當成貼圖來使用`
{
// `消除畫面`
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(0, 0, 150, 255), 1.0f, 0);
// `設定轉換矩陣`
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
#define DRAW_TEAPORT_FIRST 1
//! 画茶壶
if (DRAW_TEAPORT_FIRST)
{
SetupLightingDX9();
g_Model_DX9.Render();
}
//! 设置矩形的纹理
sModelMaterial_DX9 material;
material.m_pTextures[0] = g_pTexture;
material.Submit();
Matrix4x4 inv_view_matrix = view_matrix;
inv_view_matrix.FastInvert();
Matrix4x4 uv_offset_matrix;
uv_offset_matrix.Identity();
uv_offset_matrix.Scale(0.5f, -0.5f, 0.5f);
uv_offset_matrix[3].Set(0.5f, 0.5f, 0.5f, 1.0f);
Matrix4x4 texture_matrix = inv_view_matrix * light_view_matrix * light_projection_matrix * uv_offset_matrix;
Matrix4x4 indent_matrix = Matrix4x4::IdentityMatrix();
device->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *) &texture_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &indent_matrix);
device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT4 | D3DTTFF_PROJECTED );
device->SetRenderState(D3DRS_LIGHTING, FALSE);
// `畫出矩形`
device->SetFVF(D3DFVF_XYZ);
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Quad, sizeof(Vertex_VT));
//! 关闭纹理矩阵
device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
if (!DRAW_TEAPORT_FIRST)
{
//SetupLightingDX9();
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
g_Model_DX9.Render();
}
}
// `宣告所有的繪圖指令都下完了`
device->EndScene();
// `把背景backbuffer的畫面呈現出來`
device->Present( NULL, NULL, NULL, NULL );
}
示例5: Render
VOID Render()
{
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
if (SUCCEEDED(g_pD3DDevice->BeginScene()))
{
SetupLights();
SetupMatrices();
if (15 < (g_tick % 31))
{
g_pD3DDevice->SetTexture(0, g_pTexture0);
}
else
{
g_pD3DDevice->SetTexture(0, g_pTexture1);
}
g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
g_pD3DDevice->SetStreamSource(0, g_pVertexBuffer0, 0, sizeof(CUSTOMVERTEX));
g_pD3DDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2 * 50 - 2);
g_pD3DDevice->SetStreamSource(0, g_pVertexBuffer1, 0, sizeof(CUSTOMVERTEX));
g_pD3DDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2 * 50 - 2);
//tiger 1
D3DXMATRIXA16 matFirstTiger, matTrans, matRotate;
//D3DXMatrixIdentity(&matFirstTiger);
//g_pD3DDevice->GetTransform(D3DTS_WORLD, &matFirstTiger);
D3DXMatrixTranslation(&matTrans, -3.f, -1.5f, -1.6f);
D3DXMatrixRotationY(&matRotate, timeGetTime() / 1000.0f);
D3DXMatrixMultiply(&matFirstTiger, &matRotate, &matTrans);
g_pD3DDevice->SetTransform(D3DTS_WORLD, &matFirstTiger);
for (DWORD i = 0; i < g_dwNumMaterials; ++i)
{
g_pD3DDevice->SetMaterial(&g_pMeshMaterials0[i]);
g_pD3DDevice->SetTexture(0, g_pMeshTextures0[i]);
g_pMesh0->DrawSubset(i);
}
//tiger 2
D3DXMATRIXA16 matSecondTiger;
D3DXMatrixIdentity(&matSecondTiger);
D3DXMatrixIdentity(&matTrans);
D3DXMatrixIdentity(&matRotate);
g_pD3DDevice->GetTransform(D3DTS_WORLD, &matSecondTiger);
D3DXMatrixTranslation(&matTrans, 3.f, -1.5f, -1.6f);
D3DXMatrixRotationY(&matRotate, -(timeGetTime() / 1000.0f));
D3DXMatrixMultiply(&matSecondTiger, &matRotate, &matTrans);
g_pD3DDevice->SetTransform(D3DTS_WORLD, &matSecondTiger);
for (DWORD i = 0; i < g_dwNumMaterials; ++i)
{
g_pD3DDevice->SetMaterial(&g_pMeshMaterials0[i]);
g_pD3DDevice->SetTexture(0, g_pMeshTextures0[i]);
g_pMesh0->DrawSubset(i);
}
g_pD3DDevice->EndScene();
}
g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
g_tick++;
}
示例6: Direct3D_Render
//-----------------------------------【Direct3D_Render( )函数】-------------------------------
// 描述:使用Direct3D进行渲染
//--------------------------------------------------------------------------------------------------
void Direct3D_Render(HWND hwnd)
{
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之一】:清屏操作
//--------------------------------------------------------------------------------------
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(100, 100, 100), 1.0f, 0);
//定义一个矩形,用于获取主窗口矩形
RECT formatRect;
GetClientRect(hwnd, &formatRect);
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之二】:开始绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->BeginScene(); // 开始绘制
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之三】:正式绘制,利用顶点缓存绘制图形
//--------------------------------------------------------------------------------------
g_pd3dDevice->SetStreamSource(0, g_pVertexBuffer, 0, sizeof(CUSTOMVERTEX));//把包含的几何体信息的顶点缓存和渲染流水线相关联
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);//指定我们使用的灵活顶点格式的宏名称
g_pd3dDevice->SetIndices(g_pIndexBuffer);//设置索引缓存
//--------------------------------------------------------------------------------------
// 【纹理绘制四步曲之四】:纹理的启用
//--------------------------------------------------------------------------------------
g_pd3dDevice->SetTexture(0, g_pTexture); //启用纹理
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12);//利用索引缓存配合顶点缓存绘制图形
//在窗口右上角处,显示每秒帧数
int charCount = swprintf_s(g_strFPS, 20, _T("FPS:%0.3f"), Get_FPS());
g_pTextFPS->DrawText(NULL, g_strFPS, charCount, &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_RGBA(0, 239, 136, 255));
//显示显卡类型名
g_pTextAdaperName->DrawText(NULL, g_strAdapterName, -1, &formatRect,
DT_TOP | DT_LEFT, D3DXCOLOR(1.0f, 0.5f, 0.0f, 1.0f));
// 输出绘制信息
formatRect.top = 30;
static wchar_t strInfo[256] = { 0 };
swprintf_s(strInfo, -1, L"模型坐标: (%.2f, %.2f, %.2f)", g_matWorld._41, g_matWorld._42, g_matWorld._43);
g_pTextHelper->DrawText(NULL, strInfo, -1, &formatRect, DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(135, 239, 136, 255));
// 输出帮助信息
formatRect.left = 0, formatRect.top = 380;
g_pTextInfor->DrawText(NULL, L"控制说明:", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(235, 123, 230, 255));
formatRect.top += 35;
g_pTextHelper->DrawText(NULL, L" 按住鼠标左键并拖动:平移模型", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
g_pTextHelper->DrawText(NULL, L" 按住鼠标右键并拖动:旋转模型", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
g_pTextHelper->DrawText(NULL, L" 滑动鼠标滚轮:拉伸模型", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
g_pTextHelper->DrawText(NULL, L" W、S、A、D键:平移模型 ", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
g_pTextHelper->DrawText(NULL, L" 上、下、左、右方向键:旋转模型 ", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
g_pTextHelper->DrawText(NULL, L" 键盘上1,2数字键:在两种填充模式之间切换 ", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
formatRect.top += 25;
g_pTextHelper->DrawText(NULL, L" ESC键 : 退出程序", -1, &formatRect,
DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之四】:结束绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->EndScene(); // 结束绘制
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之五】:显示翻转
//--------------------------------------------------------------------------------------
g_pd3dDevice->Present(NULL, NULL, NULL, NULL); // 翻转与显示
}
示例7: MainLoop
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void MainLoop()
{
for(;;)
{
MSG msg;
if (PeekMessage (&msg,NULL,0,0,PM_NOREMOVE))
{
if( msg.message == WM_QUIT )
{
return ;
}
GetMessage (&msg,NULL,0,0);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// サーバーの更新を行う。
g_server->Update();
if( g_timer % 120 == 0 )
{
// エフェクトの停止
g_manager->StopEffect( g_handle );
// エフェクトの再生
g_handle = g_manager->Play( g_effect, 0, 0, 0 );
}
// エフェクトの移動処理を行う。
g_manager->AddLocation( g_handle, ::Effekseer::Vector3D( 0.2f, 0.0f, 0.0f ) );
// エフェクトの更新処理を行う。
g_manager->Update();
g_d3d_device->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
g_d3d_device->BeginScene();
// エフェクトの描画開始処理を行う。
g_renderer->BeginRendering();
// エフェクトの描画を行う。
g_manager->Draw();
// エフェクトの描画終了処理を行う。
g_renderer->EndRendering();
g_d3d_device->EndScene();
g_timer++;
{
HRESULT hr;
hr = g_d3d_device->Present( NULL, NULL, NULL, NULL );
// デバイスロスト処理
switch ( hr )
{
// デバイスロスト
case D3DERR_DEVICELOST:
while ( FAILED( hr = g_d3d_device->TestCooperativeLevel() ) )
{
switch ( hr )
{
// デバイスロスト
case D3DERR_DEVICELOST:
::SleepEx( 1000, true );
break;
// デバイスロスト:リセット可
case D3DERR_DEVICENOTRESET:
// デバイスロストの処理を行う前に実行する
g_renderer->OnLostDevice();
D3DPRESENT_PARAMETERS d3dp;
ZeroMemory(&d3dp, sizeof(d3dp));
d3dp.BackBufferWidth = g_window_width;
d3dp.BackBufferHeight = g_window_height;
d3dp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dp.BackBufferCount = 1;
d3dp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dp.Windowed = TRUE;
d3dp.hDeviceWindow = g_window_handle;
d3dp.EnableAutoDepthStencil = TRUE;
d3dp.AutoDepthStencilFormat = D3DFMT_D16;
g_d3d_device->Reset( &d3dp );
// デバイスロストの処理の後に実行する
g_renderer->OnResetDevice();
break;
}
}
break;
//.........这里部分代码省略.........
示例8: Game
void Game()
{
build_display_array();
if(g_pDevice == NULL) return;
g_pDevice->SetRenderState(D3DRS_FILLMODE,
(g_bShowWireFrm)?D3DFILL_WIREFRAME:D3DFILL_SOLID);
g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
SetupCam();
for (int i=0;i<100;++i)
for (int j=0;j<100;++j) {
int index = (i * 100 + j) * 6;
int count = g_pBox[i][j].bSelect;
int intensity;
if (count == 0) intensity = 0;
else if (count == 1) intensity = 127;
else {
intensity = min(255, 127 + count*16);
}
intensity = 255 - intensity;
int color = D3DCOLOR_ARGB(255, intensity, intensity, 255);
g_pVerticesList[index++].color = color;
g_pVerticesList[index++].color = color;
g_pVerticesList[index++].color = color;
g_pVerticesList[index++].color = color;
g_pVerticesList[index++].color = color;
g_pVerticesList[index++].color = color;
}
//'장면(Scene) 그리기' 시작
if(SUCCEEDED(g_pDevice->BeginScene()))
{
g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
//버퍼 채우기.
VOID* pVertices;
if(FAILED(g_pVB->Lock(0, sizeof(g_pVerticesList), (void**)&pVertices, 0 )))
{
printf("버텍스버퍼 Locking 오류!!\n");
return;
}
memcpy(pVertices, g_pVerticesList, sizeof(g_pVerticesList));
g_pVB->Unlock();
g_pDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
D3DXMATRIX mTrans;
D3DXMatrixIdentity(&mTrans);
g_pDevice->SetTransform(D3DTS_WORLD, &mTrans);
g_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 6 * 100 * 100);
g_pDevice->EndScene();
}
g_pDevice->Present(NULL, NULL, NULL, NULL);
}
示例9: Direct3D_Render
//-----------------------------------【Direct3D_Render( )函数】-------------------------------
// 描述:使用Direct3D进行渲染
//--------------------------------------------------------------------------------------------------
void Direct3D_Render(HWND hwnd)
{
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之一】:清屏操作
//--------------------------------------------------------------------------------------
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
//定义一个矩形,用于获取主窗口矩形
RECT formatRect;
GetClientRect(hwnd, &formatRect);
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之二】:开始绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->BeginScene(); // 开始绘制
Matrix_Set();//调用封装了四大变换的函数,对Direct3D世界变换,取景变换,投影变换,视口变换进行设置
// 获取键盘消息并给予设置相应的填充模式
if (::GetAsyncKeyState(0x31) & 0x8000f) // 若数字键1被按下,进行实体填充
g_pd3dDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
if (::GetAsyncKeyState(0x32) & 0x8000f) // 若数字键2被按下,进行线框填充
g_pd3dDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之三】:正式绘制,利用顶点缓存绘制图形
//--------------------------------------------------------------------------------------
D3DXMatrixRotationY(&R, ::timeGetTime() / 1440.0f); //设置公转的矩阵
// 进行立方体的绘制
D3DXMatrixTranslation(&g_WorldMatrix[0], 3.0f, -3.0f, 0.0f);
g_WorldMatrix[0] = g_WorldMatrix[0]*R;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[0]);
g_cube->DrawSubset(0);
//进行茶壶的绘制
D3DXMatrixTranslation(&g_WorldMatrix[1], -3.0f, -3.0f, 0.0f);
g_WorldMatrix[1] = g_WorldMatrix[1]*R;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[1]);
g_teapot->DrawSubset(0);
// 进行圆环的绘制
D3DXMatrixTranslation(&g_WorldMatrix[2], 3.0f, 3.0f, 0.0f);
g_WorldMatrix[2] = g_WorldMatrix[2]*R;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[2]);
g_torus->DrawSubset(0);
// 进行球面体的绘制
D3DXMatrixTranslation(&g_WorldMatrix[3], -3.0f, 3.0f, 0.0f);
g_WorldMatrix[3] = g_WorldMatrix[3]*R;
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[3]);
g_sphere->DrawSubset(0);
//在窗口右上角处,显示每秒帧数
int charCount = swprintf_s(g_strFPS, 20, _T("FPS:%0.3f"), Get_FPS() );
g_pFont->DrawText(NULL, g_strFPS, charCount , &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255,39,136));
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之四】:结束绘制
//--------------------------------------------------------------------------------------
g_pd3dDevice->EndScene(); // 结束绘制
//--------------------------------------------------------------------------------------
// 【Direct3D渲染五步曲之五】:显示翻转
//--------------------------------------------------------------------------------------
g_pd3dDevice->Present(NULL, NULL, NULL, NULL); // 翻转与显示
}
示例10: Render
//.........这里部分代码省略.........
bloom->EndPass();
bloom->End();
device->SetRenderState(D3DRS_ZENABLE, TRUE);
// STEP 5: water surface
device->SetRenderState(D3DRS_SRGBWRITEENABLE, TRUE);
D3DXMatrixTranslation(&world, 0, -1, 0);
D3DXMatrixIdentity(&inv);
water->SetMatrix("matViewProj", &viewproj);
water->SetMatrix("matWorld", &world);
water->SetMatrix("matWorldInv", &inv);
water->SetVector("eyePos", (D3DXVECTOR4*)&eye);
water->SetVector("lightPos", &lightpos);
water->SetVector("lightColor", &lightcolor);
water->SetFloat("time", time);
water->Begin(0, 0);
water->BeginPass(0);
{
device->SetTexture(0, refraction);
device->SetTexture(1, reflection);
device->SetTexture(2, waves);
waterplane->DrawSubset(0, DXObject::Opaque);
}
water->EndPass();
water->End();
device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
// STEP 6: downsample & blur
quadvertices[6] = quadvertices[24] = quadvertices[30] = (float)screenwidth * 0.5f - 0.5f;
quadvertices[13] = quadvertices[19] = quadvertices[31] = (float)screenheight * 0.5f - 0.5f;
device->SetRenderTarget(0, bloomsurf1);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetVertexDeclaration(quaddecl);
texelsize.x = 1.0f / screenwidth;
texelsize.y = 1.0f / screenheight;
bloom->SetTechnique("downsample");
bloom->SetVector("texelSize", &texelsize);
bloom->Begin(0, 0);
bloom->BeginPass(0);
{
device->SetTexture(0, sceneldr);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
}
bloom->EndPass();
bloom->End();
device->SetRenderTarget(0, bloomsurf2);
texelsize.x = 2.0f / screenwidth;
texelsize.y = 2.0f / screenheight;
bloom->SetTechnique("blur");
bloom->SetVector("texelSize", &texelsize);
bloom->Begin(0, 0);
bloom->BeginPass(0);
{
device->SetTexture(0, bloomtex1);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
}
bloom->EndPass();
bloom->End();
// STEP 7: add light shafts
quadvertices[6] = quadvertices[24] = quadvertices[30] = (float)screenwidth - 0.5f;
quadvertices[13] = quadvertices[19] = quadvertices[31] = (float)screenheight - 0.5f;
device->SetRenderTarget(0, backbuffer);
godray->SetTechnique("final");
godray->Begin(0, 0);
godray->BeginPass(0);
{
device->SetTexture(0, sceneldr);
device->SetTexture(1, occluders);
device->SetTexture(2, bloomtex2);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
}
godray->EndPass();
godray->End();
backbuffer->Release();
device->SetRenderState(D3DRS_ZENABLE, TRUE);
device->EndScene();
}
device->Present(NULL, NULL, NULL, NULL);
}
示例11: RenderFrameDX9
//.........这里部分代码省略.........
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
g_Model_DX9.Render();
}
// 畫出墻壁
{
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &ident_matrix);
sModelMaterial_DX9 material;
material.m_Material.Diffuse.r = 0.0f;
material.m_Material.Diffuse.g = 0.0f;
material.m_Material.Diffuse.b = 1.0f;
material.m_Material.Diffuse.a = 1.0f;
material.Submit();
device->SetFVF(D3DFVF_XYZ);
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Quad, sizeof(Vertex_VT));
}
device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
device->SetRenderState(D3DRS_STENCILENABLE, TRUE);
device->SetRenderState(D3DRS_STENCILREF, 0x01);
device->SetRenderState(D3DRS_STENCILMASK, 0xff);
// 在Stencil Buffer上標示出陰影區域
{
sModelMaterial_DX9 material;
material.m_bCullFace = false;
material.Submit();
// 套用矩陣
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &shadow_matrix);
// 設定頂點資料格式
device->SetFVF(D3DFVF_XYZ);
device->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, TRUE);
// cw stencil setting
device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
device->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCR);
// ccw stencil setting
device->SetRenderState(D3DRS_CCW_STENCILFUNC, D3DCMP_ALWAYS);
device->SetRenderState(D3DRS_CCW_STENCILZFAIL, D3DSTENCILOP_DECR);
// disable color write
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
// 畫出Shadow Volume
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, g_ShadowVolume.m_iNumShadowVolumeFaces, g_ShadowVolume.m_pShadowVolume, sizeof(Vector4));
// 恢復更新framebuffer
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0xff);
device->SetRenderState(D3DRS_TWOSIDEDSTENCILMODE, FALSE);
device->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
device->SetRenderState(D3DRS_CCW_STENCILZFAIL, D3DSTENCILOP_KEEP);
}
// 畫出陰影
{
sModelMaterial_DX9 material;
material.m_bCullFace = false;
material.Submit();
device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
// 套用矩陣
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &ident_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &ident_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &ident_matrix);
// 只更新stencil buffer上值為1的像素
device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_EQUAL);
device->SetRenderState(D3DRS_STENCILREF, 0x01);
// 使用黑色再畫一次墻壁
device->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(0, 0, 0,255) );
device->SetFVF(D3DFVF_XYZ);
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_FullScreenQuad, sizeof(Vertex_VT));
}
device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
// 觀察shadow volume, 除錯用.
if ( g_bDrawShadowVolume )
{
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &shadow_matrix);
sModelMaterial_DX9 material;
material.m_bCullFace = false;
material.Submit();
device->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(255, 255, 255, 255) );
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, g_ShadowVolume.m_iNumShadowVolumeFaces, g_ShadowVolume.m_pShadowVolume, sizeof(Vector4));
device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
}
// 恢復更新zbuffer
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
// 把顏色來源還原為 diffuse * texture
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例12: Render
//.........这里部分代码省略.........
skyeffect->Begin(NULL, 0);
skyeffect->BeginPass(0);
{
skymesh->DrawSubset(0);
}
skyeffect->EndPass();
skyeffect->End();
device->SetRenderState(D3DRS_ZENABLE, TRUE);
// STEP 2: render object
device->SetTexture(0, texture);
device->SetTexture(1, fresneltexture);
device->SetTexture(2, skytexture);
device->SetTexture(3, roughspecular);
fresnel->Begin(NULL, 0);
fresnel->BeginPass(0);
{
mesh->DrawSubset(0);
}
fresnel->EndPass();
fresnel->End();
device->SetVertexDeclaration(vertexdecl);
// STEP 3: measure average luminance
MeasureLuminance();
// STEP 4: adapt luminance to eye
AdaptLuminance(elapsedtime);
// STEP 5: bright pass
BrightPass();
// STEP 6: downsample bright pass texture
DownSample();
// STEP 7: blur downsampled textures
Blur();
// STEP 8: ghost
LensFlare();
// STEP 9: star
Star();
// STEP 10: final combine
hdreffect->SetTechnique("final");
hdreffect->SetFloat("targetluminance", targetluminance);
device->SetRenderTarget(0, oldtarget);
device->SetTexture(0, scenetarget); // scene
device->SetTexture(1, blurtargets[0]); // blur
device->SetTexture(2, blurtargets[1]); // star
device->SetTexture(3, ghosttargets[0]); // ghost
device->SetTexture(4, afterimages[1 - afterimagetex]);
device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
device->SetRenderState(D3DRS_SRGBWRITEENABLE, true);
oldtarget->Release();
hdreffect->Begin(NULL, 0);
hdreffect->BeginPass(0);
{
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, sizeof(D3DXVECTOR4) + sizeof(D3DXVECTOR2));
}
hdreffect->EndPass();
hdreffect->End();
if( drawhelp )
{
// render text
device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
device->SetTexture(0, text);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float));
device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
device->SetRenderState(D3DRS_ZENABLE, TRUE);
}
// clean up
device->SetTexture(1, NULL);
device->SetTexture(2, NULL);
device->SetTexture(3, NULL);
device->SetTexture(4, NULL);
device->SetTexture(5, NULL);
device->EndScene();
}
device->Present(NULL, NULL, NULL, NULL);
}
示例13: 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(150, 150, 150), //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
)))
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
//fps출력
static WORD frameCnt = 0;
static DWORD ntimeDelay = 0;
static float fps = 0.f;
frameCnt++;
ntimeDelay += timeDelta;
if( ntimeDelay >= 1000 )
{
fps = (float)frameCnt;
frameCnt = 0;
ntimeDelay -= ntimeDelay;
}
string outputFps = format( "%0.3f", fps );
RECT rc;
SetRect( &rc, 150, 100, 0, 0 ); //다이렉트 생성할때의 화면 크기의 좌표로 적용됨
global->font->DrawTextA( NULL, //A : 아스키코드
// "global->font->DrawText",
outputFps.c_str(),
-1,
&rc,
DT_NOCLIP, //다 출력하겠다라는 의미(화면 크기 연연하지 않겠다인듯??)
D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) );
//쿼터니언 응용
/*
Quaternion quat;
quat.SetRotationArc(Vector3(0,1,0),Vector3(0,0,1)); //첫번째 인자방향 기준으로 두번째 인자 방향으로
Matrix44 qt = quat.GetMatrix();
*/
static float ftheta = 0.f;
ftheta += 0.0005f;
const float fradian = ftheta / MATH_PI;
if( ftheta >= 360.f )
ftheta = 0.f;
Matrix44 mat;
mat.SetTranslate(Vector3(5, sin(fradian) * 10.f, -490)); //sin(fradian) : 각도에 따른 +-변화 //10.f 곱하기는 범위
// Matrix44 m = global->localTm * mat;
// g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&m); //마우스 회전 잠금
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&mat);
global->mesh3DText->DrawSubset( 0 );
Vector3 mainPos(-10, 0, -490);
Vector3 targetLook = mat.GetPosition() - mainPos; //대상물체와 메인물체와의 거리 판단
targetLook.Normalize();
Quaternion quat;
// mainPos.Normalize();
// quat.SetRotationArc(mainPos, targetLook); //첫번째 인자를 물체의 위치로 하니 회전하는 방향이 생각과는 다르게 표현된다...역시 고정된 방향이어야 되나보다...
quat.SetRotationArc(Vector3(1,0,0), targetLook); //양의 x축방향으로 대상물체를 바라본다
Matrix44 qm = quat.GetMatrix();
mat.SetTranslate(mainPos);
qm *= mat;
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&qm);
global->mesh3DText->DrawSubset( 0 );
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
示例14: WinMain
//.........这里部分代码省略.........
// ←ボタン
{
if (wiiController->getPress(WC_LEFT))
debug->SetDebug("LEFT [ON]\n");
else
debug->SetDebug("LEFT [OFF]\n");
}
// →ボタン
{
if (wiiController->getPress(WC_RIGHT))
debug->SetDebug("RIGHT [ON]\n");
else
debug->SetDebug("RIGHT [OFF]\n");
}
// -ボタン
{
if (wiiController->getPress(WC_MINUS))
debug->SetDebug("MINUS [ON]\n");
else
debug->SetDebug("MINUS [OFF]\n");
if(wiiController->getTrigger(WC_MINUS))
wiiController->rotSpeedCalibration();
}
// +ボタン
{
if (wiiController->getPress(WC_PLUS))
debug->SetDebug("PLUS [ON]\n");
else
debug->SetDebug("PLUS [OFF]\n");
if(wiiController->getTrigger(WC_PLUS))
wiiController->rotReset();
}
// 1ボタン
{
if (wiiController->getPress(WC_ONE))
debug->SetDebug("ONE [ON]\n");
else
debug->SetDebug("ONE [OFF]\n");
}
// 2ボタン
{
if (wiiController->getPress(WC_TWO))
debug->SetDebug("TWO [ON]\n");
else
debug->SetDebug("TWO [OFF]\n");
}
// HOMEボタン
{
if (wiiController->getPress(WC_HOME))
debug->SetDebug("HOME [ON]\n");
else
debug->SetDebug("HOME [OFF]\n");
}
}
// バックバッファ&Zバッファのクリア
device->Clear(0,
NULL,
(D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER),
D3DCOLOR_RGBA(255, 255, 255, 255),
1.0f,
0);
// Direct3Dによる描画の開始
if (SUCCEEDED(device->BeginScene()))
{
CDebug::Draw();
// Direct3Dによる描画の終了
device->EndScene();
}
// バックバッファとフロントバッファの入れ替える
device->Present(NULL, NULL, NULL, NULL);
flameCount++;
}
}
}
SAFE_DELETE(wiiController);
SAFE_DELETE(keyboard);
SAFE_DELETE(mouse);
SAFE_DELETE(debug);
// ウィンドウクラスの登録を解除
UnregisterClass(CLASS_NAME, wcex.hInstance);
timeEndPeriod(1); // 分解能を戻す
return static_cast<int>(msg.wParam);
}
示例15: FSEndScene
BOOL FSEndScene( void )
{
return lpD3DDevice->EndScene() == D3D_OK;
}