Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix DrawRangeElementsBaseVertex #2187

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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