aik6980's picture

ES20 application problem, Graphicmode with stencil buffer?

how could I use OpenTK to create ES20 application with stencil buffer?

here is what I use and got error
public Game()
: base (Renderer.PANDORA_SCREEN_WIDTH, Renderer.PANDORA_SCREEN_HEIGHT, new GraphicsMode(16, 8, 8), "Equilibrium", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded)

GraphicsMode: Index: 9, Color: 24 (0888), Depth: 24, Stencil: 8, Samples: 0, Accum: 64 (16161616), Buffers: 2, Stereo: False
IWindowInfo: Windows.WindowInfo: Handle 400008, Parent (Windows.WindowInfo: Handle 8390682, Parent (null))
GraphicsContextFlags: Embedded
error: "EGL window surface not supported" -> something along this line

if I use GraphicsMode(16, 16), the application run fine

application is tested on AMD ES Emulator
any ideas?


Comments

Comment viewing options

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

ok, I got a workaround on this, which I'm not 100% sure this is the correct way to fix this problem
Here I have modified this line

OpenTK\Platform\Egl\EglContext.cs

Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
            if (!Mode.Index.HasValue)
                throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
            // EqFixed: Stencil buffer problem
            //EGLConfig config = new EGLConfig(mode.Index.Value);
            EGLConfig config = new EGLConfig(Mode.Index.Value);

the result show that the supported surface has been created, but

public Game()
: base (Renderer.PANDORA_SCREEN_WIDTH, Renderer.PANDORA_SCREEN_HEIGHT, new GraphicsMode(16, 8, 8), "Equilibrium", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded)

why the final surface config shows

GraphicsMode: Index: 9, Color: 24 (0888), Depth: 24, Stencil: 8, Samples: 0, Accum: 64 (16161616), Buffers: 2, Stereo: False
IWindowInfo: Windows.WindowInfo: Handle 2693780, Parent (Windows.WindowInfo: Handle 597098, Parent (null))
GraphicsContextFlags: Embedded

hmm, the graphic mode doesn't show matched surface, 16-8-8(ES) -> 32-24-8(WGL)??

the Fiddler's picture

There is no guarantee that you will get the exact surface you asked for in the constructor. According to the wgl/glx specs, very few values are treated as exact requirements, with most values being treated as hints by the driver. For example, if you ask for an 8bit depth buffer, the driver might return 16bits, 24bits or even fail (if a depth buffer is not supported).

In this specific case, it is very likely that that a stencil buffer is only supported when using a 24bit depth buffer, so the drivers are returning this combination.

Edit: please file a bug report with your solution, so I don't forget to take a look before the final release!