Sign in to follow this  

VBO is corrupted?

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

I am having a bit of a problem with my VBOs from what I can tell. I have a class that is for terrain and with a constructor I setup the data for 129x129 map and works fine. Now I change the size and with in the deconstructor I call delete and clean out the GL buffers for textures and VBOs. I then rinse wash repeat for 513x513 and then my mesh is rendered all messed up. Now here is the kicker, if I take out the GL buffer deletes in the deconstructor never happens! and if I start with a 513x513 map size first and go to a smaller one it doesn't happen, but does show up once I go back to 513x513 from a 129x129 map size if I use the GL buffer deletes??? I have clue why this would be and not even sure how to start debugging this.

Share this post


Link to post
Share on other sites
It depends on your code.

Personally, I would never put gl code in a C++ destructor.
I make my own member function and call that if I want to delete some GL resource.
Then I kill the GL RC.

Share this post


Link to post
Share on other sites
I don't have a solution for you but why 129x129 and 513x513? Why non-power of 2? I've personally never seen this before. Also the cleanup code in the destructor should be fine if it's correct, obviously.

Share this post


Link to post
Share on other sites
Run the program through the debugger and step through a few frames. Obviously, something doesn't get initialized properly in the constructor, or doesn't get destroyed properly in the destructor (or a combination). Or it gets initialized in the wrong order or....

Step through it line by line in the debugger and see what happens when and why.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike2343
I don't have a solution for you but why 129x129 and 513x513? Why non-power of 2? I've personally never seen this before. Also the cleanup code in the destructor should be fine if it's correct, obviously.


Why well think about it, if you have 8x8 how many polygons do you have? 7 polygons, now if you add one 9x9 you have 8 polygons wide and high. I want POT amount of polygons not odd numbers.

Quote:
Personally, I would never put gl code in a C++ destructor.

Why not? this way you have a clean design and one that will be called when it should be called when the object is destroyed.

I figured it out all my code is correct, I was using a global struct for my map data, and called it in my GUI code to get mapdata to display minimaps and then that data was updated with new data, but when the deconstructor was called it had incorrect x,y values... Wow what a headache that was. I knew my GL code was correct, just a bad design mistake.

Thanks all.

Share this post


Link to post
Share on other sites

This topic is 3845 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.

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