Jump to content
  • Advertisement
Sign in to follow this  
Kasya

glVertexAttribute - where to enable?

This topic is 3135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!