Im blogging about all the stuff I find broken in my daily work making games using Unity or Unreal, Maya 2011, Modo, Photoshop and more. by the way, I love to hate >:)
Friday, May 11, 2012
2D and 3D content in XNA
Drawing layers of 2D and 3D content in XNA on the Windows Phone.
private void OnDraw(object sender, GameTimerEventArgs e)
{
SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
spriteBatch.Draw(background, mainFrame, Color.White);
elementRenderer.Render();
spriteBatch.Draw(elementRenderer.Texture, Vector2.Zero, Color.White);
spriteBatch.End();
Draw3DContent();
spriteBatch.Begin();
spriteBatch.Draw(cursorImage(), cursorPos, Color.White);
spriteBatch.End();
}
So this is a modified versuion of some code that i came to when drawing 2d stuff and 3d sutff using silverlight and xna for both 2d and 3d elements. The first chunk is going to be a begin and end for the background and some UI elements that are drawn in silverlight. then I have another function that has all of the 3d elements each chunk ending in mesh.Draw();
the last bit is to draw a silverlight cursor using xna sprite stuff since the cursor is animated and has several states.
I wasn't able to find an example of this anywhere so im posting it here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment