Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
* Egl.cs:
Browse files Browse the repository at this point in the history
* 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".

git-svn-id: https://opentk.svn.sourceforge.net/svnroot/opentk/trunk@3060 ebc5dd9b-fb1d-0410-b6f8-d24c324e9604
  • Loading branch information
the_fiddler committed Jan 18, 2011
1 parent 1cd9688 commit 52c79d3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
11 changes: 10 additions & 1 deletion Source/OpenTK/Platform/Egl/Egl.cs
Expand Up @@ -2,7 +2,7 @@
//
// 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
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -41,6 +41,15 @@ namespace OpenTK.Platform.Egl
using EGLSurface = 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
{
public const int VERSION_1_0 = 1;
Expand Down
8 changes: 7 additions & 1 deletion Source/OpenTK/Platform/Egl/EglContext.cs
Expand Up @@ -61,7 +61,13 @@ class EglContext : EmbeddedGraphicsContext

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)
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
IntPtr config = Mode.Index.Value;
Expand Down
26 changes: 17 additions & 9 deletions Source/OpenTK/Platform/Egl/EglGraphicsMode.cs
Expand Up @@ -36,20 +36,28 @@ class EglGraphicsMode : IGraphicsMode
{
#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];
int[] attribList = new int[]
{
//Egl.SURFACE_TYPE, Egl.WINDOW_BIT,

// 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.RENDERABLE_TYPE, (int)renderable_flags,

Egl.RED_SIZE, color.Red,
Egl.GREEN_SIZE, color.Green,
Expand Down

0 comments on commit 52c79d3

Please sign in to comment.