   [.net] C# DirectX error on resizing and close and images not displaying correctly
  Hello.I am having some troubles with my code. The first problem is whenever I resize the application, my sprite.draw2d part of the code errors out with a "NullReferenceException". It seems that the textures get lost when the device gets reset. I am not sure though. On the device resetting, I have set a breakpoint and when I try to set the Device.PresentationParameters.DeviceWindow, I see that the DeviceWindow is null. How do you stop this from happening?Also another error I am having that is probably related, is when I close the application I get an "AccessViolationException". And I am not sure where it happens, but is new when I added the MDX code.The third problem is that some of my images are not displaying in the right position. The weird thing is that some of them display correctly, other dont. They are shifted over by some varying amount. The same code worked with XNA but does not now with C# and DirectX. Also my textures are not a power of two, and resizing them to a power of 2 is not an option. I have heard there is some flag that will allow video cards to not have to use powers of 2 textures, but I cannot find what they are referring to.Any ideas?   
  As far as I know, textures are not lost upon a device reset. I think the problem is that you are forgetting to reset a few things before a you draw your scene again. After a device reset, you need to reset the PresentationParamaters.BackBuffer dimensions to render the scene. If you are creating the DepthStencil manually, you will need to reset that too before drawing again. Remember though, you will not be able to reset these things if your window width or height is 0 or the window is minimized.As for your third problem, you'll need to be more specific.   ;  For the 3rd problem here is what I mean:This is what it is supposed to look like:This is what it looks like:The code is the same to define the size and everything, I just replaced the "SpriteBatch.Draw()" with "Sprite.Draw2D()" and moved the parameters around, but the actual sizing, position and all is the same. I am not sure what is going on. When I break the code in the draw area (immediately before Draw2D), I see the position is correctly stored, I see the scaling factor is correct, and even made temp varaibles that stored the info and verified that the location it was going to draw to and the size it was going to draw to is correct, but once it draws on the screen, it is wrong.And for the resizing, what else do I need to do? I have:  MDX_Device.PresentationParameters.BackBufferWidth = this.Width;  MDX_Device.PresentationParameters.BackBufferHeight = this.Height;and it still errors. This is inside the resize handler of the form and the only thing I have in there right now.   ;  Ok, I changed from using Draw2D() to using Draw() and the problem goes away. This leads me to believe there is a big problem with the Draw2D() code in managed DX as I havent actually changed my code apart from calling a different function and rearranging the input parameters.Now I am trying to find out how to scale/rotate a single texture, not a full sprite.Also, how do I display images with this forums? It always shows up as text, and [img] tags dont work...?   