Jump to content
  • Advertisement
Sign in to follow this  
Isura

Managed D3D Sprite Class Problems

This topic is 4996 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 new to Direct3D (I've used DirectDraw to make several simple games). I'm trying to use the Draw2D() method (in C#) in the Sprite class to display an image. I'm using the exact code in the docs, but nothing seems to show up on the screen. Is it necessary to set up lighting, camera views, vertex buffers, before rendering with Sprite. The docs don't mention anything, and I'm very new to 3D. I haven't been able to find any samples of doing anywhere on the web. Any help appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I'm now able to display sprites using Draw() but Draw2D() doesn't seem to work. The two versions I used have the same signature, don't know what the problem is.

Share this post


Link to post
Share on other sites
You don't have to do anything with lighting, camera views, or vertex buffers to get the Sprite class to work. You can use lighting if you want, but unless your sprites are just so, they won't look right at all with it enabled.

However, the general procedure to getting it to work is as follows:

This assumes that your direct3d device is called d3d, and your Sprite object called sprite.

texture = TextureLoader.fromfile(d3d, filepath) 'load in the sprite
d3d.begin()
sprite.begin()
'In here goes your rendering code
sprite.draw2d(texture, rectangle.empty, rectangle.empty, new point(xScreenLocation, yScreenLocation), Color.White)
sprite.end()
d3d.end()
d3d.present()

Anyhows, this should hopefully help you out a little bit. You'll have to look up the exact syntax for these in C#, but this is more or less how you do it.

Share this post


Link to post
Share on other sites
Thanks, that code works except I have to use Draw instead of Draw2D. I noticed that Draw2D was added in the new release of the SDK, so that might be a bug on some systems.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!