Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power of two exception #47

Open
CodeHelix opened this issue May 5, 2012 · 5 comments
Open

Power of two exception #47

CodeHelix opened this issue May 5, 2012 · 5 comments

Comments

@CodeHelix
Copy link

I am getting exception but am unsure what exactly I will need to do to get rid of the exception. Here is the exception:

System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=PressPlay.FFWD
StackTrace:
at PressPlay.FFWD.Texture.CheckPowerOfTwoSize() in C:\Users\dwc2987@msn.com\FFWD-Templates\FFWD\Framework\PressPlay.FFWD\Texture.cs:line 96
at PressPlay.FFWD.Texture.DoLoadAsset(AssetHelper assetHelper) in C:\Users\dwc2987@msn.com\FFWD-Templates\FFWD\Framework\PressPlay.FFWD\Texture.cs:line 78
at PressPlay.FFWD.Asset.LoadAsset(AssetHelper assetHelper) in C:\Users\dwc2987@msn.com\FFWD-Templates\FFWD\Framework\PressPlay.FFWD\Asset.cs:line 28
at PressPlay.FFWD.Application.LoadSceneAssets() in C:\Users\dwc2987@msn.com\FFWD-Templates\FFWD\Framework\PressPlay.FFWD\Application.cs:line 496
at PressPlay.FFWD.Application.Update(GameTime gameTime) in C:\Users\dwc2987@msn.com\FFWD-Templates\FFWD\Framework\PressPlay.FFWD\Application.cs:line 228
at Microsoft.Xna.Framework.Game.Update(GameTime gameTime)
at FFWD.Unity.Tests.Game1.Update(GameTime gameTime) in C:\Users\dwc2987@msn.com\Documents\New folder\XNA\Test\Game1.cs:line 85
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.RunOneFrame()
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(IntPtr 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.RunGame(Boolean useBlockingRun)
at Microsoft.Xna.Framework.Game.Run()
at FFWD.Unity.Tests.Program.Main(String[] args) in C:\Users\dwc2987@msn.com\Documents\New folder\XNA\Test\Program.cs:line 15
InnerException:

@stanleyjoy
Copy link

The power of two exception happens to a texture that is applied to 3D model. The texture must be

  • a power of two meaning the texture must be 128x128 or 256x256 or 512x512 or 1024x1024 or 2048x2048 or 4096x4096 it must not be 1024x512 or any other matches. I had this issue before.
  • the texture(s) must be read/write enabled

I changed the code so that it will read only 1024x1024 or 512x512
Stan

@CodeHelix
Copy link
Author

Thanks. I resized my sprtie sheet and ended up with the same error. So means theres something else causing the exception error besides the sprite sheet.

@stanleyjoy
Copy link

If the size of the sprite sheet is around 1024x1024 try hard coding the condition so that it will respond to only that size of texture.
I tried this once and it worked for me.
stan

@stanleyjoy
Copy link

There is also another problem that you could have overlooked. The position of the texture files in your XNA project must be the same way as it is in Unity.
You can get this issue. If a "tex" does not have a texture defined. Debug and find out if a texture is present in tex.

@fehaar
Copy link
Owner

fehaar commented May 10, 2012

The exception occurs due to a missing null reference check. If there is no texture it fails, so there should be a check for that. I have some new code for it done, but it is mixed up with some other stuff that is not done yet - so it hasn't been posted. Hopefully I can get back to FFWD soon and finish up those parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants