Sign in to follow this  
Isura

Managed D3D Sprite Class Problems

Recommended Posts

Isura    122
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
Guest Anonymous Poster   
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
andor    182
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
Isura    122
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this