Vertex shaders can write to gl_PointSize (fixes #1603).

If a shader uses gl_PointSize then it can only be used when drawing points. If a shader doesn't use gl_PointSize then it can't be used when drawing points.

Added 'ConstantPointSize' and 'CurrentDPIScale' built-in shader uniforms.

ConstantPointSize is in DPI-scaled points, whereas gl_PointSize is in pixels, so to get the correct default behaviour a shader needs to do gl_PointSize = ConstantPointSize * CurrentDPIScale
This commit is contained in:
Alex Szpakowski
2021-01-23 13:47:12 -04:00
parent deff795908
commit 694d448e83
13 changed files with 83 additions and 87 deletions
+8 -4
View File
@@ -1138,11 +1138,14 @@ Graphics::BatchedVertexData Graphics::requestBatchedDraw(const BatchedDrawComman
state.standardShaderType = cmd.standardShaderType;
}
if (state.vertexCount == 0 && Shader::isDefaultActive())
Shader::attachDefault(state.standardShaderType);
if (state.vertexCount == 0)
{
if (Shader::isDefaultActive())
Shader::attachDefault(state.standardShaderType);
if (state.vertexCount == 0 && Shader::current != nullptr && cmd.texture != nullptr)
Shader::current->checkMainTexture(cmd.texture);
if (Shader::current != nullptr)
Shader::current->validateDrawState(cmd.primitiveMode, cmd.texture);
}
if (shouldresize)
{
@@ -1350,6 +1353,7 @@ void Graphics::points(const Vector2 *positions, const Colorf *colors, size_t num
cmd.formats[0] = getSinglePositionFormat(is2D);
cmd.formats[1] = CommonFormat::RGBAub;
cmd.vertexCount = (int) numpoints;
cmd.standardShaderType = Shader::STANDARD_POINTS;
BatchedVertexData data = requestBatchedDraw(cmd);