-
Notifications
You must be signed in to change notification settings - Fork 240
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
Vbo utils #8
Vbo utils #8
Conversation
…and (optionally) index buffer
|
||
std::unique_ptr<ShaderProgram> shader; | ||
std::unique_ptr<VertexLayout> layout; | ||
std::unique_ptr<VboMesh> mesh; |
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.
Question: A combination of Mesh, layout and shader represents a style?
And Mesh can have multiple VBOs?
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.
Along with other elements like geometry builders, e.g. how raw geo data is transformed into polys (tessellation for regular polys, construction of polylines, etc.).
Looking nice :) |
|
||
private: | ||
|
||
static std::unordered_map<GLint, GLuint> s_enabledAttribs; // Map from attrib locations to bound shader program |
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.
Why this needs to be static?
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.
Because its purpose is to track the enabled vertex attributes, which are a global GL state. It's used to correctly switch between layouts. Previously bound attributes need to be tracked globally so they can be disabled (if they are not needed) for the next draw call.
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.
Ahh ... Makes sense. Thanks
…e shared across many meshes
cc @patriciogonzalezvivo - check this out and add any comments! |
"}\n"; | ||
|
||
|
||
std::shared_ptr<ShaderProgram> shader (nullptr); |
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.
You do not need to specify a nullptr here. By default since the pointer is pointing to nothing it will have a reference count of 0 and hence doing a get() will return a nullptr.
|
||
} | ||
|
||
void VboMesh::addIndex(GLushort _index) { |
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.
Why not a GLushort* here?
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.
Could make it a pointer for consistency. It's actually less data to pass by value here, but a very small savings and a (probably) rarely used method
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.
Agreed, also as brett mentioned before that these might not be used at all.
Add a VertexLayout class and VboMesh class, then add an example use case to the Tangram test program