00001 #region License
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #endregion
00027
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031
00032 using OpenTK.Graphics;
00033 using OpenTK.Platform.Windows;
00034
00035 namespace OpenTK.Platform.Egl
00036 {
00037
00038 class EglWinPlatformFactory : WinFactory
00039 {
00040 #region Public Members
00041
00042 public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
00043 {
00044 WinWindowInfo win_win = (WinWindowInfo)window;
00045 IntPtr egl_display = GetDisplay(win_win.DeviceContext);
00046 EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(win_win.WindowHandle, egl_display);
00047 return new EglContext(mode, egl_win, shareContext, major, minor, flags);
00048 }
00049
00050 public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
00051 {
00052 WinWindowInfo win_win = (WinWindowInfo)window;
00053 IntPtr egl_display = GetDisplay(win_win.DeviceContext);
00054 EglWindowInfo egl_win = new OpenTK.Platform.Egl.EglWindowInfo(win_win.WindowHandle, egl_display);
00055 return new EglContext(handle, egl_win, shareContext, major, minor, flags);
00056 }
00057
00058 public override GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
00059 {
00060 return (GraphicsContext.GetCurrentContextDelegate)delegate
00061 {
00062 return new ContextHandle(Egl.GetCurrentContext());
00063 };
00064 }
00065
00066 public override IGraphicsMode CreateGraphicsMode()
00067 {
00068 return new EglGraphicsMode();
00069 }
00070
00071 #endregion
00072
00073 #region Private Members
00074
00075 IntPtr GetDisplay(IntPtr dc)
00076 {
00077 IntPtr display = Egl.GetDisplay(dc);
00078 if (display == IntPtr.Zero)
00079 display = Egl.GetDisplay(IntPtr.Zero);
00080
00081 return display;
00082 }
00083
00084 #endregion
00085 }
00086 }