Skip to content

Commit 101b780

Browse files
authored
Merge pull request #288 from Earu/fix/macos
Fix for macos rendering bad frames due to clip planes
2 parents 3b3c04d + a9cc583 commit 101b780

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎Source.ShaderAPI.Gl46/ShaderAPIGl46.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ private unsafe void CreateMatrixStacks() {
260260
uboClipPlanes = glCreateBuffer();
261261
glObjectLabel(GL_BUFFER, uboClipPlanes, "ShaderAPI User Clip Planes UBO");
262262
glNamedBufferData(uboClipPlanes, sizeof(Vector4) * Gl46.HardwareConfig.MAXUSERCLIPPLANES, null, GL_DYNAMIC_DRAW);
263+
for (int i = 0; i < Gl46.HardwareConfig.MAXUSERCLIPPLANES; i++)
264+
UploadNoClipPlane(i);
263265
UniformBufferBindings.Bind(UniformBufferBindingLocation.UserClipPlanes, uboClipPlanes);
264266
}
265267

@@ -3473,10 +3475,18 @@ public void EnableClipPlane(int index, bool bEnable) {
34733475
else {
34743476
UserClipPlaneEnabled &= ~(1 << index);
34753477
glDisable(GL_CLIP_DISTANCE0 + index);
3478+
UploadNoClipPlane(index);
34763479
}
34773480
}
34783481
}
34793482

3483+
private unsafe void UploadNoClipPlane(int index) {
3484+
Vector4 noClip = new(0, 0, 0, 1);
3485+
glNamedBufferSubData(uboClipPlanes, index * sizeof(Vector4), sizeof(Vector4), &noClip);
3486+
UserClipPlaneProj[index] = noClip;
3487+
UserClipPlaneChanged |= 1 << index;
3488+
}
3489+
34803490
public void EnableFastClip(bool enable) {
34813491
throw new NotImplementedException("Incomplete port of IShaderAPI");
34823492
}

0 commit comments

Comments
 (0)