Sign in to follow this  

Sprite.Flush and System.NullReferenceException

This topic is 4595 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 When I do something like this Sprite s = new Sprite. s.Begin(); s.Flush(); s.End(); I get a NullReferenceException because I try to flush when nothing is drawn with the sprite object. But how can I test if I need to call the flush? I must call s.flush in order to have some effect from the ScissorRectangle. How can I check if their are some sprites drawn? kind regards Alexander

Share this post


Link to post
Share on other sites
Quote:
I get a NullReferenceException because I try to flush when nothing is drawn with the sprite object.
I doubt that this is why you are getting you are getting that exception. It is possible but, very unlikely. It is much more likely that one of your objects is null or you are passing a null object into a function against its requirements. If you are sure it is comming from your Flush line than your sprite object is probably null.

Quote:
But how can I test if I need to call the flush?

The buffer should be flushed when you call End() so you may not need to call it at all. The need for a Flush is dependant on the application and there is really no way for DX to internally know about this need.

Quote:
How can I check if their are some sprites drawn?

Keep a count?:

int drawcount = 0;
s.Begin();
...
s.Draw();
drawcount++;
...
s.End();

hope this helps.

Share this post


Link to post
Share on other sites
Okay

I found it, it is a mistake in the sdk.

Sprite s = new Sprite(device);
s.Begin(SpriteFlags.AlphaBlend);// | SpriteFlags.SortDepthBackToFront);
s.Flush();
s.End();

No exception.

Switch on the Sorting flag ==> exception.

Where can I post such errors?

kind regards

Alexander

Share this post


Link to post
Share on other sites

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