Jump to content
  • Advertisement
Sign in to follow this  
RanmaruX

Locking vertex buffer crash

This topic is 4896 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'm using a modified version of the CParticleSystem class in the SDK samples. I can declare an array of CParticleSystem and render them all in a loop just fine. If I declare a CParticleSystem using a pointer and "= new" (all data has been initialised successfully), then the program crashes when it comes to: if( FAILED( hr = pVB->Lock( dwBase * sizeof(PointVertex), dwFlush * sizeof(PointVertex), (void**) &pVertices, dwBase ? D3DLOCK_NOOVERWRITE : D3DLOCK_DISCARD ) ) ) { return hr; } I can't work out why it crashes using pointer variables and not when I use arrays. Can anybody suggest what might be causing this? If you need to know anything more, let me know. Thanks in advance - Alex

Share this post


Link to post
Share on other sites
Advertisement
What exactly do you mean by "crash"? does the function just fail, or does your program fail with a segfault/gpf, or are you entering the BSOD wonderland? [smile]

From your fragment of code I can't see anything obviously wrong.

What is the value of hr? Have you checked all of the variables/params - e.g. is pVB valid?

Have you run your program against the debug runtimes - that should give you a big point in the right direction as to what it might not be liking.

hth
Jack

Share this post


Link to post
Share on other sites
The crash is a windows error. The system works fine if I revert back to declaring an array of CParticleSystem instances and looping through them, so from that I could assume that all the data members are valid.

hr is just a HRESULT for error handling, which doesn't appear to be used by the SDK sample.

Share this post


Link to post
Share on other sites
Quote:
Original post by RanmaruX
The crash is a windows error. The system works fine if I revert back to declaring an array of CParticleSystem instances and looping through them, so from that I could assume that all the data members are valid.

Well I'd have to say that it sounds like an invalid pointer somewhere - particularly if you say all you've changed is to make it a dynamic instantiation.

I'd go with putting LOTS of assert() statements into your code and find out where things go wrong. You could also look at the VStudio pointer verification code (I forget what it's called now, but think it's one of the _ctr*() calls).

Quote:
Original post by RanmaruX
hr is just a HRESULT for error handling, which doesn't appear to be used by the SDK sample.

The SDK's often wrap up HRESULT checking with V_RETURN() or V() macros, so you might not see the code directly. What version of the SDK/samples are you using?

If the sample doesn't properly check return values then it's showing bad practice - and doesn't stop you from going in and adding/checking them all [grin]

hth
Jack

Share this post


Link to post
Share on other sites
assert? ctr? The more I learn about C++, the more I discover new things that I don't know about :) This all seems a bit beyond me at the moment, so for now I'll just stick to the working array system I have and maybe come back to these things another time :) I'm just experimenting for the time being.

Thanks for helping!

- Alex

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!