This may be a known issue, but I haven't been able to find it
anywhere... and I'm a good googler =o)...
I have this code (directly taken from Microsoft) to draw a simple
sprite:
public Device device=null;
public Microsoft.DirectX.Direct3D.Spr
public Texture tex=null;
public void InitGraphics()
{
PresentParameters p=new PresentParameters();
p.SwapEffect=SwapEffect.Discar
p.Windowed=true;
device=new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProc
sprite=new Sprite(device);
tex=TextureLoader.FromFile(dev
{
device.Clear(ClearFlags.Target
device.BeginScene();
sprite.Begin(SpriteFlags.None)
sprite.Draw2D(tex, Rectangle.Empty, Rectangle.Empty, new
Point(10, 10), Color.Blue);
sprite.End();
device.EndScene();
device.Present();
{
Form1 frm = new Form1();
frm.InitGraphics();
frm.Show();
while (frm.Created)
{
frm.doRender();
Application.DoEvents();
}
doesn't show anywhere... if I run the generated executable, it shows up
fine...
what am I missing
I even tried this in a different IDE(Delphi 2005) with the exact same
results
I'm using
- Windows 2000 SP 4
- Visual Studio 2003
- DirectX 9.0c
- December 2004 update (managed)
thanks in advance

draw sprite doesn't work when inside VS (executable works fine)
frapgn
kiln
[]'s
bbroyles
The December 2004 SDK release was 4 releases ago. Would you upgrade to the June 2005 SDK and let us know if you still have the same problem
P.S. -- You might also want to look at how the newer samples are written. We no longer recommend using the Application.DoEvents-style of rendering.
John Gallardo - MSFT
Have you tried this with the August 2005 SDK that was just released There was an error in the Draw2D method that was just recently fixed.
Tom Waters
I'm very concerned about the PS there. I've been looking through the examples (specifically "EmptyProject" for this new way of doing things, which appears to be to be setting the OnIdle event.
That's not so bad, even if it lacks a simple return value to tell the system to call the event until told otherwise like Borland Delphi has done since forever, but the amount of code in the SDK sample utilities files... talk about code obsfucation!
Shouldn't Microsoft's aim be to make coding easier for programmers The tutorial that uses Application.DoEvents() (which is still in the June 2005 SDK mind you) was extremely easy to understand and use, and while it lacks all the frills and protections offered by the sdk's common utilities, it doesn't scare the pants off beginners.
So then, why are you trying to make life hard for people I'm no beginner, but when I see the mess that is the SDK samples and think that is what you want beginners to think programming directx involves just get a simple window up, it gives me a headache. I've never used MFC for this same reason. I can code assembler with less headahces.
Programming is simple, lets try and keep it that way.
Sergey M
Try adding .ToArgb() to the end of that Draw2D call:
sprite.Draw2D(tex, Rectangle.Empty, Rectangle.Empty, new Point(10, 10), Color.Blue.ToArgb());
which will take you to a different overload that should work.
We are continuing to look into this issue (including the VS/exe differential).
edit: there are a few other issues on this thread, such as undesired behavior from Draw2D generally (regarding placement from rotation); those are separate from the original issue.
blobz
Just as my application starts I get a short glimpse of the offending sprite, seems like the first call to draw2D works while all subsequent ones fail.
Hope you guys fix this in the next version of the SDK.
Prasad Khandekar
I don't have any more problems with it though; calling Draw2D DOES set the Transform on my Sprite object to what I want, and I can just draw the sprite using first Draw2D then Draw to make sure it's rendered in- and outside VS.
mbordoni
Shorin
I'll test with the latest SDK and report back
thanks
birch9397
...at least it wasn't anything I was doing... or not doing
Kailash-Bisht
I have yet to get Sprite.Draw2D to work properly myself. In my case, starting the project executable manually produces the same result: the sprite silently fails to render. I dicovered the problem last week, and yesterday I did a format and reinstall of WinXP, VS 2K3 and the June DirectX SDK, the problem is still there.

This problem only occurs when using one of the oveloads of Draw2D that take a destination rectangle as an argument, the overload below renders the sprite(though not in the way I want it)
Sprite.Draw2D(Texture srcTexture, Point rotationCenter, float rotationAngle, Point position, Color color)
I'm currently using Sprite.Draw as a temporary placeholder, but i want some of my sprites to resize to fill the screen and for that it's easiest to use Draw2D which can take a destination rectangle.
Has anyone succeded in drawing a sprite using one of the Draw2D overloads that take a destination rectangle If so, please post how you did it!
As a side note, there is an error in the documentation for "How do I... " -> "Draw A Sprite".
In the example code a System.Drawing.Point is declared with
new Point(5.0f, 5.0f)
and that's no good