Invalid Operation Exception when using DrawUtil.Rect on GUIBitmap
by Michael Malandra · in Torque X 2D · 04/10/2009 (9:14 pm) · 1 replies
Ok, I must be missing something somewhere. In the _BeginRun() method, I create a GUIBitmap and set it as the content control. I then attempt to set the property HasBorder to true. When I do this, the game throws an exception on line 260 of the Util class in the GUI namespace. Here is the entire exception the game throws:
System.InvalidOperationException was unhandled
Message="Both a valid vertex shader and pixel shader (or valid effect) must be set on the device before any draw operations may be performed."
Source="Microsoft.Xna.Framework"
StackTrace:
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyCanDraw(Boolean bUserPrimitives, Boolean bIndexedPrimitives)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, Int32 primitiveCount)
at GarageGames.Torque.GUI.DrawUtil.Rect(Vector2 a, Vector2 b, Color color) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\Util.cs:line 260
at GarageGames.Torque.GUI.DrawUtil.Rect(RectangleF rect, Color color) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\Util.cs:line 281
at StarterGame2D.TEST_SCREEN.UpdateAnimation(Single dt) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Game\TEST_SCREEN.cs:line 42
at StarterGame2D.TEST_SCREEN.OnRender(Vector2 offset, RectangleF updateRect) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Game\TEST_SCREEN.cs:line 48
at GarageGames.Torque.GUI.GUICanvas.OnRender(Vector2 offset, RectangleF updateRect) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\GUICanvas.cs:line 206
at GarageGames.Torque.GUI.GUICanvas.RenderFrame() in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\GUICanvas.cs:line 127
at GarageGames.Torque.XNA.TorqueEngineComponent.Draw(GameTime gameTime) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\XNA\TorqueEngineComponent.cs:line 499
at Microsoft.Xna.Framework.Game.Draw(GameTime gameTime)
at GarageGames.Torque.GameUtil.TorqueGame.Draw(GameTime gameTime) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GameUtil\TorqueGame.cs:line 200
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at StarterGame2D.Game.Main() in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Game\Game.cs:line 46
InnerException:
Also, if I set HasBorder to false and just try to use DrawUtil.Rect on my own, I also get an exception. Is there something wrong with the DrawUtil or am i missing something/some necessary initialization?
System.InvalidOperationException was unhandled
Message="Both a valid vertex shader and pixel shader (or valid effect) must be set on the device before any draw operations may be performed."
Source="Microsoft.Xna.Framework"
StackTrace:
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyCanDraw(Boolean bUserPrimitives, Boolean bIndexedPrimitives)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, Int32 primitiveCount)
at GarageGames.Torque.GUI.DrawUtil.Rect(Vector2 a, Vector2 b, Color color) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\Util.cs:line 260
at GarageGames.Torque.GUI.DrawUtil.Rect(RectangleF rect, Color color) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\Util.cs:line 281
at StarterGame2D.TEST_SCREEN.UpdateAnimation(Single dt) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Game\TEST_SCREEN.cs:line 42
at StarterGame2D.TEST_SCREEN.OnRender(Vector2 offset, RectangleF updateRect) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Game\TEST_SCREEN.cs:line 48
at GarageGames.Torque.GUI.GUICanvas.OnRender(Vector2 offset, RectangleF updateRect) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\GUICanvas.cs:line 206
at GarageGames.Torque.GUI.GUICanvas.RenderFrame() in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GUI\GUICanvas.cs:line 127
at GarageGames.Torque.XNA.TorqueEngineComponent.Draw(GameTime gameTime) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\XNA\TorqueEngineComponent.cs:line 499
at Microsoft.Xna.Framework.Game.Draw(GameTime gameTime)
at GarageGames.Torque.GameUtil.TorqueGame.Draw(GameTime gameTime) in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Torque\GameUtil\TorqueGame.cs:line 200
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at StarterGame2D.Game.Main() in C:\Users\Michael Malandra\Documents\Visual Studio 2005\Projects\GUI_TEST\GUI_TEST\Game\Game.cs:line 46
InnerException:
Also, if I set HasBorder to false and just try to use DrawUtil.Rect on my own, I also get an exception. Is there something wrong with the DrawUtil or am i missing something/some necessary initialization?
Torque Owner Michael Malandra