mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 13:45:36 +00:00
Implemented EglContext construction according to AMD's OpenGL|ES samples.
This commit is contained in:
parent
5515c59173
commit
5d5f598707
|
@ -41,29 +41,38 @@ namespace OpenTK.Platform.Egl
|
|||
EGLConfig[] configs = new EGLConfig[1];
|
||||
int[] attribList = new int[]
|
||||
{
|
||||
Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
|
||||
//Egl.SURFACE_TYPE, Egl.WINDOW_BIT,
|
||||
|
||||
Egl.RED_SIZE, color.Red,
|
||||
Egl.GREEN_SIZE, color.Green,
|
||||
Egl.BLUE_SIZE, color.Blue,
|
||||
Egl.ALPHA_SIZE, color.Alpha,
|
||||
|
||||
Egl.DEPTH_SIZE, depth > 0 ? depth : Egl.DONT_CARE,
|
||||
Egl.STENCIL_SIZE, stencil > 0 ? stencil : Egl.DONT_CARE,
|
||||
Egl.DEPTH_SIZE, depth > 0 ? depth : 0,
|
||||
Egl.STENCIL_SIZE, stencil > 0 ? stencil : 0,
|
||||
|
||||
Egl.SAMPLE_BUFFERS, samples > 0 ? 1 : 0,
|
||||
//Egl.SAMPLE_BUFFERS, samples > 0 ? 1 : 0,
|
||||
Egl.SAMPLES, samples > 0 ? samples : 0,
|
||||
|
||||
Egl.NONE, Egl.NONE
|
||||
Egl.NONE,
|
||||
};
|
||||
|
||||
// Todo: what if we don't wish to use the default display?
|
||||
EGLDisplay display = Egl.GetDisplay(EGLNativeDisplayType.Default);
|
||||
int major, minor;
|
||||
if (!Egl.Initialize(display, out major, out minor))
|
||||
throw new GraphicsModeException(String.Format("Failed to initialize display connection, error {0}", Egl.GetError()));
|
||||
|
||||
int num_configs;
|
||||
Egl.GetConfigs(display, configs, configs.Length, out num_configs);
|
||||
if (num_configs == 0)
|
||||
throw new NotSupportedException("The requested GraphicsMode is not supported.");
|
||||
if (!Egl.GetConfigs(display, null, 0, out num_configs))
|
||||
{
|
||||
throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode configurations, error {0}", Egl.GetError()));
|
||||
}
|
||||
|
||||
if (!Egl.ChooseConfig(display, attribList, configs, configs.Length, out num_configs))
|
||||
{
|
||||
throw new GraphicsModeException(String.Format("Failed to retrieve GraphicsMode, error {0}", Egl.GetError()));
|
||||
}
|
||||
|
||||
// See what we really got
|
||||
EGLConfig active_config = configs[0];
|
||||
|
@ -79,7 +88,7 @@ namespace OpenTK.Platform.Egl
|
|||
Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out sample_buffers);
|
||||
Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out samples);
|
||||
|
||||
return new GraphicsMode(active_config.Handle.Value, new ColorFormat(r, g, b, a), depth, stencil, sample_buffers > 0 ? samples : 0, 0, 2, false);
|
||||
return new GraphicsMode(active_config.Handle.Value, new ColorFormat(r, g, b, a), d, s, sample_buffers > 0 ? samples : 0, 0, 2, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -40,7 +40,8 @@ namespace OpenTK.Platform.Egl
|
|||
public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
WinWindowInfo win_win = (WinWindowInfo)window;
|
||||
EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(win_win.WindowHandle, Egl.GetDisplay(new EGLNativeDisplayType(win_win.DeviceContext)));
|
||||
EGLDisplay egl_display = Egl.GetDisplay(EGLNativeDisplayType.Default); // Egl.GetDisplay(new EGLNativeDisplayType(win_win.DeviceContext));
|
||||
EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(win_win.WindowHandle, egl_display);
|
||||
return new EglContext(mode, egl_win, shareContext, major, minor, flags);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform.Egl
|
||||
{
|
||||
|
@ -72,6 +73,9 @@ namespace OpenTK.Platform.Egl
|
|||
public void CreateWindowSurface(EGLConfig config)
|
||||
{
|
||||
Surface = Egl.CreateWindowSurface(Display, config, Handle, null);
|
||||
int error = Egl.GetError();
|
||||
if (error != Egl.SUCCESS)
|
||||
throw new GraphicsContextException(String.Format("[Error] Failed to create EGL window surface, error {0}.", error));
|
||||
}
|
||||
|
||||
//public void CreatePixmapSurface(EGLConfig config)
|
||||
|
|
Loading…
Reference in a new issue