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

Vbo utils #8

Merged
merged 14 commits into from
Sep 23, 2014
Merged

Vbo utils #8

merged 14 commits into from
Sep 23, 2014

Conversation

matteblair
Copy link
Member

Add a VertexLayout class and VboMesh class, then add an example use case to the Tangram test program


std::unique_ptr<ShaderProgram> shader;
std::unique_ptr<VertexLayout> layout;
std::unique_ptr<VboMesh> mesh;
Copy link
Member

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?

Copy link
Member

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.).

@bcamper
Copy link
Member

bcamper commented Sep 20, 2014

Looking nice :)


private:

static std::unordered_map<GLint, GLuint> s_enabledAttribs; // Map from attrib locations to bound shader program
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh ... Makes sense. Thanks

@bcamper
Copy link
Member

bcamper commented Sep 22, 2014

cc @patriciogonzalezvivo - check this out and add any comments!

"}\n";


std::shared_ptr<ShaderProgram> shader (nullptr);
Copy link
Member

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) {
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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.

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