本文整理汇总了C++中CGutModel_DX10::Render方法的典型用法代码示例。如果您正苦于以下问题:C++ CGutModel_DX10::Render方法的具体用法?C++ CGutModel_DX10::Render怎么用?C++ CGutModel_DX10::Render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGutModel_DX10
的用法示例。
在下文中一共展示了CGutModel_DX10::Render方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderFrameDX10
void RenderFrameDX10(void)
{
Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// frame buffer
ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView();
// depth/stencil buffer
ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView();
// front/back buffer
IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
// 清除顏色
g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
// 清除Depth/Stencil buffer
g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
// 取得轉換矩陣
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
Matrix4x4 ident_matrix = Matrix4x4::IdentityMatrix();
CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
CGutModel_DX10::SetViewMatrix(view_matrix);
// 畫出茶具組
{
g_pDevice->OMSetDepthStencilState(NULL, 1);
CGutModel_DX10::SetWorldMatrix(world_matrix);
CGutModel_DX10::UpdateMatrix();
g_Model_DX10.Render();
}
// stencil pass, 在stencil buffer里標出光源照射到的像素
{
g_pDevice->OMSetDepthStencilState(g_pZStencil_Mask, 1);
CGutModel_DX10::SetWorldMatrix(ident_matrix);
CGutModel_DX10::UpdateMatrix();
CGutModel_DX10::SetMaterialOverwrite(&g_material_stencilpass);
g_SpotLightModel_DX10.Render();
}
// 畫出被光線照射到的區域
{
g_pDevice->OMSetDepthStencilState(g_pZStencil_Test, 1);
CGutModel_DX10::SetMaterialOverwrite(&g_material_spotlightpass);
g_SpotLightModel_DX10.Render();
}
// 畫出光柱圓錐
{
g_pDevice->OMSetDepthStencilState(NULL, 1);
CGutModel_DX10::SetMaterialOverwrite(NULL);
g_SpotLightModel_DX10.Render();
}
// 等待硬體掃結束, 然後才更新畫面.
pSwapChain->Present(1, 0);
}
示例2: RenderModelDX10
void RenderModelDX10(bool mirror, Vector4 *pPlane)
{
ID3D10Device *pDevice = GutGetGraphicsDeviceDX10();
Matrix4x4 view_matrix;
Matrix4x4 proj_matrix;
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
if ( mirror )
{
Vector4 vEye = g_Control.GetCameraPosition();
Vector4 vUp = g_Control.m_vUp;
Vector4 vLookAt = g_Control.m_vLookAt;
Vector4 mirror_eye = MirrorPoint(vEye, *pPlane);
Vector4 mirror_lookat = MirrorPoint(vLookAt, *pPlane);
Vector4 mirror_up = MirrorPoint(vUp, *pPlane);
view_matrix = GutMatrixLookAtRH(mirror_eye, mirror_lookat, mirror_up);
g_mirror_view_matrix = view_matrix;
}
else
{
view_matrix = g_Control.GetViewMatrix();
}
// `CGutModel_DX10中有提供一些模擬Fixed Piepline的函式`
CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
CGutModel_DX10::SetViewMatrix(view_matrix);
CGutModel_DX10::SetWorldMatrix(world_matrix);
CGutModel_DX10::UpdateMatrix();
g_Model_DX10.Render();
}
示例3: RenderFrameDX10
void RenderFrameDX10(void)
{
Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// 取得呼叫GutCreateGraphicsDeviceDX10時所產生的D3D10物件
ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer
IDXGISwapChain *pSwapChain = GutGetDX10SwapChain(); // front/back buffer
g_pDevice->ClearRenderTargetView(pRenderTargetView, &vClearColor[0]);
g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
Matrix4x4 camera_matrix = g_Control.GetCameraMatrix();
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
g_Model_DX10.SetLight(0, g_Lights[0]);
g_Model_DX10.SetLight(1, g_Lights[1]);
g_Model_DX10.EnableLighting(true);
g_Model_DX10.SetProjectionMatrix(g_proj_matrix);
g_Model_DX10.SetWorldMatrix(world_matrix);
g_Model_DX10.SetViewMatrix(view_matrix);
g_Model_DX10.SetInvViewMatrix(camera_matrix);
g_Model_DX10.UpdateMatrix();
g_Model_DX10.Render();
// 等待硬體掃結束, 然後才更新畫面
pSwapChain->Present(1, 0);
}
示例4: RenderFrameDX10
void RenderFrameDX10(void)
{
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
UINT stride = sizeof(Vertex_VT);
UINT offset = 0;
ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView();
ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView();
g_pDevice->OMSetRenderTargets(1, &g_pRTView[FULLSIZE], pDepthStencilView);
g_pDevice->ClearRenderTargetView(g_pRTView[FULLSIZE], &vClearColor[0]);
g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
SetViewport(FULLSIZE);
CGutModel_DX10::SetViewMatrix(view_matrix);
CGutModel_DX10::SetWorldMatrix(world_matrix);
CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
CGutModel_DX10::UpdateMatrix();
g_Model_DX10.Render();
ConvertToLuminance();
Average();
AdaptiveLuminance();
AutoExposure();
if ( g_iMode & 0x01 )
{
g_pDevice->OMSetRenderTargets(1, &pRenderTargetView, pDepthStencilView);
SetViewport(FULLSIZE);
float x = -1.0f;
float y = -1.0f;
float w = 0.2f;
float h = 0.2f;
DrawImage(g_pSRView[LUMINANCE_CURRENT], x, y, w, h);
x+=w;
DrawImage(g_pSRView[LUMINANCE_PREVIOUS], x, y, w, h);
x+=w;
}
// 等待硬體掃結束, 然後才更新畫面
IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
pSwapChain->Present(1, 0);
}
示例5: RenderFrameDX10
void RenderFrameDX10(void)
{
Vector4 vClearColor(0.0f);
Vector4 vObjectColor(0.0f, 1.0f, 0.0f);
ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView(); //frame buffer
ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView(); //depth/stencil buffer
g_pDevice->ClearRenderTargetView(pRenderTargetView, &vClearColor[0]);
g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
// background image
DrawImage(g_pTexture);
// refraction
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
Matrix4x4 wvp_matrix = world_matrix * view_matrix * g_proj_matrix;
Matrix4x4 wv_matrix = world_matrix * view_matrix;
ID3D10EffectTechnique *pShader = g_pRefractionFX->GetTechniqueByName("Refraction");
ID3D10EffectShaderResourceVariable *texture_param = g_pRefractionFX->GetVariableByName("BackgroundImage")->AsShaderResource();
ID3D10EffectMatrixVariable *wvpmatrix_param = g_pRefractionFX->GetVariableByName("wvp_matrix")->AsMatrix();
ID3D10EffectMatrixVariable *wvmatrix_param = g_pRefractionFX->GetVariableByName("wv_matrix")->AsMatrix();
ID3D10EffectVectorVariable *color_param = g_pRefractionFX->GetVariableByName("object_color")->AsVector();
texture_param->SetResource(g_pTexture);
wvpmatrix_param->SetMatrix( (float *)&wvp_matrix );
wvmatrix_param->SetMatrix( (float *)&wv_matrix );
color_param->SetFloatVector( (float *)&vObjectColor );
pShader->GetPassByIndex(0)->Apply(0);
g_pDevice->IASetInputLayout(g_pRefractionLayout);
g_Model_DX10.Render(SUBMIT_CULLFACE);
// 等待硬體掃結束, 然後才更新畫面
IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
pSwapChain->Present(1, 0);
}
示例6: RenderFrameDX10
void RenderFrameDX10(void)
{
Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// frame buffer
ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView();
// depth/stencil buffer
ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView();
// front/back buffer
IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
Matrix4x4 ident_matrix; ident_matrix.Identity();
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
Matrix4x4 world_view_proj_matrix = world_matrix * view_matrix * g_proj_matrix;
// 清除顏色
g_pDevice->ClearRenderTargetView(pRenderTargetView, (float *)&vClearColor);
// 清除Depth/Stencil buffer
g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
// 畫出茶壼, 并更新 Stencil Buffer.
{
g_pDevice->OMSetDepthStencilState(g_pZStencil_Incr, 0);
CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
CGutModel_DX10::SetViewMatrix(view_matrix);
CGutModel_DX10::SetWorldMatrix(world_matrix);
CGutModel_DX10::UpdateMatrix();
g_Model_DX10.Render();
}
// 套用 Shader
{
UINT stride = sizeof(Vertex_V);
UINT offset = 0;
// 設定Shader
g_pDevice->VSSetShader(g_pVertexShader);
g_pDevice->PSSetShader(g_pPixelShader);
// 設定Shader讀取參數的記憶體位罝
g_pDevice->VSSetConstantBuffers(0, 1, &g_pConstantBuffer);
g_pDevice->PSSetConstantBuffers(0, 1, &g_pConstantBuffer);
// 設定vertex資料格式
g_pDevice->IASetInputLayout(g_pVertexLayout);
// 設定Vertex Buffer
g_pDevice->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset);
// 設定三角形頂點索引值資料排列是triangle strip
g_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
ShaderConstant *pConstData = NULL;
// 用綠色標示出只更新1次的像素
{
// 設定shader參數
g_pConstantBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pConstData );
pConstData->m_wvp_matrix = ident_matrix;
pConstData->m_color.Set(0,1,0,1);
g_pConstantBuffer->Unmap();
// 畫出看板
g_pDevice->OMSetDepthStencilState(g_pZStencil_Test, 1);
g_pDevice->Draw(4, 0);
}
// 用藍色標示出更新2次的像素
{
// 設定shader參數
g_pConstantBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pConstData );
pConstData->m_wvp_matrix = ident_matrix;
pConstData->m_color.Set(0,0,1,1);
g_pConstantBuffer->Unmap();
// 畫出看板
g_pDevice->OMSetDepthStencilState(g_pZStencil_Test, 2);
g_pDevice->Draw(4, 0);
}
// 用紅色標示出更新3次的像素
{
// 設定shader參數
g_pConstantBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pConstData );
pConstData->m_wvp_matrix = ident_matrix;
pConstData->m_color.Set(1,0,0,1);
g_pConstantBuffer->Unmap();
// 畫出看板
g_pDevice->OMSetDepthStencilState(g_pZStencil_Test, 3);
g_pDevice->Draw(4, 0);
}
// 用白色標示出更新超過3次的像素
{
// 設定shader參數
g_pConstantBuffer->Map( D3D10_MAP_WRITE_DISCARD, NULL, (void **) &pConstData );
pConstData->m_wvp_matrix = ident_matrix;
pConstData->m_color.Set(1,1,1,1);
g_pConstantBuffer->Unmap();
// 畫出看板
g_pDevice->OMSetDepthStencilState(g_pZStencil_Less, 3);
g_pDevice->Draw(4, 0);
}
// 等待硬體掃結束, 然後才更新畫面.
pSwapChain->Present(1, 0);
//.........这里部分代码省略.........