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

Buffer2 follow-up refactoring (remove *_buffer classes) #1578

Merged
merged 8 commits into from
Oct 1, 2015

Conversation

mourner
Copy link
Member

@mourner mourner commented Oct 1, 2015

A part of the steps outlined here. Final goal of this PR is removing *_buffer files.

Cleaning up code feels so good after the Buffer2 refactor — everything finally fits into place. Great work @lucaswoj! cc @jfirebaugh

also removes redundant *_buffer tests because they don’t actually test
anything useful after buffer2 refactor.
refactors the code so vertexAttribPointer calls are derived from buffer
configuration rather than hardcoded into either individual buffer
classes or draw code.
@mourner
Copy link
Member Author

mourner commented Oct 1, 2015

This is ready to be merged. I made sure every commit is self-contained and passes tests.
Also, I went for explicit buffer.setAttribPointers method instead of implicitly setting layout in bind — this is easier to manage in code.`

@@ -65,29 +64,19 @@ function Buffer(options) {
}

// Start Buffer1 compatability code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this line now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!


Buffer.prototype = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the same Buffer.prototype.bind = syntax here and add a JSdoc comment


gl.vertexAttribPointer(
shader['a_' + attrib.name], attrib.components, gl[attrib.type.name],
false, this.itemSize, offset + attrib.offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use getOffset instead of manually calculating offset + attrib.offset here. That, or we should drop getOffset entirely. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say drop entirely. Simpler, less code, easier to understand. We can always reintroduce knew flexible methods later when we need them externally.

* @param shader The active WebGL shader
* @param {number} offset The offset of the attrubute data in the currently bound GL buffer.
*/
Buffer.prototype.setAttribPointers = function(gl, shader, offset) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I was going to put this in the bind method but this is better

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.

3 participants