Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have the following classes.

// Basically hots the instance of the Vectorfont & Matrix
internal class Text3D : AManageable
{
  private Text                                _textFont;
  private string                              _textString;
  private Matrix                              _matrix;

  private VectorFont                          _vectorFont;

  public Text3D(GameMainManager pGameMainManager)
    : base(pGameMainManager)
  {

    _vectorFont = MM.DebugFont12;
    TextString = string.Empty;
    Matrix = Matrix.Identity;
  }

  public string TextString
  { 
    set
    {
      _textString = value;
      TextFont = VectorFont.Fill(value);
      TextFont = VectorFont.Extrude(value);
    }
    get { return _textString; }
  }
  public Matrix Matrix { set { _matrix = value; } get { return _matrix; } }
  public Text TextFont { set { _textFont = value; } get { return _textFont; } }
  public VectorFont VectorFont { set { _vectorFont = value; TextString = TextString; } get { return _vectorFont; } }
}

Maybe something in this class is causing the error, but I doubt this.

//This is my state class:

sealed internal class MainMenuState : AMenuState
{

  private List<Text3D>                                  _menuTextList;
  private int                                           _selectedOption;

  internal MainMenuState(GameMainManager pGameMainManager)
    : base(pGameMainManager)
  {
    // init menu
    _menuTextList = new List<Text3D>();
    _menuTextList.Add(new Text3D(MM) { VectorFont = MM.DebugFont24, TextString = "New Game" });
    _menuTextList.Add(new Text3D(MM) { VectorFont = MM.DebugFont24, TextString = "Options" });
    _menuTextList.Add(new Text3D(MM) { VectorFont = MM.DebugFont24, TextString = "Exit" });

    float currPosY = ((float)_menuTextList.Count * _optionHeight) / 2 - _optionHeight / 2;
    for(int i = 0; i < _menuTextList.Count; i++)
    {
      float posX = -_menuTextList[i].TextFont.Width / 2;
      _menuTextList[i].Matrix = Matrix.CreateTranslation(posX, currPosY, 0);
      currPosY -= _optionHeight;
    }
    // end init

    _selectedOption = 0;
  }

  public override void Update(GameTime gameTime)
  {
    // irrelevant
  }

  public override void Draw(GameTime gameTime) // draw method
  {
    MM.Game.GraphicsDevice.Clear(Color.CornflowerBlue);

    MM.TextBatch.ViewProjection = _camera.View * _camera.Projection;
    MM.TextBatch.Begin();

    DrawSelectableList(MM.TextBatch, _menuTextList, _selectedOption);

    MM.TextBatch.End();
  }
}

My main class, initializes the text, posisitions it correctly.

// this is the DrawSelectableList, a method in the base class
protected void DrawSelectableList(TextBatch pTextBatch, List<Text3D> pList, int pSelected)
{
  for(int i = 0; i < pList.Count; i++)
  {
    if(pSelected == i)
    {
      pTextBatch.DrawText(pList[i].TextFont, pList[i].Matrix, Color.Green );
    }
    else
    {
      pTextBatch.DrawText(pList[i].TextFont, pList[i].Matrix, Color.White );
    }
  }
}

When looping for the second time, GraphicsDevice.RasterizerState is set to null when DrawText is executed.

I hope this is enough to reproduce the problem.

EDIT: Blendstate & DepthStencilState are also set to null.

share|improve this question
1  
Can you provide the full Draw() function? If it's too long, please provide an abridged version with all calls to TextBatch, along with any calls you make involving GraphicsDevice. –  Fibericon Sep 12 '12 at 7:55
    
@Fibericon I will when I get off work, don't have the souce code with me at the moment. –  ProgrammerAtWork Sep 12 '12 at 7:57
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.