   [.net] sprite.draw2D() problems
  I am trying to draw code but I get a weird exception..Quote:System.NullReferenceException was unhandled  Message="Object reference not set to an instance of an object."  Source="SoC"  StackTrace:  at SoC.cDirectX.render() in C:\Documents and Settings\ryan\Desktop\SoC\SoC\cDirectX.cs:line 122  at SoC.cSoCEngine..ctor() in C:\Documents and Settings\ryan\Desktop\SoC\SoC\cSoCEngine.cs:line 19  at SoC.main.Main() in C:\Documents and Settings\ryan\Desktop\SoC\SoC\main.cs:line 18  at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)  at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)  at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()  at System.Threading.ThreadHelper.ThreadStart_Context(Object state)  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  at System.Threading.ThreadHelper.ThreadStart()Code:[C#]  sTiles.Draw2D(tTiles, new Rectangle(32, 32, 32, 32),new SizeF(32,32),  new PointF(0, 0), System.Drawing.Color.White);
  Right, so either your sprite or your texture are null. Likely the sprite I'd guess, since normal d3d can accept null textures without keeling over.   ;  I have my sprite create a new one, with the device as the argiment. I don't know what IntPtr pInterface is, unless thats the window...   private void loadGraphics()   { tTiles = new Texture(_device, "./graphics/tiles.bmp"); sTiles = new Sprite(_device);   };  No, the device should be right. You should be able to look in the little locals/watch debugging window and check which variable is null at the time of the exception (or put a breakpoint there if it's crashing the first time).   ;  I didn't have the texture in the right directory :P. Both Sprite and the Texture are not null, but new exception.Quote:Microsoft.DirectX.Direct3D.InvalidCallException was unhandled  Message="Error in the application."  Source="Microsoft.DirectX"  AdditionalInformation=""  ErrorCode=-2005530516  ErrorString="D3DERR_INVALIDCALL"  StackTrace:  at Microsoft.DirectX.Direct3D.Sprite.Draw2D(Texture texture, Rectangle* pSourceRectangle, SizeF* pDestinationSize, PointF* pCenter, Single rotationAngle, PointF position, Int32 color)  at Microsoft.DirectX.Direct3D.Sprite.Draw2D(Texture texture, Rectangle sourceRect, SizeF destinationSize, PointF rotationCenter, Single rotationAngle, PointF position, Int32 color)  at Microsoft.DirectX.Direct3D.Sprite.Draw2D(Texture texture, Rectangle sourceRect, SizeF destinationSize, PointF position, Color color)  at SoC.cDirectX.render() in C:\Documents and Settings\ryan\Desktop\SoC\SoC\cDirectX.cs:line 122  at SoC.cSoCEngine..ctor() in C:\Documents and Settings\ryan\Desktop\SoC\SoC\cSoCEngine.cs:line 20  at SoC.main.Main() in C:\Documents and Settings\ryan\Desktop\SoC\SoC\main.cs:line 18  at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)  at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)  at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()  at System.Threading.ThreadHelper.ThreadStart_Context(Object state)  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  at System.Threading.ThreadHelper.ThreadStart();  Do you call Device.BeginScene(), Sprite.Begin(SpriteFlags), *Draw here*, Sprite.End() and Device.EndScene()?If not, you'll get the D3D_INVALID_CALL exception. I had this aswell, and it took me a good 15 minutes to realize...Toolmaker   ;  From what i see, your program shouldnt compile. For me, there is no overload for Draw2D:Sprite.Draw2D(Texture,Rectangle,Size,Point,Color);I have been having a problem using Sprite interface, basically i am making a 2D game, i tried using Textured quads and i simply cannot get the alpha to work or the color key, i have tried every possible combination of settings etc. So i decided to use the sprite interface but this has its problems... first, with Sprite.Draw() i cannot set a destination Rectangle size, so it is no good for wat i need. So i will use Draw2D() but this is very odd. When i try to use it, the render is very wierd and everything is in the wrong place... i cannot fix it i have tried all the overloads for this function. Basically, all i need is a blitting function which supports alpha transparency and/or color keying. This is how i got to this post, i was searching for help on google, hopefully i can get some help here... thx!   