Jump to content
  • Advertisement
Sign in to follow this  
Bow_vernon

OpenGL disable padding for VBO?

This topic is 2613 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

Hi I'm learning to use VBO (again) now, as I never had time to learn on that one. I wonder if I should disable padding in my custom vertex structure for the VBO to work....something like

#include <pshpack1.h>
//blah blah vertex structure
struct MyVert
{
float u1,v1;
float x,y,z;
};
#include <poppack.h>


I know the compiler would pad the structure otherwise, but will the opengl work fine with it? thanks before :D

Share this post


Link to post
Share on other sites
Advertisement
That structure won't contain any padding, and even if a structure contains padding in general, the padding will be beneficial for the VBO as well. Removing the automatic padding costs you unaligned memory accesses, which may be bad for the VBO as well.

Share this post


Link to post
Share on other sites
As always, until you've definitively proven that it's a problem, don't do it. When you're learning something new is not the time to start complicating things by introducing optimizations, even optimizations that are not of dubious benefit. You're introducing too many variable factors, and if something goes wrong you're reducing your chances of being able to fix it (and of understanding what went wrong). Learn VBOs first, learn how to use them properly, then worry about lower level stuff.

Share this post


Link to post
Share on other sites
http://www.opengl.org/wiki/Vertex_Buffer_Object
"ATI suggests that you align your vertex size for 32 bytes, so I added 4 floats to make it 2 * 32 bytes. For nVidia, I think it doesn't matter"

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!