mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-23 09:21:05 +00:00
* Egl.cs:
* EglContext.cs: * EglGraphicsMode.cs: Added a parameter to indicate which ES renderer version we wish to use. Fixes issue [#2247]: "CreateEGLGraphicsMode should select the correct renderer".
This commit is contained in:
parent
d22c7312d9
commit
774374efc0
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// The Open Toolkit Library License
|
// The Open Toolkit Library License
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
// Copyright (c) 2006 - 2011 the Open Toolkit library.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -41,6 +41,15 @@ namespace OpenTK.Platform.Egl
|
||||||
using EGLSurface = IntPtr;
|
using EGLSurface = IntPtr;
|
||||||
using EGLClientBuffer = IntPtr;
|
using EGLClientBuffer = IntPtr;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
enum RenderableFlags
|
||||||
|
{
|
||||||
|
ES = Egl.OPENGL_ES_BIT,
|
||||||
|
ES2 = Egl.OPENGL_ES2_BIT,
|
||||||
|
GL = Egl.OPENGL_BIT,
|
||||||
|
VG = Egl.OPENVG_BIT,
|
||||||
|
}
|
||||||
|
|
||||||
static partial class Egl
|
static partial class Egl
|
||||||
{
|
{
|
||||||
public const int VERSION_1_0 = 1;
|
public const int VERSION_1_0 = 1;
|
||||||
|
|
|
@ -61,7 +61,13 @@ namespace OpenTK.Platform.Egl
|
||||||
|
|
||||||
WindowInfo = window;
|
WindowInfo = window;
|
||||||
|
|
||||||
Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
|
// Select an EGLConfig that matches the desired mode. We cannot use the 'mode'
|
||||||
|
// parameter directly, since it may have originated on a different system (e.g. GLX)
|
||||||
|
// and it may not support the desired renderer.
|
||||||
|
Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat,
|
||||||
|
mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat,
|
||||||
|
mode.Buffers, mode.Stereo,
|
||||||
|
major > 1 ? RenderableFlags.ES2 : RenderableFlags.ES);
|
||||||
if (!Mode.Index.HasValue)
|
if (!Mode.Index.HasValue)
|
||||||
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
|
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
|
||||||
IntPtr config = Mode.Index.Value;
|
IntPtr config = Mode.Index.Value;
|
||||||
|
|
|
@ -36,20 +36,28 @@ namespace OpenTK.Platform.Egl
|
||||||
{
|
{
|
||||||
#region IGraphicsMode Members
|
#region IGraphicsMode Members
|
||||||
|
|
||||||
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
|
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil,
|
||||||
|
int samples, ColorFormat accum, int buffers, bool stereo)
|
||||||
|
{
|
||||||
|
// According to the EGL specs, the ES flag should select ES 1.0 or higher, which
|
||||||
|
// makes sense as a default. EglContext.cs checks
|
||||||
|
return SelectGraphicsMode(color, depth, stencil, samples, accum, buffers, stereo,
|
||||||
|
RenderableFlags.ES);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Members
|
||||||
|
|
||||||
|
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil,
|
||||||
|
int samples, ColorFormat accum, int buffers, bool stereo,
|
||||||
|
RenderableFlags renderable_flags)
|
||||||
{
|
{
|
||||||
IntPtr[] configs = new IntPtr[1];
|
IntPtr[] configs = new IntPtr[1];
|
||||||
int[] attribList = new int[]
|
int[] attribList = new int[]
|
||||||
{
|
{
|
||||||
//Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
|
//Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
|
||||||
|
Egl.RENDERABLE_TYPE, (int)renderable_flags,
|
||||||
// Context creation will fail unless one of these bits is set. Hopefully, setting all bits will not
|
|
||||||
// cause any ugly side-effects.
|
|
||||||
// If this doesn't work, we'll have to use Egl.GetConfigs and implement our own selection logic,
|
|
||||||
// because we the exact ES version is not known when selecting a graphics context.
|
|
||||||
// (See WinGraphicsMode.cs for an selection logic implementation).
|
|
||||||
// Todo: add Egl.OPENVG_BIT here if we ever add OpenVG bindings.
|
|
||||||
Egl.RENDERABLE_TYPE, Egl.OPENGL_ES_BIT | Egl.OPENGL_ES2_BIT | Egl.OPENGL_BIT,
|
|
||||||
|
|
||||||
Egl.RED_SIZE, color.Red,
|
Egl.RED_SIZE, color.Red,
|
||||||
Egl.GREEN_SIZE, color.Green,
|
Egl.GREEN_SIZE, color.Green,
|
||||||
|
|
Loading…
Reference in a new issue