pass the glyph size to the shader too
This commit is contained in:
parent
54db2c2c3b
commit
d5d8576d1b
|
@ -14,11 +14,10 @@ cbuffer PixelShaderSettings {
|
|||
float2 Resolution;
|
||||
// Background color as rgba
|
||||
float4 Background;
|
||||
|
||||
float2 GlyphSize;
|
||||
float2 CursorPosition;
|
||||
float2 BufferSize;
|
||||
float foo;
|
||||
float3 bar;
|
||||
};
|
||||
|
||||
// A pixel shader is a program that given a texture coordinate (tex) produces a color.
|
||||
|
@ -33,9 +32,15 @@ float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
|
|||
// Inverts the rgb values (xyz) but don't touch the alpha (w)
|
||||
color.xyz = 1.0 - color.xyz;
|
||||
|
||||
float2 cursorTopLeft = CursorPosition * GlyphSize;
|
||||
float2 cursorBottomRight = (CursorPosition + float2(1, 1)) * GlyphSize;
|
||||
float2 relativeTopLeft = cursorTopLeft / Resolution;
|
||||
float2 relativeBottomRight = cursorBottomRight / Resolution;
|
||||
|
||||
float2 relativeCursorPos = CursorPosition / BufferSize;
|
||||
if (tex.y >= relativeCursorPos.y) {
|
||||
color.xy = CursorPosition / BufferSize;
|
||||
if ((tex.x >= relativeTopLeft.x && tex.x <= relativeBottomRight.x) &&
|
||||
(tex.y >= relativeTopLeft.y && tex.y <= relativeBottomRight.y)) {
|
||||
color.xy = relativeCursorPos;
|
||||
color.z = 0.0;
|
||||
}
|
||||
|
||||
|
|
|
@ -478,9 +478,12 @@ void DxEngine::_ComputePixelShaderSettings() noexcept
|
|||
background.w = _backgroundColor.a;
|
||||
_pixelShaderSettings.Background = background;
|
||||
|
||||
til::size glyphSize{ _fontRenderData->GlyphCell() };
|
||||
_pixelShaderSettings.GlyphSize = XMFLOAT2{ ::base::saturated_cast<float>(glyphSize.width()), ::base::saturated_cast<float>(glyphSize.height()) };
|
||||
_pixelShaderSettings.CursorPosition = XMFLOAT2{ ::base::saturated_cast<float>(_lastCursor.x()), ::base::saturated_cast<float>(_lastCursor.y()) };
|
||||
_pixelShaderSettings.BufferSize = XMFLOAT2{ ::base::saturated_cast<float>(_lastBufferSize.width()), ::base::saturated_cast<float>(_lastBufferSize.height()) };
|
||||
|
||||
|
||||
_d3dDeviceContext->UpdateSubresource(_pixelShaderSettingsBuffer.Get(), 0, nullptr, &_pixelShaderSettings, 0, 0);
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
|
Loading…
Reference in a new issue