Uses Canvas2D for str_gui_solid_mask material in GUIRenderer.
This was SVN commit r25597.
This commit is contained in:
parent
9e611e11f8
commit
bee5a4b3a6
@ -36,8 +36,8 @@ namespace
|
|||||||
// Array of 2D elements unrolled into 1D array.
|
// Array of 2D elements unrolled into 1D array.
|
||||||
using PlaneArray2D = std::array<float, 8>;
|
using PlaneArray2D = std::array<float, 8>;
|
||||||
|
|
||||||
void DrawTextureImpl(CTexturePtr texture,
|
inline void DrawTextureImpl(CTexturePtr texture,
|
||||||
const PlaneArray2D& vertices, const PlaneArray2D& uvs,
|
const PlaneArray2D& vertices, PlaneArray2D uvs,
|
||||||
const CColor& multiply, const CColor& add)
|
const CColor& multiply, const CColor& add)
|
||||||
{
|
{
|
||||||
CShaderDefines defines;
|
CShaderDefines defines;
|
||||||
@ -47,6 +47,14 @@ void DrawTextureImpl(CTexturePtr texture,
|
|||||||
CShaderProgramPtr shader = tech->GetShader();
|
CShaderProgramPtr shader = tech->GetShader();
|
||||||
|
|
||||||
shader->BindTexture(str_tex, texture);
|
shader->BindTexture(str_tex, texture);
|
||||||
|
for (size_t idx = 0; idx < uvs.size(); idx += 2)
|
||||||
|
{
|
||||||
|
if (texture->GetWidth() > 0.0f)
|
||||||
|
uvs[idx + 0] /= texture->GetWidth();
|
||||||
|
if (texture->GetHeight() > 0.0f)
|
||||||
|
uvs[idx + 1] /= texture->GetHeight();
|
||||||
|
}
|
||||||
|
|
||||||
shader->Uniform(str_transform, GetDefaultGuiMatrix());
|
shader->Uniform(str_transform, GetDefaultGuiMatrix());
|
||||||
shader->Uniform(str_colorAdd, add);
|
shader->Uniform(str_colorAdd, add);
|
||||||
shader->Uniform(str_colorMul, multiply);
|
shader->Uniform(str_colorMul, multiply);
|
||||||
@ -127,17 +135,12 @@ void CCanvas2D::DrawTexture(
|
|||||||
CTexturePtr texture, const CRect& destination, const CRect& source,
|
CTexturePtr texture, const CRect& destination, const CRect& source,
|
||||||
const CColor& multiply, const CColor& add)
|
const CColor& multiply, const CColor& add)
|
||||||
{
|
{
|
||||||
PlaneArray2D uvs = {
|
const PlaneArray2D uvs = {
|
||||||
source.left, source.bottom,
|
source.left, source.bottom,
|
||||||
source.right, source.bottom,
|
source.right, source.bottom,
|
||||||
source.right, source.top,
|
source.right, source.top,
|
||||||
source.left, source.top
|
source.left, source.top
|
||||||
};
|
};
|
||||||
for (size_t idx = 0; idx < uvs.size() / 2; idx += 2)
|
|
||||||
{
|
|
||||||
uvs[idx + 0] /= texture->GetWidth();
|
|
||||||
uvs[idx + 1] /= texture->GetHeight();
|
|
||||||
}
|
|
||||||
const PlaneArray2D vertices = {
|
const PlaneArray2D vertices = {
|
||||||
destination.left, destination.bottom,
|
destination.left, destination.bottom,
|
||||||
destination.right, destination.bottom,
|
destination.right, destination.bottom,
|
||||||
|
@ -243,9 +243,10 @@ void GUIRenderer::UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const
|
|||||||
}
|
}
|
||||||
else if ((*cit)->m_Effects->m_SolidColor != CGUIColor())
|
else if ((*cit)->m_Effects->m_SolidColor != CGUIColor())
|
||||||
{
|
{
|
||||||
Call.m_Shader = g_Renderer.GetShaderManager().LoadEffect(str_gui_solid_mask);
|
|
||||||
Call.m_Material = str_gui_solid_mask;
|
Call.m_Material = str_gui_solid_mask;
|
||||||
Call.m_ShaderColorParameter = (*cit)->m_Effects->m_SolidColor;
|
const CColor color = (*cit)->m_Effects->m_SolidColor;
|
||||||
|
Call.m_ColorAdd = CColor(color.r, color.g, color.b, 0.0f);
|
||||||
|
Call.m_ColorMultiply = CColor(0.0f, 0.0f, 0.0f, color.a);
|
||||||
}
|
}
|
||||||
else /* Slight confusion - why no effects? */
|
else /* Slight confusion - why no effects? */
|
||||||
{
|
{
|
||||||
@ -339,10 +340,10 @@ void GUIRenderer::Draw(DrawCalls& Calls, CCanvas2D& canvas)
|
|||||||
// Iterate through each DrawCall, and execute whatever drawing code is being called
|
// Iterate through each DrawCall, and execute whatever drawing code is being called
|
||||||
for (DrawCalls::const_iterator cit = Calls.begin(); cit != Calls.end(); ++cit)
|
for (DrawCalls::const_iterator cit = Calls.begin(); cit != Calls.end(); ++cit)
|
||||||
{
|
{
|
||||||
if (cit->m_HasTexture && cit->m_Material == str_gui_basic)
|
if (cit->m_HasTexture && (cit->m_Material == str_gui_basic || cit->m_Material == str_gui_solid_mask))
|
||||||
{
|
{
|
||||||
CRect texCoords = cit->ComputeTexCoords();
|
CRect texCoords = cit->ComputeTexCoords().Scale(
|
||||||
texCoords.Scale(cit->m_Texture->GetWidth(), cit->m_Texture->GetHeight());
|
cit->m_Texture->GetWidth(), cit->m_Texture->GetHeight());
|
||||||
|
|
||||||
// Ensure the quad has the correct winding order
|
// Ensure the quad has the correct winding order
|
||||||
CRect rect = cit->m_Vertices;
|
CRect rect = cit->m_Vertices;
|
||||||
|
Loading…
Reference in New Issue
Block a user