diff --git a/src/gl/data/gl_viewpointbuffer.cpp b/src/gl/data/gl_viewpointbuffer.cpp index 7b9039bf3a..611db9e407 100644 --- a/src/gl/data/gl_viewpointbuffer.cpp +++ b/src/gl/data/gl_viewpointbuffer.cpp @@ -41,6 +41,7 @@ GLViewpointBuffer::GLViewpointBuffer() Allocate(); Clear(); mLastMappedIndex = UINT_MAX; + mClipPlaneInfo.Push(0); } GLViewpointBuffer::~GLViewpointBuffer() @@ -121,10 +122,9 @@ int GLViewpointBuffer::Bind(unsigned int index) glBindBufferRange(GL_UNIFORM_BUFFER, VIEWPOINT_BINDINGPOINT, mBufferId, index * mBlockAlign, mBlockAlign); // Update the viewpoint-related clip plane setting. - auto *vp = (HWViewpointUniforms*)(((char*)mBufferPointer) + mUploadIndex * mBlockAlign); if (!(gl.flags & RFL_NO_CLIP_PLANES)) { - if (index > 0 && (vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f)) + if (mClipPlaneInfo[index]) { glEnable(GL_CLIP_DISTANCE0); } @@ -162,6 +162,7 @@ int GLViewpointBuffer::SetViewpoint(HWViewpointUniforms *vp) memcpy(((char*)mBufferPointer) + mUploadIndex * mBlockAlign, vp, sizeof(*vp)); Unmap(); + mClipPlaneInfo.Push(vp->mClipHeightDirection != 0.f || vp->mClipLine.X > -10000000.0f); return Bind(mUploadIndex++); } @@ -169,5 +170,6 @@ void GLViewpointBuffer::Clear() { // Index 0 is reserved for the 2D projection. mUploadIndex = 1; + mClipPlaneInfo.Resize(1); } diff --git a/src/gl/data/gl_viewpointbuffer.h b/src/gl/data/gl_viewpointbuffer.h index 208a42a5d9..3ec1093df5 100644 --- a/src/gl/data/gl_viewpointbuffer.h +++ b/src/gl/data/gl_viewpointbuffer.h @@ -12,6 +12,7 @@ class GLViewpointBuffer unsigned int mLastMappedIndex; unsigned int mByteSize; void * mBufferPointer; + TArray mClipPlaneInfo; unsigned int m2DWidth = ~0u, m2DHeight = ~0u;