Sign in to follow this  
Kasya

glVertexAttribute - where to enable?

Recommended Posts

Hello, I got a problem about glVertexAttribPointer. I created a Vertex Layout which stores the attributes (which are initialized in shader loading) and enables them. But know I just see that I'll have two Mesh Types: Mutable and Static. Difference between them is that, in the static meshes the bone data is not included. Here is how i activate VertexLayout (DRAFT):
VertexLayout::Bind(uint stride) {

	foreach(attrib in layout) {
		glVertexAttribPointer(attrib->location, attrib->size, attrib->type->glType, GL_FALSE, stride, attrib->size * attrib->type->size);
		glEnableVertexAttribArray(attrib->location);		
	}

}



And Mesh Rendering:
Mesh::Render() {

layout->Bind(sizeof(Vertex));
shader->Bind();
Draw();
shader->Unbind();
layout->Unbind();

}



My question is where to call VertexLayout::Bind function (during Rendering; during Initialization; or glVertexAttribPointer during Initialization and glEnableVertexAttribArray during Rendering)? Thanks, Kasya

Share this post


Link to post
Share on other sites
Keep things enabled for as short time as possible. If you enable things at initialization, for example, you have to be aware that it is enabled all the time, and it may interfere with other things you don't expect.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this