Coder Social home page Coder Social logo

fna-xna / fna Goto Github PK

View Code? Open in Web Editor NEW
2.5K 78.0 258.0 2.74 MB

FNA - Accuracy-focused XNA4 reimplementation for open platforms

Home Page: https://fna-xna.github.io/

Makefile 0.83% C# 96.13% HLSL 3.03%
xna fna csharp gamedev windows macos linux steamos

fna's Introduction

This is FNA, an XNA4 reimplementation that focuses solely on developing a fully
accurate XNA4 runtime for the desktop.

Project Website: https://fna-xna.github.io/

License
-------
FNA is released under the Microsoft Public License. See LICENSE for details.

FNA uses LzxDecoder.cs, released under a dual MSPL/LGPL license.
See lzxdecoder.LICENSE for details.

FNA uses code from the Mono.Xna project, released under the MIT license.
See monoxna.LICENSE for details.

Documentation
-------------
Documentation for FNA can be found on the FNA wiki:

https://github.com/FNA-XNA/FNA/wiki

Found an issue?
---------------
Issues and patches can be reported via GitHub:

https://github.com/FNA-XNA/FNA/issues

fna's People

Contributors

0x0ade avatar bartwe avatar brooksbishop avatar chicken-bones avatar deccer avatar dtaddis avatar enoughtea avatar flibitijibibo avatar harry-cpp avatar jaedan avatar jfmu avatar kg avatar kiates avatar kiddkaffeine avatar mistzzt avatar mklingen avatar moocowtg avatar pprism avatar rds1983 avatar rfht avatar rosalie241 avatar slaweknowy avatar teamtwentythree avatar thatcosmonaut avatar thespydog avatar tomcashman avatar trevorsundberg avatar wardbenjamin avatar ytn0 avatar zanedubya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fna's Issues

Xbox controllers + Win10 Anniversary update

After installing the Win10 Anniversary update, SDL thinks I've got two Xbox One controllers connected when I've only got the one connected. Using FNA 16.07.

Controller 0: XInput Controller
Controller 1: XInput Controller

GamePad.GetState(PlayerIndex.One).IsConnected <== true
GamePad.GetState(PlayerIndex.Two).IsConnected <== true
GamePad.GetState(PlayerIndex.Three).IsConnected <== false
GamePad.GetState(PlayerIndex.Four).IsConnected <== false

Any ideas on what might be the cause of this?

Exception when trying to load compiled XNB from a ResourceContentManager.

Steps to reproduce...

  1. Add a Resource file to project and add some compiled XNB to it "SomeTexture.xnb"

  2. Load the content...
    var rcm = new ResourceContentManager(Services, Resource1.ResourceManager);
    rcm.Load("SomeTexture");

The following exception is thrown...

An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll

Additional information: MemoryStream's internal buffer cannot be accessed.

mscorlib
at System.IO.MemoryStream.GetBuffer()
at Microsoft.Xna.Framework.Content.Texture2DReader.Read(ContentReader reader, Texture2D existingInstance) in C:\Users\paul.cunningham\Source_____Source_____ThirdParty\FNA\src\Content\ContentReaders\Texture2DReader.cs:line 193
at Microsoft.Xna.Framework.Content.ContentTypeReader1.Read(ContentReader input, Object existingInstance) in C:\Users\paul.cunningham\Source\_____Source\_____ThirdParty\FNA\src\Content\ContentTypeReader.cs:line 130 at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance) in C:\Users\paul.cunningham\Source\_____Source\_____ThirdParty\FNA\src\Content\ContentReader.cs:line 339 at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T](T existingInstance) in C:\Users\paul.cunningham\Source\_____Source\_____ThirdParty\FNA\src\Content\ContentReader.cs:line 153 at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]() in C:\Users\paul.cunningham\Source\_____Source\_____ThirdParty\FNA\src\Content\ContentReader.cs:line 141 at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() in C:\Users\paul.cunningham\Source\_____Source\_____ThirdParty\FNA\src\Content\ContentReader.cs:line 276 at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action1 recordDisposableObject) in C:\Users\paul.cunningham\Source_____Source_____ThirdParty\FNA\src\Content\ContentManager.cs:line 341
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) in C:\Users\paul.cunningham\Source_____Source_____ThirdParty\FNA\src\Content\ContentManager.cs:line 214
at FNATest.FNATestGame.LoadContent() in C:\Users\paul.cunningham\Source\Temp\FNATest\FNATest\FNATestGame.cs:line 24
at Microsoft.Xna.Framework.Game.Initialize() in C:\Users\paul.cunningham\Source_____Source_____ThirdParty\FNA\src\Game.cs:line 725
at Microsoft.Xna.Framework.Game.DoInitialize() in C:\Users\paul.cunningham\Source_____Source_____ThirdParty\FNA\src\Game.cs:line 823
at Microsoft.Xna.Framework.Game.Run() in C:\Users\paul.cunningham\Source_____Source_____ThirdParty\FNA\src\Game.cs:line 438
at FNATest.Program.Main(String[] args) in C:\Users\paul.cunningham\Source\Temp\FNATest\FNATest\Program.cs:line 8
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Potential Fix to ResourceContentManager.cs

protected override Stream OpenStream(string assetName)
{
    object obj = this.resource.GetObject(assetName);
    if (obj == null)
    {
        throw new ContentLoadException("Resource not found");
    }
    byte[] byteArrayObject = obj as byte[];
    if (byteArrayObject == null)
    {
        throw new ContentLoadException("Resource is not in binary format");
    }
    return new MemoryStream(byteArrayObject, 0, byteArrayObject.Length, true, true);
}

Crash when loading video on OSX

Hey

I've just been updating everything to the newest version (FNA, MonoKickstart and the libs) and while the windows version is working fine, OSX is crashing.

The Error seems to just be "libtheoraplay.dylib"

Here's the stack trace:

at (wrapper managed-to-native) TheoraPlay:THEORAPLAY_startDecodeFile (string,uint,TheoraPlay/THEORAPLAY_VideoFormat)
at Microsoft.Xna.Framework.Media.Video.Initialize () [0x00000] in :0
at Microsoft.Xna.Framework.Media.Video..ctor (System.String fileName) [0x00000] in :0
at Microsoft.Xna.Framework.Media.Video..ctor (System.String fileName, Int32 durationMS, Int32 width, Int32 height, Single framesPerSecond, VideoSoundtrackType soundtrackType) [0x00000] in :0
at Microsoft.Xna.Framework.Content.VideoReader.Read (Microsoft.Xna.Framework.Content.ContentReader input, Microsoft.Xna.Framework.Media.Video existingInstance) [0x00000] in :0
at Microsoft.Xna.Framework.Content.ContentTypeReader1[Microsoft.Xna.Framework.Media.Video].Read (Microsoft.Xna.Framework.Content.ContentReader input, System.Object existingInstance) [0x00000] in <filename unknown>:0 at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[Video] (Microsoft.Xna.Framework.Media.Video existingInstance) [0x00000] in <filename unknown>:0 at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[Video] (Microsoft.Xna.Framework.Media.Video existingInstance) [0x00000] in <filename unknown>:0 at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[Video] () [0x00000] in <filename unknown>:0 at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[Video] () [0x00000] in <filename unknown>:0 at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[Video] (System.String assetName, System.Action1 recordDisposableObject) [0x00000] in :0
at Microsoft.Xna.Framework.Content.ContentManager.Load[Video](System.String assetName) [0x00000] in :0
at DPII.Sprite.loadVideo (System.String name, System.String location) [0x00000] in :0
at DPII.Sprite.load () [0x00000] in :0
at DPII.Game1.LoadContent () [0x00000] in :0
at Microsoft.Xna.Framework.Game.Initialize () [0x00000] in :0
at DPII.Game1.Initialize () [0x00000] in :0
at Microsoft.Xna.Framework.Game.DoInitialize () [0x00000] in :0
at Microsoft.Xna.Framework.Game.Run () [0x00000] in :0
at DPII.Program.Main (System.String[] args) [0x00000] in :0

I've not tried Linux yet as I nromally get it working on osx first.

AL lib: (EE) alc_cleanup: 1 device not closed

Hello,

When I start (key F5) my project from VisualStudio more than 6 or 7 times this error appears in the output window :

  • AL lib: (EE) alc_cleanup: 1 device not closed
    And my project take 2 ou 3 seconds to close

Before these 6 or 7 times, no message, no delay to exit.
If I quit VisualStudio and restart it, no message and no delay for 6 or 7 times again.

I searched on google, many info about libgdx or minecraft :)
I certainly forgot something.
My project and FNA are compiled in 32 bits.
If I switch to monogame, I don't have this problem (others but not this one). But I don't want to switch to monogame for win/linux/osx.

To exit my project, I call the function Exit() from the FNA class Game

Any idea ? Need more information ? I will try to help.

Thank you in advance,
Have a good day,
-Thierry

ReadBackbuffer GL_INVALID_OPERATION

When calling GraphicsDevice.GetBackBufferData(...) a GL_INVALID_OPERATION error is generated in DebugCallback handler of OpenGLDevice_GL.cs.

The console output for reference is as follows:

GREMEDY_string_marker not supported!
IGLDevice: OpenGLDevice
OpenGL Device: GeForce GTX TITAN X/PCIe/SSE2
OpenGL Driver: 4.5.0 NVIDIA 368.81
OpenGL Vendor: NVIDIA Corporation
MojoShader Profile: glsl120
Using EXT_swap_control_tear VSync!
EXT_swap_control_tear unsupported. Fall back to standard VSync.
GL_INVALID_OPERATION error generated. FBO anti-alias method is not valid for read pixels.
    Source: GL_DEBUG_SOURCE_API_ARB
    Type: GL_DEBUG_TYPE_ERROR_ARB
    Severity: GL_DEBUG_SEVERITY_HIGH_ARB

The method call inside OpenGLDevice.cs which is causing the DebugCallback to be triggered is

glReadPixels(
    x,
    y,
    w,
    h,
    GLenum.GL_RGBA,
    GLenum.GL_UNSIGNED_BYTE,
    data
);

on lines 3062 - 3070.

The cause of this invalid operation seems to occur when multi-sampling is enabled, as per this page https://www.opengl.org/wiki/GL_EXT_framebuffer_multisample you are unable to use glReadPixels to read a multisampled buffer.

I tested it with multisampling disabled and the error does not occur.

I am happy to help out where I can with any fixes, or further investigation but I was after some feedback from those more knowledgeable than myself.

Thanks in advance for any assistance.

FNAPlatform.CreateWindow

Today, I wanted to use FNA for my game project instead of Monogame and when i run my code with visual studio 2013, i got an exception :

An unhandled exception of type 'System.TypeInitializationException' occurred in FNA.dll

It's refered to the line 290 of Game.cs (in FNA).

I'm on Windows 10.

And that's my game code :

class MyGame : Game
    {
        private static MyGame instance = null;
        private GraphicsDeviceManager graphics;
        private SpriteBatch spriteBatch;

        public static MyGame GetInstance()
        {
            if (instance == null)
                instance = new MyGame();
            return instance;
        }

        private MyGame()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 600;

            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            base.LoadContent();
        }

        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            base.Draw(gameTime);
        }
    }

SDL2 GameWindow and other platform code

Hey Flibit,

I am currently working on my own game framework from scratch, called Flare that has the goal of not only letting developers use (for example) sprites and text rendering as part of the engine but also exposing the raw OpenGL API if they want it.

Right now, I'm in the process of investigating a move to SDL2 rather than OpenTK for input and window handling. May I use your window handling and input bindings from FNA, of course under the appropriate licensing?

~Benjamin Ward

SpriteBatch/Texture2D corruption

A customer just reported this weird graphical bug in Shipwreck:

1xptat0

The top row of images show some missing gaps and the bottom row seems to show us rendering the entire sprite sheet into the image.

I've not been able to reproduce it but here's the info I have from my log:

FNA version: 16.5.5.0
OS: Microsoft Windows NT 5.1.2600 Dodatek Service Pack 3 (Windows XP 32 bit)
OpenGL Device: GeForce 6150SE nForce 430/integrated/SSE2/3DNOW!
OpenGL Driver: 2.1.2
OpenGL Vendor: NVIDIA Corporation
MojoShader Profile: glsl120

Shipwreck loads data from a custom format and uses Texture2D.SetData to create textures. From there we just use normal SpriteBatch with its default shaders to draw everything. We do use a RenderTarget2D to draw the game at its native low resolution before rendering it scaled up to the back buffer.

I've not seen this on any of my operating systems nor have I heard about anyone else having this issue. If there's more I can do to assist, let me know.

Embed FNA in Winforms

Hi,

I have some kind of game editor working with XNA/Winforms, and I wanted to give a try to FNA after some problems with Monogame.
However, I was not able to find any code using a winform, beside the SDL2WindowExample.cs in which I see no link to FNA.
Basically, I would like to embed a Game class to a winform control (picturebox or whatever), with all the loops, loading, drawing, ..., working. Is that possible? If not with Winforms, is it possible with Gtk, Xwt, or even Eto.Forms?

Thank you

Implement MetalDevice

With Vulkan being MUCH harder to implement than Metal, MoltenVK being proprietary, and MojoShader getting Metal shader support, I've started to warm up to this idea a little bit.

That said, this will still be implemented in a very strict manner.

The Metal documentation can be found here:

https://developer.apple.com/metal/

Unlike OpenGL/Vulkan where we can have managed code with dynamically loaded entry points, Metal will have to be a native C (or rather, Objective-C, barf) library that a C# file (the MetalDevice) will reference with various opaque pointers, and testing for support will be as simple as attempting to load the dylib and falling back to OpenGL if it fails. I will NOT be using anything like Xamarin.Mac due to the absurd dependency tree and sheer size of those projects; just using a single native dylib that only links to Metal and hooking that up to an SDL_Window* will be far more pleasant.

The overall process and difficulty of this task will be similar to #11, except it should (in theory) be ever so slightly less difficult to test due to both the simpler API and the smaller range of hardware that supports it. On the note of hardware, one side effect of this IGLDevice is that it would allow for easier support of iOS and tvOS, which would certainly need any performance improvements that Metal can provide.

  • Create libFNAMetal.dylib
    • Create C API for MetalDevice.cs to access
    • Integrate MojoShader MSL output into Metal renderer
  • Create MetalDevice.cs, DllImport FNAMetal
    • If FNAMetal fails to load, fall back to OpenGLDevice

XACT Pitch/Volume Variation does not work with looped sound effects.

Creating an XACT sound effect with pitch and volume variation enabled works ok. But if you make the effect looped, then the pitch/volume is randomized once when you play the cue, and then never again for the subsequent looped plays.

In looking at the code it appears the looping is handled by OpenAL, but the variation only happens with creation of the SoundEffectInstance in CueData.GenerateInstance. That said I don't have my head wrapped around the sound system at this point, so my assumptions could be incorrect.

Not a blocking issue for us, since we can just yank the looping and loop in code, but is an XNA accuracy issue.

2. Download Native Libraries

  • Visual Studio 2015 Community Edition
  • Windows 10 64 Bit

Hi, I'm sorry if this is really obvious but I am struggling with this step.

I've downloaded the native libraries, but what do I actually do with them?

Instinctively I thought I would need to add a reference to them, but I get the a reference to DLL could not be added error message.

Any hints?

Thanks

Latest FNA (head) breaks rendering in Shipwreck

Was just trying to do a simple update to Shipwreck including bumping to the latest FNA, but it seems rendering is totally busted for our game:

fna bug

Got any immediate ideas? I just saw this and haven't yet done any real research; we generally only build against release so I don't have debugger output. I'm going to do some looking into it but wanted to put this on your radar.

If you want to look into it, you should be able to grab the build from Steam and replace the DLL and see this (I would assume). I can also grant you permissions to our Git repo if that helps.

Mojoshader missing variable, and assertion in preShader

Hi,

When initially loading the following file:
shader.txt

it fails to compile the generated glsl because of a missing variable ps_v1, I believe this is caused by the NORMAL0 parameter passed into pixel shader which I think can be fixed by adding the following code:

 else if (usage == MOJOSHADER_USAGE_NORMAL)
 {
     push_output(ctx, &ctx->globals);
     output_line(ctx, "vec4 %s;", var);
     pop_output(ctx);
 } // else if        

at https://github.com/flibitijibibo/MojoShader/blob/master/mojoshader.c#L2731

This change allowed the shader to compile, but when I actually make use of the effect I run into another issue which relates to an assertion failure in the MOJOSHADER_runPreshader
https://github.com/flibitijibibo/MojoShader/blob/master/mojoshader_effects.c#L193
where the final operand is actually of type MOJOSHADER_PRESHADEROPERAND_INPUT.
The last commit to that line is putting in the assertion for OUTPUT only though the previous changeset had a commented out assert which tolerated INPUT or OUTPUT. Should we be allowing INPUT types as the destination?

Audio (SoundEffect and Song) on Mac Failing

Everything tested with a fresh pull from the FNA repo. I am running into some audio playback issues and can't seem to figure out what the issue might be. Everything works on Windows but on Mac I am getting some errors and I was hoping you can point me in the right direction to get these fixed up.

SoundEffect

Both a raw wav file and a wav packed into an xnb with XNA were tested. The results are the same either way.

var sound = contentManager.Load<SoundEffect>( "audio/secret" );
sound.Play();

The above two lines result in the following stacktrace:

ARB_debug_output not supported!
GREMEDY_string_marker not supported!
IGLDevice: OpenGLDevice
OpenGL Device: Intel(R) Iris(TM) Graphics 6100
OpenGL Driver: 2.1 INTEL-10.14.66
OpenGL Vendor: Intel Inc.
MojoShader Profile: glsl120
Stacktrace:

  at <unknown> <0xffffffff>
  at Microsoft.Xna.Framework.Audio.OpenALDevice/OpenALBuffer..ctor (uint,System.TimeSpan) [0x00009] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/FNAPlatform/OpenALDevice.cs:53
  at Microsoft.Xna.Framework.Audio.OpenALDevice.GenBuffer (byte[],uint,uint,uint,uint,bool,uint) [0x0010b] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/FNAPlatform/OpenALDevice.cs:323
  at Microsoft.Xna.Framework.Audio.AudioDevice.GenBuffer (byte[],uint,uint,uint,uint,bool,uint) [0x00021] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Audio/AudioDevice.cs:166
  at Microsoft.Xna.Framework.Audio.SoundEffect..ctor (string,byte[],uint,uint,uint,uint,bool,uint) [0x00029] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Audio/SoundEffect.cs:190
  at Microsoft.Xna.Framework.Content.SoundEffectReader.Read (Microsoft.Xna.Framework.Content.ContentReader,Microsoft.Xna.Framework.Audio.SoundEffect) [0x00096] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentReaders/SoundEffectReader.cs:78
  at Microsoft.Xna.Framework.Content.ContentTypeReader`1<T_REF>.Read (Microsoft.Xna.Framework.Content.ContentReader,object) [0x00013] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentTypeReader.cs:130
  at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject<T_REF> (T_REF) [0x0004c] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentReader.cs:339
  at Microsoft.Xna.Framework.Content.ContentReader.ReadObject<T_REF> (T_REF) [0x00003] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentReader.cs:153
  at Microsoft.Xna.Framework.Content.ContentReader.ReadObject<T_REF> () [0x0000b] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentReader.cs:141
  at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset<T_REF> () [0x00008] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentReader.cs:276
  at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset<T_REF> (string,System.Action`1<System.IDisposable>) [0x0023a] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentManager.cs:341
  at Microsoft.Xna.Framework.Content.ContentManager.Load<T_REF> (string) [0x00077] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Content/ContentManager.cs:214
  at FNATester.TestScene.initialize () [0x000f1] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNATester/Scenes/TestScene.cs:44
  at Nez.Scene..ctor () [0x000c2] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/Nez-PCL/ECS/Scene.cs:285
  at FNATester.TestScene..ctor () <IL 0x00001, 0x0002b>
  at FNATester.Game1.Initialize () [0x00007] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNATester/Game1.cs:11
  at Microsoft.Xna.Framework.Game.DoInitialize () [0x00036] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Game.cs:850
  at Microsoft.Xna.Framework.Game.Run () [0x00014] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNA/src/Game.cs:446
  at FNATester.Program.RunGame () [0x00010] in /Users/desaro/Documents/dev/MonoGame/Nez.FNA.Branch/FNATester/Program.cs:28

Song

Songs seem to be having a wholly different issue related to dylib loading.

Code used:

var song = contentManager.Load<Song>( "audio/CromaticMinor.ogg" );
MediaPlayer.Play( song );

Stacktrace:

ARB_debug_output not supported!
GREMEDY_string_marker not supported!
IGLDevice: OpenGLDevice
OpenGL Device: Intel(R) Iris(TM) Graphics 6100
OpenGL Driver: 2.1 INTEL-10.14.66
OpenGL Vendor: Intel Inc.
MojoShader Profile: glsl120
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libvorbisfile.3.dylib
  at (wrapper managed-to-native) Vorbisfile:INTERNAL_ov_fopen (string,intptr)
  at Vorbisfile.ov_fopen (System.String path, System.IntPtr& vf) <0xa33cbd8 + 0x0001f> in <filename unknown>:0 
  at Microsoft.Xna.Framework.Media.Song..ctor (System.String fileName) <0xa33c750 + 0x0009b> in <filename unknown>:0 
  at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T] (System.String assetName, System.Action`1 recordDisposableObject) <0x8fcfb78 + 0x008ab> in <filename unknown>:0 
  at Microsoft.Xna.Framework.Content.ContentManager.Load[T] (System.String assetName) <0x8fcf980 + 0x00117> in <filename unknown>:0 
  at FNATester.TestScene.initialize () <0xa335610 + 0x002b7> in <filename unknown>:0 
  at Nez.Scene..ctor () <0xa334000 + 0x00307> in <filename unknown>:0 
  at FNATester.TestScene..ctor () <0xa1bffb8 + 0x00013> in <filename unknown>:0 
  at FNATester.Game1.Initialize () <0x8fcf6c0 + 0x00033> in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game.DoInitialize () <0x82e0960 + 0x000d6> in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game.Run () <0x82e07f0 + 0x00023> in <filename unknown>:0 
  at FNATester.Program.RunGame () <0x703fc0 + 0x0003b> in <filename unknown>:0 
  at FNATester.Program.Main (System.String[] args) <0x703ec8 + 0x0000b> in <filename unknown>:0 
AL lib: (EE) alc_cleanup: 1 device not closed

Note that the output folder contains all the downloaded dylibs including libvorbisfile.3.dylib.

Attaching the audio files tested with in case they are of assistance.
Archive.zip

Program silently crashes after first call to SDL_Init

I'm not sure if this is the best place to ask this, but I've been having some trouble...

So, I was looking into porting one of my old XNA games to FNA. I believe I followed the setup instructions correctly. I placed the downloaded DLLs into the same folder the executable is run from. When I clicked run in VS, the program seemed to run but quit immediately without any errors. I noticed that after I commented out all of my game specific code, the game will run ONLY when I click on the built EXE from the File Explorer (it will show a blank screen with CornFlowerBlue). When I try to run it from VS, I can debug it until it reaches SDL_Init, after which, the program exits with exit code 1080890248 (0x406d1388).

I'm using Visual Studio 2010 Pro on Windows 10. Not sure how to debug this one. Do you have any tips?

Keyboard Up and Down events

Hi,

Firstly great work on this library, it's amazing how simple it has made it shifting an XNA application to multiple platforms.

One difficulty I've come across though is the use of WinForms (and your recommendation not to for cross platform applications) and its usage in our application for accessing all the underlying keyboard events I.e. Getting access to all the key up and key down events (which we use for controlling a gui which uses control, alt, tab etc)

So I've looked into SDL2 and how I could use it to access those keyboard events and because FNA polls the events the only way I can see of accessing those events is to register an event filter using AddEventWatch.

I was wondering whether you thought exposing key up and down events as an extension to the XNA api would be something worthwhile? The other option would be making the underlying SDL event stream available however that would tie FNA to SDL forever as a public api.

Many thanks,
Jeff

XACT memory usage is very high

When streaming with XACT, is it normal for memory usage to go through the roof? Usage jumps 50-60 megabytes PER song that is played - this is in one hit. As soon as cue.Play() and before any audio is actually played, BOOM, goodbye memory.

My game usage is normally 60-70mb. If using the MediaPlayer to play OGG files, this stays the same but with XACT it goes bonkers... Play 10 songs with MediaPlayer and memory usage is the same, play 10 songs with XACT and memory usage is +550mb odd :(

The wave bank is set to streaming and created as follows:
waveBank = New WaveBank(audioEngine, "CDAUDIO.DLC", 0, 4)

I'm at a loss to see what is happening.

Multiple window extension?

I have a C# project that uses Kinect for Windows (the new one) to implement a gesturally controlled audiovisual live looper: http://holofunk.com

This project was originally written with XNA, then ported to the SharpDX Toolkit (an XNA-like layer on top of SharpDX with DirectX 10). Now, with Windows 10, DX10 is dead and gone, and the SharpDX Toolkit is no longer maintained.

Along comes FNA, answer to my prayers! Except: my app creates and renders multiple views in multiple windows (to provide multi-monitor support, whereby a monitor and a projector can be displaying different rendered views of the same performance).

It appears right now that FNA supports only one GameWindow, via the singleton Game.Window property. The SharpDX Toolkit added support for multiple GameWindowRenderers, which my app uses. FNA loses this.

Is it conceivable that I might add an extension to FNA which supports multiple windows? I would be happy to create a pull request with a working example. Also even happier to hear any design feedback or offhand thoughts about this idea.

Thanks very much!
Cheers,
Rob Jellinghaus

Some simple helper methods that exist in MonoGame being implemented would reduce the friction when using both FNA and MonoGame

Before I take the time to make a pull request I wanted to check in and see if this is something you would consider accepting. MonoGame has various little helper methods and some function overloads that if implemented in FNA would make it much easier for folks switching over or using both FNA and MonoGame. These are all small additions like Vector2.ToPoint, Point.ToVector2, SpriteBatch.Begin overloads, VertexPosition class, etc. Nothing groundbreaking or anti-XNA, just some little helpers here and there.

On a related note, there is a small and simple optimization that can be made to GraphicsDevice.SetRenderTarget that avoids 1 or more array allocations every frame. Caching a RenderTargetBinding[] and reusing it is a simple change to avoid all the array allocations.

DotNET Core compatibility.

Is it possible to build FNA with the newly released .NET Core 1.0?

Can we get a project.json file to build it or at least a .NET Core compiled NuGet packaged so that we can import it easily?

Thanks

Additional developer documentation

Hi,

I was wondering if it would be a good idea to add some additional developer level documentation to FNA.

Initially I was thinking it could consist of:

  • Code style
  • Location of the native libraries (for those developing or wanting to try out a bug fix) which people may want to work on.

Code style

This is copied from (flibitijibibo/FNA-MGHistory#147):

  • Tabs: Actual '\t' tabs, NOT SPACES!
  • Blank Lines: NO TRAILING SPACE! Blank lines should be, you know, blank.
  • Characters per line: ~100. When a line gets too long, start splitting it up into multiple lines. The number should only be considered a maximum value; if you find that you're doing a lot of extensive left-to-right reading rather than top-to-bottom, start splitting the lines up.
  • i++/i--: Do i += 1 and i -= 1 instead unless the increment is genuinely being used to its advantage. If it's that painful to do this, consider foreach instead.
  • Do not use var! Use the actual type name!
  • someMethod() rather than someMethod (), someArray[x] rather than someArray [x], etc.
  • (Type) cast rather than (Type)cast.
  • Use braces everywhere! I don't care if the if block is one line, braces! Use them!
  • Single line comments: // This code is derp rather than //this code is derp.
  • Multi-line comments: Use /* */ blocks, rather than multiple lines of //.

Additional

  • Line Endings: Should be Linux style '\n'.

Native Library Sources

Would be interested to know if this seems like a good idea?

Implement Microsoft.Xna.Framework.Input.Touch

This is an issue continued from the old FNA repository: flibitijibibo/FNA-MGHistory#331

@SeanColombo is working on implementing this namespace in FNA, with @angelde98 providing additional data on the side. When this is completed and verified as working accurately, FNA will officially support touch input as XNA 4 did.

The current branch is based on the old history, but this can be dealt with when the patch is complete:

https://github.com/BlueLineGames/FNA/tree/touchsupport

Further Reading:

XNA Docs: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.touch.aspx
XNA4SpecTest: https://github.com/flibitijibibo/XNA4SpecTest

SpriteBatch + Texture2D disposal issue

If you take this example:

Dim tex1 As Texture2D = Texture2D.FromStream(GraphicsDevice, imageStream)
Dim tex2 As Texture2D = Texture2D.FromStream(GraphicsDevice, imageStream2)
tex1.Dispose()
spriteBatch.Begin()
spriteBatch.Draw(tex1, Vector2.Zero, Color.White)
spriteBatch.End()

And run with XNA4 you get this:
An unhandled exception of type 'System.ObjectDisposedException' occurred in Microsoft.Xna.Framework.dll
Additional information: Cannot access a disposed object.

But if you run it with FNA tex2 will draw... No errors, nothing... very odd. I've not modified FNA drawing at all.

DynamicSoundEffectInstance differences between XNA and FNA

So, I was just messing around with DynamicSoundEffectInstance and I grabbed this old sample code which is a very basic synthesizer. The code works perfectly with XNA 4 but with FNA it doesn't produce any audio.

Digging a bit deeper it appears that there is something different about the FNA DynamicSoundEffectInstance.PendingBufferCount. This particular section of code from the Synth class doesnt ever make it through the while loop except the first 2 times it is called.

            while (_instance.PendingBufferCount < 2)
            {
                SubmitBuffer();
            }

Removing the while loop and just submitting buffers every frame gets the audio playing but with a pretty massive delay on the order of 1 - 5 seconds depending on the buffer size.

What are the differences between FNA and MonoGame ?

How does this compare to MG? I am asking this because having two separate project to do the same thing is redundant - in my opinion - unless there are some substantial divergences between the two.

I am going to make a 2D game from scratch and I don't like Unity as my only IDE is Visual Studio and it does not support Visual Basic (unless i do some dark ritual).

The Monolithic Static Analysis Thread

This will act as the monolithic thread for bringing our static analysis warnings down to 0, for ALL possible analyzers. For starters, here are our current reports:

VS 2017: http://fna.flibitijibibo.com/analyze2017.txt

The Utilities/ folder is the only folder that is NOT to be touched. This is because we need to keep MonoGame compatibility for these files in particular. In addition, we will NOT be touching the StockEffects since those came directly from Microsoft, so changing them would only be more inaccurate. Lastly, these reports include messages for third-party libs; you ignore these warnings.

For this task, simply take any task in the report you want (letting us know you're doing so), send me the PR to fix it, and I'll update the report.

Ideally we should be able to properly fix all of these defects, but some are by XNA4's design... for example, Microsoft.Xna.Framework.Input.Touch is a massive namespace, and Gendarme reports this, but we can't change this without breaking XNA4 compatibility. In these situations, add a line to suppress the warning and document why the suppression is needed.

As we get closer to resolving all the warnings I'll be lowering the threshold for warning level and certainty, so expect more defects to show up as the list gets smaller.

If you decide to take a task, please post here and let us know you're working on it. Because we're doing so much work on so much code, we need to be sure we're not conflicting with other branches.

Problem running Exe on a surface

I've got a game created with FNA which is supposed to run on a tablet on a show in about 1,5 months from now. TO that end I bought a Surface tablet running Windows 10.. During my initial test the game ran fine. However one day later (and a couple of windows updates later) it refuses to run.
The windows event viewer reports the following:

Application: Blue.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException
Stack:
at MojoShader.INTERNAL_glBestProfile(MOJOSHADER_glGetProcAddress, IntPtr, MOJOSHADER_malloc, MOJOSHADER_free, IntPtr)
at Microsoft.Xna.Framework.Graphics.OpenGLDevice..ctor(Microsoft.Xna.Framework.Graphics.PresentationParameters)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice..ctor(Microsoft.Xna.Framework.Graphics.GraphicsAdapter, Microsoft.Xna.Framework.Graphics.GraphicsProfile, Microsoft.Xna.Framework.Graphics.PresentationParameters)
at Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.CreateDevice()
at Microsoft.Xna.Framework.GraphicsDeviceManager.get_GraphicsDevice()
at Microsoft.Xna.Framework.Game.get_GraphicsDevice()
at Microsoft.Xna.Framework.GamePlatform.BeforeInitialize()
at Microsoft.Xna.Framework.SDL2_GamePlatform.BeforeInitialize()
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run()
at Blue.Program.Main(System.String[])

And also
Faulting application name: Blue.exe, version: 0.0.0.0, time stamp: 0x5711d6ec
Faulting module name: KERNELBASE.dll, version: 10.0.10240.16766, time stamp: 0x56e8cf1c
Exception code: 0xe0434352
Fault offset: 0x000b40f8
Faulting process id: 0x117c
Faulting application start time: 0x01d19bd0f15f602a
Faulting application path: C:\Users\jd\Documents\blue\Release\Blue.exe
Faulting module path: C:\windows\SYSTEM32\KERNELBASE.dll
Report Id: de4131b9-fb6a-485c-91bb-62dba7ef1229
Faulting package full name:
Faulting package-relative application ID:

I've tried installing VC++ redist. and a DirectX redist. even an XNA redistribution to be on the safe side. But nothing seems to work.
I am at my wits end here. ANy ideas?

OGG playback issues

I've just updated my copy of FNA to 16/07 and have noticed two cases of different behaviour. This is the 1st case...

In an older copy of FNA, Song.FromUri looked like this:

    if (!uri.IsFile)
    {
        throw new InvalidOperationException("Only local file URIs are supported for now");
    }

    return new Song(uri.LocalPath)
    {
        Name = name
    };

Previously, if I passed in a URI created like this `New Uri(PATH)' everything was fine on Windows, OS X and Linux. PATH = a path returned using the IO class.

But 16/07 throws in VorbisFile.cs on line 180 (Object reference not set to an instance of an object.). To get around it, I created a URI that passed the Uri.IsWellFormedUriString check just like FNA does and the same result. No matter what I do, I cannot get it to work on Windows 10...

Aside from replacing the FromUri do you have any ideas?

EDIT: 2nd issue fixed... chalk that up to over-zealous copy and pasting...

Global Mouse State

I'm not sure if this is something that will effect anyone, but with xna it would keep tracking the mouse's position even if it was not on top of the game window allowing it to go into negative values and values larger than the window. FNA seems to stop tracking it if it goes outside of the window meaning that the cursor will be left at the edge at it's last tacked place.

[XACT] Cue looping gaps when not handled by ALDevice

So this is a fun bug. Based on my previous issue I noticed that when OpenAL does the looping, it plays properly. If the variation is detected and the looping is handled by FNA, it's slightly slower than OpenAL. Presumably due to the frame times. I think OpenAL is basically in line with XNA and the FNA looping is slower. Our repro was with a short sound effect, haven't tried longer ones. I'm guessing it's related to frame times and loosing a few ms from when the previous play ends, and our next play is detected and kicked off.

Repro:
Short sound effect (<1s) with infinite looping (Variation not needed, looping handled by OpenAL)
Short sound effect (<1s) with loop count set to 254 (Looping handled by FNA)

Unexpected result from Vector2.Transform(ref Vector2 value, ref Quaternion rotation, out Vector2 result)

Hello!

It seems that method Vector2.Transform(ref Vector2 value, ref Quaternion rotation, out Vector2 result) returns strange results when pitch and roll is involved. In MonoGame it works as expected.

Demo:

var vec2 = new Vector2(10, 20);                                 
var quaternion = Quaternion.CreateFromYawPitchRoll(3.1415f, 1.5707f, 1.5707f);
var matrix = Matrix.CreateFromYawPitchRoll(3.1415f, 1.5707f, 1.5707f);

Vector2 rotatedByQ = Vector2.Transform(vec2, quaternion);
Vector2 rotatedByM = Vector2.Transform(vec2, matrix);

// Next line will throw; rotation by matrix will work as expected, 
// while rotation by quaternion will be different:
Assert.That(rotatedByQ, Is.EqualTo(rotatedByM));

quaternion's matrix is identical to matrix, so Vector2.Transform(vec2, Matrix.CreateFromQuaternion(quaternion)) works as expected. This leaves the only culprit: Vector2.Transform(Vector2, Quaternion) method.

Turning Vector2 into Vector3 and using its Transform works; replacing Vector2.Transform code with MonoGame's one works as well.

I took a peek inside Vector2.Transform, it uses a canonical formula v' = q * v * q^-1, and all quaternion methods look good at least from first glance, so I'm kinda stumped.

Windows 64 Bit Support

In the precompiled libraries that can be downloaded, there is a universal macos, and 32/64 bit support for linux, and 32 bit dlls for windows. Is there a reason 64bit dlls for Windows cannot be used with FNA?

Failure to compile effect

Hi,

I have upgraded to the latest 16.5.5 version and I am getting the following errors occurring when attempting to load an effect file:

GREMEDY_string_marker not supported!
OpenGL Device: Intel(R) HD Graphics 4600    
OpenGL Driver: 4.3.0 - Build 10.18.14.4170
OpenGL Vendor: Intel
MojoShader Profile: glsl120
Using EXT_swap_control_tear VSync!
Using EXT_swap_control_tear VSync!
Error has been generated. GL error GL_INVALID_ENUM
        Source: GL_DEBUG_SOURCE_API_ARB
        Type: GL_DEBUG_TYPE_ERROR_ARB
        Severity: GL_DEBUG_SEVERITY_HIGH_ARB

Unhandled Exception: System.InvalidOperationException: ARB_debug_output found an error.
   at Microsoft.Xna.Framework.Graphics.OpenGLDevice.DebugCallback(GLenum source, GLenum type, UInt32 id, GLenum severity, Int32 length, IntPtr message, IntPtr userParam) 

I presume something is going wrong in the native mojoshader code. Has anyone seen anything like this before? or else I will be stepping through mojoshader :)

Only allowed one SDL_SetEventFilter

Hi,

Code was added recently due to poor Windows event pumping at https://github.com/FNA-XNA/FNA/blob/master/src/SDL2/SDL2_FNAPlatform.cs#L160 which makes use of an SDL_SetEventFilter. However it looks like after googling it, that SDL only supports a single EventFilter (and multiple event watchers) which means its now not possible to intercept the events being polled by the main FNA loop.

I was trying to make use of the EventFilter to catch SDL_EventType.SDL_QUIT and use that to delay the closing so I can put up a prompt for the user to Save before quitting or just to cancel the close. However it clashes with FNAs usage because I am in the unfortunate position of being on Windows and allowing user resizing.

I was wondering if you have any ideas for how this can be handled without changing the FNA code?

Thanks in advance.

Implement VulkanDevice

The Vulkan 1.0 specification has been released:

https://www.khronos.org/vulkan/

The quick reference manual is here:

https://www.khronos.org/registry/vulkan/specs/1.0/refguide/Vulkan-1.0-web.pdf

Example code can be found here:

https://github.com/SaschaWillems/Vulkan/

This will act as a tracker for a possible alternative to the FNA OpenGLDevice that uses Vulkan for graphics driver interaction. There would be a handful of benefits, including a dramatic reduction in CPU overhead (something we desperately need as a C# project) as well as better use of XNA4's GraphicsDevice render state bindings, but the downside is that it requires higher-spec graphics hardware no matter how fast it ends up being. Additionally, this would mean maintaining two separate devices, which means more regression testing for critical graphics changes. Apple does not have native Vulkan support, but MoltenVK should allow us to use it via Metal, similar to our D3D11 support via ANGLE.

A high level overview of the work needed to get a VulkanDevice:

  • Implement a SPIR-V emitter for MojoShader
  • Integrate ARB_gl_spirv into MojoShader
  • Start with a clone of the ModernGLDevice or MetalDevice
  • Port individual pieces of the GLDevice to Vulkan until device is 100% Vulkan
    • If required, create a MOJOSHADER_vk* API

In theory Vulkan should be more compatible with XNA4 than OpenGL, and we may even be able to use XNA4's own limitations to our advantage when wrangling any possible use cases (thereby eliminating overly generic cases typically handled by drivers and further reducing overhead), but part of having explicit control will mean taking in responsibilities previously handled by driver vendors, and the difficulty of such responsibilities should NOT be underestimated.

Build option to separate out primitive objects into a separate assembly

Hey there! Thanks for all the hard work on FNA, I recently discovered it and after spending time studying the source I'm really appreciative that you've done this in an open-source manner.

So one of the persistent issues that I run into when using any of the XNA family of libraries is that I often have a core, logic-only library that doesn't have any dependency on any of the graphics, audio, etc. stuff in the game part of the gizmo. That core library could really use a lot of the primitives in FNA to avoid some gross marshaling back and forth between framework-independent types and the FNA ones. What I'm thinking (and this is something that I'd be willing to take on) is a build option that creates an FNA.Primitives.dll or something that contains those data structures and builds an FNA assembly that depends on it. That primitives library could be used in that kind of corelib (and thus, transitively, in a game server or even a web application that consumes that corelib), while plugging in straight away with a correctly built version of FNA proper.

Thoughts?

Steam Overlay not working on OS X

OS X 10.11.2

Tested with:

  • Rogue Legacy
  • FEZ (tested with Stable and 1.11 [MonoGame] branch)
  • Terraria
  • Dust: An Elysian Tail
  • Apotheon

I'm pretty sure it's not a problem on my side, as the Overlay works in non-FNA games, e.g. Hotline Miami 2, Dustforce, Guacamelee, Team Fortress 2, and Counter-Strike: Global Offensive.

Also tested on the Steam Beta as well as the Steam stable client, occurs with both.

I'm not sure how I can best help you debug this, would you like my Console dumps?

JoyStick Support

As I can see there is no joystick support yet, do I need to add this myself?
Cause I can use GamePad, but no Joystick.
Also there are no usages of SDL_EventType.SDL_JOYDEVICEADDED.

XACT Distance->Volume RPCs require min/max values set

Minor bug related to using XACT RPCs to give volume drop off. In XNA not setting a min/max value causes the adjacent values to be used (As the graphic below shows). In FNA if not within this range the volume is set to zero (Or at least I assume, sound effects are no longer audible).

image

Adding a point at the min/max (Distance 0 and 1000 on this example) seems to resolve this issue.

GraphicsResource leaking reference causing NullReferenceException

Hi,

The situation that occurred was when inside the Game.Update (https://github.com/FNA-XNA/FNA/blob/master/src/Game.cs#L770) method an Effect was created which failed to compile (due to special unsized array 'gl_TexCoord' may have at most 8 elements (10 requested)) in Mojoshader so an InvalidOperationException was thrown (https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/OpenGLDevice.cs#L1799).

This Exception then propagated all the way up to the main method which is coded like this:

using (var game = new ClassWhichExtendsGame())
{
    game.Run():
}

Which then attempted to call Dispose() on the game which result in the following:

NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object
  at Microsoft.Xna.Framework.Graphics.OpenGLDevice.DeleteEffect (IGLEffect effect) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.OpenGLDevice.AddDisposeEffect (IGLEffect effect) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.Effect.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.GraphicsResource.Dispose () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Dispose () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GraphicsDeviceManager.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GraphicsDeviceManager.System.IDisposable.Dispose () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game.Dispose () [0x00000] in <filename unknown>:0 
  at RainbowAppFna.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

The NullReference is caused by the glEffect member of Microsoft.Xna.Framework.Graphics.Effect being passed into https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/OpenGLDevice.cs#L1086 AddDisposedEffect and through to https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/OpenGLDevice.cs#L1811 DeleteEffect which then causes the NullReferenceException.

I think this occurs because when the Effect is constructed it registers itself with the GraphicsDevice (https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/Effect/Effect.cs#L245) with a weak reference before the object is fully constructed.

Then when the construction of the IGLEffect for the glEffect member occurs on the next line (https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/Effect/Effect.cs#L248) the exception is thrown and that member remains null. But because GraphicsDevice continues to have a reference to the object when it loops through during Dispose it sees the uninstantiated object with the null member variables when then cause the NullReferenceException.

As for the solution I figure the following are possibilities:

  1. GraphicResources should register themselves at the last line (but then you risk not correctly disposing of resources which may have been constructed before any failure).
  2. The Dispose method could check for instances being null before calling their Dispose methods.

or it is possible I am incorrectly using the using { ... } block to run the Game window.

community platform?

hi, sorry if this is the wrong place to ask, but I have no clue whereelse I should ask.
I wonder if there's some active FNA community (f.e. irc or some forum) where
people could help each other with their porting problems.
f.e some weeks ago I tried to make a 4.0->FNA port of the older xna3.0 aba game "Mazer Mayhem".
the binary starts, but I must have messed up the shader conversion :)
if that worked it would rock as well to also port his "GearToyGear".
I also gave the xna4.0 port ( https://github.com/Pepsi1x1/XNA-4-Racing-Game-Kit ) of the MS XnaRacingGame a try this weekend. only some minor changes in the code. no idea if it is even possible to build the whole content stuff under linux, so I setup a win7vm to build it there. the FNA linux binary complained about some incompatible xact compression so I rebuilt it without compression. tried with prebuilt mojoshader and mojoshader from git, but the binary segfaults before opening a screen. Am I right that gdb doesn't see xna code?

some community efford to get XNALara working would be nice as well.
Gave it an ugly try and gave the resulting binary the System.Windows.Forms.dll and Accessibility.dll
of my mono install. for whatever reason ;) it didn't work.
I'm sorry if this totally misplaced here and understand if you close the issue.
thank you for your great work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.