Skip to content

Commit

Permalink
fix DrawRangeElementsBaseVertex (#2187)
Browse files Browse the repository at this point in the history
* fix DrawRangeElementsBaseVertex

* fix DrawRangeElements
  • Loading branch information
nkast authored Jan 13, 2025
1 parent 47269b5 commit 69523a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Platforms/Graphics/.GL/ConcreteGraphicsCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ internal sealed class ConcreteGraphicsCapabilities : GraphicsCapabilities
/// </summary>
internal bool SupportsFramebufferObjectIMG { get; private set; }

internal bool SupportsBaseVertex { get; private set; }
internal bool SupportsDrawRangeElements { get; private set; }

private int _maxDrawBuffers;

internal int MaxDrawBuffers { get { return _maxDrawBuffers; } }
Expand Down Expand Up @@ -163,6 +166,10 @@ internal void PlatformInitialize(ConcreteGraphicsContextGL cgraphicsContext, Gra
SupportsSeparateBlendStates = version >= new GLVersion(4,0) || GL.Extensions.Contains("GL_ARB_draw_buffers_blend");
#endif

SupportsBaseVertex = version >= new GLVersion(3,2) || GL.Extensions.Contains("GL_ARB_framebuffer_object");
SupportsDrawRangeElements = (GL.BoundApi == OGL.RenderApi.GL && version >= new GLVersion(2, 0))
|| (GL.BoundApi == OGL.RenderApi.ES && version >= new GLVersion(3, 0));

GL.GetInteger(GetParamName.MaxDrawBuffers, out _maxDrawBuffers);
GL.CheckGLError();
}
Expand Down
4 changes: 2 additions & 2 deletions Platforms/Graphics/.GL/ConcreteGraphicsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ public override void DrawIndexedPrimitives(PrimitiveType primitiveType, int base
int indexElementCount = GraphicsContextStrategy.GetElementCountArray(primitiveType, primitiveCount);
GLPrimitiveType target = ConcreteGraphicsContext.PrimitiveTypeGL(primitiveType);

if (baseVertex > 0 && GL.DrawRangeElementsBaseVertex != null)
if (baseVertex > 0 && ((ConcreteGraphicsCapabilities)this.Capabilities).SupportsBaseVertex)
{
PlatformApplyVertexBuffers(0);

Expand All @@ -890,7 +890,7 @@ public override void DrawIndexedPrimitives(PrimitiveType primitiveType, int base
baseVertex);
GL.CheckGLError();
}
else if (GL.DrawRangeElements != null)
else if (((ConcreteGraphicsCapabilities)this.Capabilities).SupportsDrawRangeElements)
{
PlatformApplyVertexBuffers(baseVertex);

Expand Down

0 comments on commit 69523a0

Please sign in to comment.