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 bytes per element for IntBuffer. #71

Merged
merged 1 commit into from Mar 23, 2021

Conversation

Displee
Copy link
Contributor

@Displee Displee commented Mar 23, 2021

This is another critical bug fix. I've been stuck on this for months. My indices (geometry.setIndex) were correct but my model was messed up and I couldn't for the love of God figure out why. I traced it down all the way to the BYTES_PER_ELEMENT of threejs:
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLAttributes.js#L57

else if ( array instanceof Int32Array ) {

			type = gl.INT;

		}
...
return {
			buffer: buffer,
			type: type,
			bytesPerElement: array.BYTES_PER_ELEMENT,
			version: attribute.version
		}

Int32Array.BYTES_PER_ELEMENT = 4

in threekt we use 3 (which is incorrect):

val (type, bytesPerElement) = when (attribute) {
            is IntBufferAttribute -> {
                GL15.glBufferData(bufferType, attribute.buffer, usage)
                GL11.GL_UNSIGNED_INT to 3 // this was the evil-doer
            }
            is FloatBufferAttribute -> {
                GL15.glBufferData(bufferType, attribute.buffer, usage)
                GL11.GL_FLOAT to 4
            }
        }

this also solved the issue I had

@Displee
Copy link
Contributor Author

Displee commented Mar 23, 2021

Btw, do you mind making a new release?

@markaren
Copy link
Owner

Thanks for this, I will check it later today.

Btw, do you mind making a new release?

Github release, maven release or both?

@Displee
Copy link
Contributor Author

Displee commented Mar 23, 2021

A Maven release would be nice. I don't like to use jars xD.

@markaren markaren merged commit 7281e6a into markaren:master Mar 23, 2021
@markaren
Copy link
Owner

Published r1-ALPHA-26 to Bintray.
Bintray is still functional for 1 more month.

@Displee Displee deleted the feature/fix-int-buffer branch January 20, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants