Wednesday, June 02, 2010

XNA: 3D and 2D

Gotta reset settings when mixing 3D and 2D content

http://forums.xna.com/forums/t/48583.aspx

eg.:

// to reset settings for 3D drawing
graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;
graphics.GraphicsDevice.RenderState.AlphaBlendEnable = false;
graphics.GraphicsDevice.RenderState.AlphaTestEnable = false;

DrawModel(gameShip);

spriteBatch.Begin();

// Draw Hello World
string output = "FPS: " + fps;

// Find the center of the string
//Vector2 FontOrigin = Font1.MeasureString(output) / 2;
Vector2 FontOrigin = FontPos;
// Draw the string
//spriteBatch.DrawString(Font1, output, FontPos, Color.LightGreen,
// 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
spriteBatch.DrawString(Font1, output, FontPos, Color.LightGreen);
spriteBatch.End();

No comments: