Manual controls draw

Dec 29, 2012 at 1:04 PM
Edited Dec 29, 2012 at 1:06 PM

I need to draw components manually (GuiManager is not added to game components).
I have added property to GuiManager to retrieve  guiVisualizer and then tried to call guiManager.GuiVisualizer.Draw(screen) but it throws null-pointer exception. Then i realized that I need to call guiManager.Initialize method (because it is no longer called automatically as gameComponent). So my code is:

 

        GraphicsDeviceManager graphics;

        public static GuiManager gui;
        private Nuclex.Input.InputManager input;

        public GameStateManagementGame()
        {
            //Game thingies
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = true;
            InitializeGraphics();

            TargetElapsedTime = TimeSpan.FromTicks(333333);
  
            //Nuclex thingies
            input = new Nuclex.Input.InputManager(Services, Window.Handle);
            gui = new GuiManager(Services);
            gui.DrawOrder = 1000;

            var capturer = new Nuclex.UserInterface.Input.DefaultInputCapturer(this.input);
            gui.InputCapturer = capturer;
           // Components.Add(gui);
            Components.Add(input);
            gui.Initialize();
        }

but i get this error:The GraphicsDevice must not be null when creating new resources.Parameter name: graphicsDevice
at (public static FlatGuiVisualizer FromResource(....)):
return new FlatGuiVisualizer(contentManager, skinStream); 


Thanks for help.
Jan 17, 2013 at 12:09 PM

I think you should call gui initialize after graphics.initialize() method. so you have to move  gui.Initialize(); to Game.LoadResources or Game.Initialize