Skip to content

Commit 25a1a1b

Browse files
authored
Fix sampling ratio to make the 'stride' value valid in gl.VertexAttribIPointer calls (#261)
1 parent 97c5aa6 commit 25a1a1b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: main_js.go

+7
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,20 @@ L_MAIN:
716716
samplingRatio := 1
717717
if pe.vi.dragging() {
718718
totalPoints := 0
719+
maxStride := 4
719720
if hasPointCloud && pp.Points > 0 {
720721
totalPoints += pp.Points
722+
maxStride = max(pp.Stride(), maxStride)
721723
}
722724
if hasSubPointCloud && ppSub.Points > 0 && selectMode == selectModeInsert {
723725
totalPoints += ppSub.Points
726+
maxStride = max(ppSub.Stride(), maxStride)
724727
}
725728
samplingRatio = 1 + totalPoints/pe.cmd.NumFastRenderPoints()
729+
// make sure the stride used in gl.VertexAttribIPointer is <= 255
730+
if samplingRatio*maxStride > 255 {
731+
samplingRatio = int(255.0 / maxStride)
732+
}
726733
}
727734

728735
if hasPointCloud && pp.Points > 0 {

0 commit comments

Comments
 (0)