本文整理汇总了C++中CGUIShaderDX::GetView方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIShaderDX::GetView方法的具体用法?C++ CGUIShaderDX::GetView怎么用?C++ CGUIShaderDX::GetView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIShaderDX
的用法示例。
在下文中一共展示了CGUIShaderDX::GetView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void COverlayQuadsDX::Render(SRenderState &state)
{
if (m_count == 0)
return;
ID3D11DeviceContext* pContext = g_Windowing.Get3D11Context();
CGUIShaderDX* pGUIShader = g_Windowing.GetGUIShader();
XMMATRIX world = pGUIShader->GetWorld();
XMMATRIX view = pGUIShader->GetView();
XMMATRIX proj = pGUIShader->GetProjection();
if (g_graphicsContext.GetStereoMode() == RENDER_STEREO_MODE_SPLIT_HORIZONTAL
|| g_graphicsContext.GetStereoMode() == RENDER_STEREO_MODE_SPLIT_VERTICAL)
{
CRect rect;
g_Windowing.GetViewPort(rect);
g_Windowing.SetCameraPosition(CPoint(rect.Width()*0.5f, rect.Height()*0.5f), rect.Width(), rect.Height());
}
XMMATRIX trans = XMMatrixTranslation(state.x, state.y, 0.0f);
XMMATRIX scale = XMMatrixScaling(state.width, state.height, 1.0f);
pGUIShader->SetWorld(XMMatrixMultiply(XMMatrixMultiply(world, scale), trans));
const unsigned stride = sizeof(Vertex);
const unsigned offset = 0;
ID3D11Buffer* vertexBuffer = m_vertex.Get();
// Set the vertex buffer to active in the input assembler so it can be rendered.
pContext->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset);
// Set the type of primitive that should be rendered from this vertex buffer, in this case triangles.
pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
g_Windowing.SetAlphaBlendEnable(true);
pGUIShader->Begin(SHADER_METHOD_RENDER_FONT);
ID3D11ShaderResourceView* views[] = { m_texture.GetShaderResource() };
pGUIShader->SetShaderViews(1, views);
pGUIShader->Draw(m_count * 6, 0);
// restoring transformation
pGUIShader->SetWorld(world);
pGUIShader->SetView(view);
pGUIShader->SetProjection(proj);
pGUIShader->RestoreBuffers();
}
示例2: LastEnd
void CGUIFontTTFDX::LastEnd()
{
ID3D11DeviceContext* pContext = g_Windowing.Get3D11Context();
if (!pContext)
return;
typedef CGUIFontTTFBase::CTranslatedVertices trans;
bool transIsEmpty = std::all_of(m_vertexTrans.begin(), m_vertexTrans.end(),
[](trans& _) { return _.vertexBuffer->size <= 0; });
// no chars to render
if (m_vertex.empty() && transIsEmpty)
return;
CreateStaticIndexBuffer();
unsigned int offset = 0;
unsigned int stride = sizeof(SVertex);
CGUIShaderDX* pGUIShader = g_Windowing.GetGUIShader();
// Set font texture as shader resource
ID3D11ShaderResourceView* resources[] = { m_speedupTexture->GetShaderResource() };
pGUIShader->SetShaderViews(1, resources);
// Enable alpha blend
g_Windowing.SetAlphaBlendEnable(true);
// Set our static index buffer
pContext->IASetIndexBuffer(m_staticIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
// Set the type of primitive that should be rendered from this vertex buffer, in this case triangles.
pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
if (!m_vertex.empty())
{
// Deal with vertices that had to use software clipping
if (!UpdateDynamicVertexBuffer(&m_vertex[0], m_vertex.size()))
return;
// Set the dynamic vertex buffer to active in the input assembler
pContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);
// Do the actual drawing operation, split into groups of characters no
// larger than the pre-determined size of the element array
size_t size = m_vertex.size() / 4;
for (size_t character = 0; size > character; character += ELEMENT_ARRAY_MAX_CHAR_INDEX)
{
size_t count = size - character;
count = std::min<size_t>(count, ELEMENT_ARRAY_MAX_CHAR_INDEX);
// 6 indices and 4 vertices per character
pGUIShader->DrawIndexed(count * 6, 0, character * 4);
}
}
if (!transIsEmpty)
{
// Deal with the vertices that can be hardware clipped and therefore translated
// Store current GPU transform
XMMATRIX view = pGUIShader->GetView();
// Store current scissor
CRect scissor = g_graphicsContext.StereoCorrection(g_graphicsContext.GetScissors());
for (size_t i = 0; i < m_vertexTrans.size(); i++)
{
// ignore empty buffers
if (m_vertexTrans[i].vertexBuffer->size == 0)
continue;
// Apply the clip rectangle
CRect clip = g_Windowing.ClipRectToScissorRect(m_vertexTrans[i].clip);
// Intersect with current scissors
clip.Intersect(scissor);
// skip empty clip, a little improvement to not render invisible text
if (clip.IsEmpty())
continue;
g_Windowing.SetScissors(clip);
// Apply the translation to the model view matrix
XMMATRIX translation = XMMatrixTranslation(m_vertexTrans[i].translateX, m_vertexTrans[i].translateY, m_vertexTrans[i].translateZ);
pGUIShader->SetView(XMMatrixMultiply(translation, view));
CD3DBuffer* vbuffer = reinterpret_cast<CD3DBuffer*>(m_vertexTrans[i].vertexBuffer->bufferHandle);
// Set the static vertex buffer to active in the input assembler
ID3D11Buffer* buffers[1] = { vbuffer->Get() };
pContext->IASetVertexBuffers(0, 1, buffers, &stride, &offset);
// Do the actual drawing operation, split into groups of characters no
// larger than the pre-determined size of the element array
for (size_t character = 0; m_vertexTrans[i].vertexBuffer->size > character; character += ELEMENT_ARRAY_MAX_CHAR_INDEX)
{
size_t count = m_vertexTrans[i].vertexBuffer->size - character;
count = std::min<size_t>(count, ELEMENT_ARRAY_MAX_CHAR_INDEX);
// 6 indices and 4 vertices per character
pGUIShader->DrawIndexed(count * 6, 0, character * 4);
}
}
// restore scissor
g_Windowing.SetScissors(scissor);
//.........这里部分代码省略.........