-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
also removes redundant *_buffer tests because they don’t actually test anything useful after buffer2 refactor.
9cc8220
to
10fd95c
Compare
10fd95c
to
cfe5950
Compare
refactors the code so vertexAttribPointer calls are derived from buffer configuration rather than hardcoded into either individual buffer classes or draw code.
7adae7a
to
bc05f22
Compare
This is ready to be merged. I made sure every commit is self-contained and passes tests. |
@@ -65,29 +64,19 @@ function Buffer(options) { | |||
} | |||
|
|||
// Start Buffer1 compatability code |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
|
||
Buffer.prototype = { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
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