kuma's picture

Stencil buffer difference between Windows OpenGL and Android OpenGL ES 2

my name is Fabio and I have a problem.
With same code I have different result, in Windows work fine but in Android I have the mask inverted.

                GL.StencilFunc(StencilFunction.Never, 1, 1);
                GL.StencilOp(StencilOp.Replace, StencilOp.Replace, StencilOp.Replace);
                GL.ColorMask(false, false, false, false);
                base.OnRender(delta, Transform);
                GL.StencilFunc(StencilFunction.Equal, 1, 1);
                GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);
                GL.ColorMask(true, true, true, true);
            if (_font != null)
                for (int c = 0; c < BufferListIndex.Count; c++)
                    int x = BufferListIndex[c];
                    base.OnRender(delta, Transform.Childs[c]);

ps:the image attached is windows version

Why OpenGL ES 2.0 don't work fine?


Inline Images
Windows version


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

Whats the Vendor/Renderer/Version strings for the Android platform?

You don't set GL.StencilMask anywhere in this code, rather set it to a known value. Also GL ES 2.0 seems to lack GL.StencilClear(), find it's equivalent and set it's initial value too.

kuma's picture

Hi Inertia,

vendor: qualcomm
driver:opengl es 2.0 1566933
render: adreno 205

(I tried also another device with render mali 400 with equal results)

last version of "Mono for android"

I have change first lines code:


but I have equal problems :(

thank you for your help.

Inertia's picture

The imports for StencilMask are ok (and OpenTK actually uses a tool to generate GL bindings to avoid such type errors). The only other idea I have is that you manually select which overload to use (there's int32 and uint32 overloads on all functions to satisfy CLS compliance. Like: StencilMask( (uint)mask );).
If you can rule out GL errors you may have to contact Xamarin or the driver programmers, they can help you.

kuma's picture

I tried the overload methods but I have the same result.

I just signaled this bug to xamarin.

thank you.