Jump to content
  • Advertisement
Sign in to follow this  
wschuler

[.net] Direct3D.Sprite Help

This topic is 3716 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 trying the following managed DirectX call and it is not drawing the section of the texture that I would expect: <code> DXSprite.Draw2D(pImage.Tex, New System.Drawing.Rectangle(0, 0, 32, 32), New System.Drawing.SizeF(32, 32), New System.Drawing.PointF(16, 16), 0, New System.Drawing.PointF(0, 0), Drawing.Color.White) </code> DXSprite is a Microsoft.DirectX.Direct3D.Sprite class properly bound to a device. Here is what I thought the parameters are and what I filled them with (* is next to parms I think could be wrong). 1. A texture, which it is. * 2. A rectange defined in pixels that outlines the part of the texture to use, which it is. * 3. The size in pixels to use when drawing on the destination buffer, which it is. 4. The pixel coordinates to rotate around, if rotation is specified. I used the center of the image. 5. The rotation angle in radians. 6. The coordinates on destination buffer to draw the texture at. 7. The docs specified using white was the way to go here. What could I be missing? Seems straight forward. Perhaps its something with the device settings?

Share this post


Link to post
Share on other sites
Advertisement
Was is it drawing and what are you expecting it to draw? Because you state it doesn't do what you expect, it's hard for us to imagine what it might be doing if don't you explain what happens.

Toolmaker

Share this post


Link to post
Share on other sites
Thank you for your response, I'll try to be clearer. But its not the easiest thing to explain.

I'd expect it to draw a 32x32 pixels section of the source texture at the destination at a width and height of 32x32 pixels. It appears to be drawing about a 24x24 pixel section of the source texture at a 32x32 pixel width and height at the destination.

So your saying my explanations of the parameters are dead on then? Because the examples I've found have not really conveyed the real meaning for the parameters.

If you want to look at it, I'd be willing to provide a link to the full source code.


Another thing that I notice now: if I draw primitives instead and it works, unless I call sprite.begin and sprite.end it turns everything a dark red color. If I call sprite.begin and sprite.end without the draw primitives call between them it does work.

I guess what I'm really looking for is a good explanation of how to use the sprite class in DirectX. This explanation would include what parameters to send to the .Draw2d routine and the order of calling .begin and .end.

[Edited by - wschuler on June 11, 2008 6:10:35 PM]

Share this post


Link to post
Share on other sites
If I multiple the width and height for the source rectange by 1.5 then its almost right. Its very very close to perfect.. Hope that helps figure out whats going on.

Share this post


Link to post
Share on other sites
I've uploaded the source code to the address below:
https://sourceforge.net/project/showfiles.php?group_id=113730

The problem code is contained in the link "MonsterLib8_Problematic.zip"

it is a Visual Studio 2008 solution and it should open up to a function that shows two calls, one goes to the problematic function that uses sprite and the other draws primitives.

The problem sub is in the MonsterX Project->MX_D3D->DrawSprite2D

Share this post


Link to post
Share on other sites
well, judging from your information, you are using the following overloaded version of Draw2D:

Sprite.Draw2D(Texture,Rectangle,Rectangle,Point,Single,Point,Color)

the problem I see is, you passed the Destination Rectangle as a SizeF, not a Rectangle. I've checked the members of SizeF and, the members are not exactly one-to-one matching with Rectangle... SizeF does not have Left, Right, Top and Bottom, which a Rectangle has. It's likely that Draw2D has mistakenly taken other members of SizeF as those Rectangle parameters and giving you a wrong result?

Share this post


Link to post
Share on other sites
Thank you for your reply, I think I'm heading in the right direction to solving this now.

The MSDN documentation matches what you said, but Visual Studio tells me that no overloaded function matches that. The autocomplete shows it as a sizeF. I have tried forcing it and it won't let me use the parameters. I guess the next thing to try is to update my DirectX???

What it won't take that it should:
<code>
DXSprite.Draw2D(pImage.Tex, _
New System.Drawing.Rectangle(0, 0, pImage.FrameWidth * 1.5, pImage.FrameHeight * 1.5), _
New System.Drawing.Rectangle(0, 0, pImage.FrameWidth, pImage.FrameHeight), _
New System.Drawing.PointF(0, 0), 0, New System.Drawing.PointF(X, Y), Drawing.Color.White)
</code>

Share this post


Link to post
Share on other sites
I've found out older versions of D3d dll have an overload that takes the parameters that you are describing. I have the newer version and from googling it looks like others have issues with it as well. I guess maybe I'll have to stick with drawing primitives, arg ;(


DirectX Version info:
DirectX 9.0c (4.09.0000.0904)

------------------
DirectX Components
------------------
ddraw.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 266240 bytes
ddrawex.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 27136 bytes
dxapi.sys: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 10496 bytes
d3d8.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 1179648 bytes
d3d8d.dll: 5.04.0000.2904 English Final Debug 7/2/2007 12:00:44 1390792 bytes
d3d8thk.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 8192 bytes
d3dref8.dll: 5.04.0000.2904 English Final Debug 7/2/2007 12:00:44 248008 bytes
d3d9.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 1689088 bytes
d3d9d.dll: 9.18.0944.0000 English Final Debug 7/2/2007 12:00:44 3087208 bytes (problem)
d3dref9.dll: 6.00.5300.0000 English Final Retail 7/2/2007 12:00:44 349416 bytes
d3dim.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 436224 bytes
d3dim700.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 825344 bytes
d3dref.dll: 5.04.0000.2904 English Final Debug 7/2/2007 12:00:46 106696 bytes
d3dramp.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 590336 bytes
d3drm.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 350208 bytes
d3dxof.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 47616 bytes
d3dpmesh.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 34816 bytes
dplay.dll: 5.00.2134.0001 English Final Retail 8/4/2004 08:00:00 33040 bytes
dplayx.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 229888 bytes
dpmodemx.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 23552 bytes
dpwsock.dll: 5.00.2134.0001 English Final Retail 8/4/2004 08:00:00 42768 bytes
dpwsockx.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 57344 bytes
dplaysvr.exe: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 30208 bytes
dpnsvr.exe: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 18432 bytes
dpnet.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 375296 bytes
dpnlobby.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 3584 bytes
dpnaddr.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 3584 bytes
dpvoice.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 212480 bytes
dpvsetup.exe: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 83456 bytes
dpvvox.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 116736 bytes
dpvacm.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 21504 bytes
dpnhpast.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 35328 bytes
dpnhupnp.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 60928 bytes
dpserial.dll: 5.00.2134.0001 English Final Retail 8/4/2004 08:00:00 53520 bytes
dinput.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 159232 bytes
dinput8.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 181760 bytes
dinput8d.dll: 5.01.2600.1106 English Final Debug 7/2/2007 12:00:46 359624 bytes
dimap.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 44032 bytes
diactfrm.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 394240 bytes
joy.cpl: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 68608 bytes
gcdef.dll: 5.01.2600.0000 English Final Retail 8/4/2004 08:00:00 76800 bytes
pid.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 35328 bytes
dsound.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 367616 bytes
dsound3d.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 1294336 bytes
dswave.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 19456 bytes
dswaved.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 30920 bytes
dsdmo.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 181760 bytes
dsdmoprp.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 71680 bytes
dmusic.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 104448 bytes
dmusicd.dll: 5.04.0000.2904 English Final Debug 7/2/2007 12:00:46 134344 bytes
dmband.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 28672 bytes
dmbandd.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 41160 bytes
dmcompos.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 61440 bytes
dmcompod.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 73928 bytes
dmime.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 181248 bytes
dmimed.dll: 5.04.0000.2904 English Final Debug 7/2/2007 12:00:46 240328 bytes
dmloader.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 35840 bytes
dmloaded.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 52424 bytes
dmstyle.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 105984 bytes
dmstyled.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 117448 bytes
dmsynth.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 103424 bytes
dmsynthd.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 112840 bytes
dmscript.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 82432 bytes
dmscripd.dll: 5.03.0000.0900 English Final Debug 7/2/2007 12:00:46 115912 bytes
system.dll: 1.01.4322.2407 English Final Retail 12/2/2007 02:36:08 1232896 bytes
Microsoft.DirectX.Direct3D.dll: 9.05.0132.0000 English Final Retail 9/22/2007 20:41:02 473600 bytes
Microsoft.DirectX.Direct3DX.dll: 5.04.0000.3900 English Final Retail 9/22/2007 20:40:59 2676224 bytes
Microsoft.DirectX.Direct3DX.dll: 9.04.0091.0000 English Final Retail 9/22/2007 20:41:00 2846720 bytes
Microsoft.DirectX.Direct3DX.dll: 9.05.0132.0000 English Final Retail 9/22/2007 20:41:00 563712 bytes
Microsoft.DirectX.Direct3DX.dll: 9.06.0168.0000 English Final Retail 9/22/2007 20:41:00 567296 bytes
Microsoft.DirectX.Direct3DX.dll: 9.07.0239.0000 English Final Retail 9/22/2007 20:41:01 576000 bytes
Microsoft.DirectX.Direct3DX.dll: 9.08.0299.0000 English Final Retail 9/22/2007 20:41:01 577024 bytes
Microsoft.DirectX.Direct3DX.dll: 9.09.0376.0000 English Final Retail 9/22/2007 20:41:01 577536 bytes
Microsoft.DirectX.Direct3DX.dll: 9.10.0455.0000 English Final Retail 9/22/2007 20:41:01 577536 bytes
Microsoft.DirectX.Direct3DX.dll: 9.11.0519.0000 English Final Retail 9/22/2007 20:41:01 578560 bytes
Microsoft.DirectX.Direct3DX.dll: 9.12.0589.0000 English Final Retail 9/22/2007 20:41:02 578560 bytes
Microsoft.DirectX.DirectDraw.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:03 145920 bytes
Microsoft.DirectX.DirectInput.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:03 159232 bytes
Microsoft.DirectX.DirectPlay.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:03 364544 bytes
Microsoft.DirectX.DirectSound.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:03 178176 bytes
Microsoft.DirectX.AudioVideoPlayback.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:02 53248 bytes
Microsoft.DirectX.Diagnostics.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:02 12800 bytes
Microsoft.DirectX.dll: 5.04.0000.2904 English Final Retail 9/22/2007 20:41:02 223232 bytes
dx7vb.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 619008 bytes
dx8vb.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 1227264 bytes
dxdiagn.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 2113536 bytes
mfc40.dll: 4.01.0000.6140 English Final Retail 8/4/2004 08:00:00 924432 bytes
mfc42.dll: 6.02.4131.0000 English Final Retail 8/4/2004 08:00:00 1028096 bytes
wsock32.dll: 5.01.2600.2180 English Final Retail 8/4/2004 08:00:00 22528 bytes
amstream.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 70656 bytes
devenum.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 59904 bytes
dxmasf.dll: 6.04.0009.1133 English Final Retail 8/22/2006 05:05:26 498742 bytes
mciqtz32.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 35328 bytes
mpg2splt.ax: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 148992 bytes
msdmo.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 14336 bytes
encapi.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 20480 bytes
qasf.dll: 10.00.0000.3646 English Final Retail 9/22/2004 19:46:02 221184 bytes
qcap.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 192512 bytes
qdv.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 279040 bytes
qdvd.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 385024 bytes
qedit.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 562176 bytes
qedwipes.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 733696 bytes
quartz.dll: 6.05.2600.3367 English Final Retail 5/7/2008 01:18:48 1287680 bytes
strmdll.dll: 4.01.0000.3936 English Final Retail 8/21/2006 10:52:08 246814 bytes
iac25_32.ax: 2.00.0005.0053 English Final Retail 8/4/2004 08:00:00 199680 bytes
ir41_32.ax: 4.51.0016.0003 English Final Retail 8/4/2004 08:00:00 848384 bytes
ir41_qc.dll: 4.30.0062.0001 English Final Retail 9/23/2004 15:55:56 120320 bytes
ir41_qcx.dll: 4.30.0064.0001 English Final Retail 9/23/2004 15:55:56 338432 bytes
ir50_32.dll: 5.2562.0015.0055 English Final Retail 8/4/2004 08:00:00 755200 bytes
ir50_qc.dll: 5.00.0063.0048 English Final Retail 12/20/2002 12:40:58 200192 bytes
ir50_qcx.dll: 5.00.0064.0048 English Final Retail 12/20/2002 12:40:58 183808 bytes
ivfsrc.ax: 5.10.0002.0051 English Final Retail 8/4/2004 08:00:00 154624 bytes
mswebdvd.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 204288 bytes
ks.sys: 5.03.2600.2180 English Final Retail 8/4/2004 00:15:22 140928 bytes
ksproxy.ax: 5.03.2600.2180 English Final Retail 8/4/2004 01:56:58 130048 bytes
ksuser.dll: 5.03.2600.2180 English Final Retail 8/4/2004 01:56:44 4096 bytes
stream.sys: 5.03.2600.2180 English Final Retail 8/4/2004 00:08:04 48640 bytes
mspclock.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:58:40 5376 bytes
mspqm.sys: 5.01.2600.2180 English Final Retail 8/3/2004 23:58:42 4992 bytes
mskssrv.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:58:42 7552 bytes
swenum.sys: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 4352 bytes
mstee.sys: 5.03.2600.2180 English Final Retail 8/3/2004 22:58:40 5504 bytes
ipsink.ax: 5.03.2600.2180 English Final Retail 8/4/2004 00:56:58 16384 bytes
mpeg2data.ax: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 118272 bytes
ndisip.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:10:14 10880 bytes
streamip.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:10:14 15360 bytes
msvidctl.dll: 6.05.2600.2180 English Final Retail 8/4/2004 08:00:00 1428480 bytes
slip.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:10:18 11136 bytes
nabtsfec.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:10:30 85376 bytes
ccdecode.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:10:18 17024 bytes
vbisurf.ax: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 30720 bytes
msyuv.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 17408 bytes
kstvtune.ax: 5.03.2600.2180 English Final Retail 8/4/2004 00:56:58 61952 bytes
ksxbar.ax: 5.03.2600.2180 English Final Retail 8/4/2004 00:56:58 43008 bytes
kswdmcap.ax: 5.03.2600.2180 English Final Retail 8/4/2004 00:56:58 90624 bytes
vfwwdm32.dll: 5.01.2600.2180 English Final Retail 8/4/2004 00:56:48 53760 bytes
wstcodec.sys: 5.03.2600.2180 English Final Retail 8/3/2004 23:10:22 19328 bytes
wstdecod.dll: 5.03.2600.2180 English Final Retail 8/4/2004 08:00:00 50688 bytes




[Edited by - wschuler on June 12, 2008 5:10:20 PM]

Share this post


Link to post
Share on other sites
I'm using March 2008 version of DX SDK, so I think it's still pretty new :)

Anyway, I'm referencing version 1.0.2902.0 of the library (runtime v1.1.4322), just for your information.

Also, I'd use Sprite.Draw() instead of Sprite.Draw2D(), just to get around the rotation bug. Sure it's more tedious since I have to cater for the extra z-components of every vector, but it's also more flexible.

And, finally, I downloaded your zip file to have a look, I noticed a problem, you are using VB.NET, while I'm talking from C# perspective, so we might have some miscommunication (though unlikely...my MSDN documentation shows the VB version of the Draw2D() as accepting 2 Rectangles as well)?

Share this post


Link to post
Share on other sites
Quote:
Original post by geekman1009
I'm using March 2008 version of DX SDK, so I think it's still pretty new :)

Anyway, I'm referencing version 1.0.2902.0 of the library (runtime v1.1.4322), just for your information.
For Microsoft.DirectX.Direct3DX, that would be wrong; the latest version on my system is 1.0.2911.0. (I have June SDK installed, though.)

I don't see anything obviously wrong with your call, though...is it correct if you just use Draw? You're not using rotation or translation, after all.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!