Is it normal to add SDL2.dll to a basic MonoGame Openg GL project (Xamarin)?

Hi there,
I’m new to mono(game). After several re-installations, adding and removing packages in my Xamarin test project, reading many websites, threads, logs, … I found out by trial and error that I need to add SDL2.dll close the my .exe file.
Is that normal? Or does Xamarin add this by default? Will this copy-paste-into have an influence on crossplatform capability?

(history: old thread )

I don’t have an answer for you but understand the problem. Saw InfinitespaceStudio’s tweet the other day;

Spent the weekend working on stuff for the @MonoGameTeam 3.5 Release. Trying to make the setup process easier for dev’s. #indiedev #monogame

which gave me hope!

Been using Monogame 3.2 for quite a while and was not without problems but ended up building it all from Scratch and since then haven’t had any issues.

Recently decided to try out some new things so installed Xamarin Studio and nuget 3.4 packages. Built default WIndowsDX project and ran it and hey presto the cornflower blue screen. Brilliant I thought. Made a couple of small changes…bang SharpDX exception. Hmm let’s try OpenGL…default project…unable to load SDL.dll…ok Xamarin Studio is new to me so let’s try Visual Studio. Default DX project gives cornflower blue screen then small changes and SharpDX exception.

So the SharpDX exceptions have to be due to my changes but a “quick try out of new things” is going to be anything but and I know I’m going to have to devote a lot more time than anticipated. Why doesn’t a default template work out the box? Once things are sorted then it really is great but getting that initial “foot in the door” is still proving painful.

For the desktop platfoms using OpenGL, SDL2.dll is indeed used by MonoGame. OpenTK uses SDL2 at this stage to provide the cross-platform windowing and input.

@procd, could you describe the small changes and some more detail on the SharpDX exception you saw? That shouldn’t happen, so we’d like to fix it or explain why it happened.

Ok, wanted to look at drawing primitives so copied the LineBatch class from Farseer and get the exception;

SharpDX.SharpDXException was unhandled
Message=HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.

at SharpDX.Result.CheckError()
at SharpDX.Direct3D11.Device.CreateSamplerState(SamplerStateDescription& samplerDescRef, SamplerState samplerStateOut)
at SharpDX.Direct3D11.SamplerState…ctor(Device device, SamplerStateDescription description)
at Microsoft.Xna.Framework.Graphics.SamplerState.GetState(GraphicsDevice device)
at Microsoft.Xna.Framework.Graphics.SamplerStateCollection.PlatformSetSamplers(GraphicsDevice device)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.ApplyState(Boolean applyShaders)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawUserPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, VertexDeclaration vertexDeclaration, Int32 vertexCount)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, Int32 primitiveCount, VertexDeclaration vertexDeclaration)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives[T](PrimitiveType primitiveType, T[] vertexData, Int32 vertexOffset, Int32 primitiveCount)
at LineBatch.LineBatch.Flush() in c:\users\admin\documents\visual studio 2010\Projects\LineBatch\LineBatch\LineBatch.cs:line 118
at LineBatch.LineBatch.End() in c:\users\admin\documents\visual studio 2010\Projects\LineBatch\LineBatch\LineBatch.cs:line 104
at LineBatch.Game1.Draw(GameTime gameTime) in c:\users\admin\documents\visual studio 2010\Projects\LineBatch\LineBatch\Game1.cs:line 95
at Microsoft.Xna.Framework.Game.DoDraw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at MonoGame.Framework.WinFormsGameWindow.RunLoop()
at MonoGame.Framework.WinFormsGamePlatform.RunLoop()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Microsoft.Xna.Framework.Game.Run()
at LineBatch.Program.Main() in c:\users\admin\documents\visual studio 2010\Projects\LineBatch\LineBatch\Program.cs:line 22
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()

It gets hit in the DrawUserPrimitives call here;

` private void Flush()
if (!_hasBegun)
throw new InvalidOperationException(“Begin must be called before Flush can be called.”);

		if (_lineVertsCount >= 2)
			int primitiveCount = _lineVertsCount / 2;
			// submit the draw call to the graphics card
			_device.DrawUserPrimitives(PrimitiveType.LineList, _lineVertices, 0, primitiveCount);
			_lineVertsCount -= primitiveCount * 2;

The Draw that ultimately casues the flush is simply

` protected override void Draw(GameTime gameTime)

        // TODO: Add your drawing code here
        lineBatch.Begin(projection, view);
        lineBatch.DrawLine(new Vector2(10, 10), new Vector2(100, 100));

1 Like