mellinoe / veldrid-samples

Sample projects for Veldrid
https://mellinoe.github.io/veldrid-docs/
121 stars 49 forks source link

Android sample does not work #6

Closed taumuon closed 6 years ago

taumuon commented 6 years ago

Hi,

I'm trying to run the TexturedCube.Android sample - running Debug | x86 in the emulator.

I get an exception in VeldridSurfaceView.SurfaceCreated, on GraphicsDevice.CreateOpenGLES() - the exception is: Veldrid.VeldridException: Failed to select a valid EGLConfig: Success

Is there any more info I can give you to try to get this working (I want to get some simple code of my own running on my phone, and it's easier to work off a working simple example).

Thanks, gary

mellinoe commented 6 years ago

Unfortunately, I don't think the Android emulator actually supports OpenGL ES 3.0, which is required for Veldrid to run. The error message is a bit weird ("Success"), but my guess is that it's just not able to create a GLES context in the emulator.

mellinoe commented 6 years ago

Do you have a device you can try it out on?

taumuon commented 6 years ago

Hi, I have a Marshmallow device, so I switched the android version to the Marshmallow sdk for all the projects. On running the texturedcube example on the device, I get a NullReferenceException on: GraphicsDevice = GraphicsDevice.CreateOpenGLES(DeviceOptions, sd);

Thanks, gary

mellinoe commented 6 years ago

@taumuon Sorry to hear that you're hitting an issue. Do you have any more information about where the NullReferenceException is happening, like a stack trace?

taumuon commented 6 years ago

Thanks for the reply, Iv'e got around to debugging again, the stack trace is:

` 0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal C# 0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C# 0x26 in object.01a5fcf4-717b-4664-8bb8-5754b09324a3 C# 0x7 in Veldrid.OpenGLBinding.OpenGLNative.glDebugMessageCallback C# 0x19 in Veldrid.OpenGL.OpenGLGraphicsDevice.EnableDebugCallback C# 0x8 in Veldrid.OpenGL.OpenGLGraphicsDevice.EnableDebugCallback C# 0x6 in Veldrid.OpenGL.OpenGLGraphicsDevice.EnableDebugCallback C# 0x24B in Veldrid.OpenGL.OpenGLGraphicsDevice.Init C# 0x27D in Veldrid.OpenGL.OpenGLGraphicsDevice.InitializeANativeWindow C# 0xB3 in Veldrid.OpenGL.OpenGLGraphicsDevice..ctor C# 0x2 in Veldrid.GraphicsDevice.CreateOpenGLES C#

0x10C in SampleBase.Android.VeldridSurfaceView.SurfaceCreated at D:\git\mellinoe\veldrid-samples-3\src\SampleBase.Android\VeldridSurfaceView.cs:83,17 C# 0x11 in Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_viewSurfaceHolder C# 0x17 in object.01a5fcf4-717b-4664-8bb8-5754b09324a3 C# `

taumuon commented 6 years ago

The device only has opengles version 3.1 - so glDebugMessageCallback probably isn't available (as that's es 3.2 only)? I get an exception running in release too. thanks, gary

mellinoe commented 6 years ago

The debug callback extension (GL_KHR_debug) is reported as available on your system (or at least Veldrid thinks so 😄), so that's why it's attempting to enable the callback. Perhaps that codepath should be more robust against errors. In Release mode, the debug callback shouldn't be enabled. What is the error that happens then?

taumuon commented 6 years ago

Hi, I got the debug version working by setting debug to false on the GraphicsDeviceOptions. I haven't got my device to hand now, to see what was happening in release, but I'm sure it was something I was doing wrong ;-) Thanks again for your help!