From a2673bf5ff1e81f8dc5ef8c534c9fde9a4b6b2fb Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 15 Jan 2008 10:48:48 +0000 Subject: [PATCH] Changed the INativeGLWindow.CreateWindow interface to return an IGLContext instead of a GLContext. --- Source/OpenTK/GameWindow.cs | 4 ++-- Source/OpenTK/Platform/INativeGLWindow.cs | 2 +- Source/OpenTK/Platform/Windows/WinGLNative.cs | 13 +++++++++---- Source/OpenTK/Platform/X11/X11GLNative.cs | 8 ++++---- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index ef1564b2..146dac99 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -71,7 +71,7 @@ namespace OpenTK //InputDriver input_driver; - GLContext glContext; + IGLContext glContext; #endregion @@ -212,7 +212,7 @@ namespace OpenTK /// Returns the opengl IGLontext associated with the current GameWindow. /// Forces window creation. /// - public GLContext Context + public IGLContext Context { get { diff --git a/Source/OpenTK/Platform/INativeGLWindow.cs b/Source/OpenTK/Platform/INativeGLWindow.cs index 9ef4f0d0..e9d541a4 100644 --- a/Source/OpenTK/Platform/INativeGLWindow.cs +++ b/Source/OpenTK/Platform/INativeGLWindow.cs @@ -17,7 +17,7 @@ namespace OpenTK.Platform /// interface INativeGLWindow : IResizable, IDisposable { - void CreateWindow(DisplayMode mode, out GLContext context); + void CreateWindow(DisplayMode mode, out IGLContext context); void DestroyWindow(); void ProcessEvents(); void PointToClient(ref System.Drawing.Point p); diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index 7b60107b..aec5799f 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -277,9 +277,9 @@ namespace OpenTK.Platform.Windows #endregion - #region public void CreateWindow(DisplayMode mode, out GLContext context) + #region public void CreateWindow(DisplayMode mode, out IGLContext context) - public void CreateWindow(DisplayMode windowMode, out GLContext context) + public void CreateWindow(DisplayMode windowMode, out IGLContext context) { Debug.Print("Creating native window with mode: {0}", windowMode.ToString()); Debug.Indent(); @@ -336,8 +336,13 @@ namespace OpenTK.Platform.Windows Functions.SetWindowPos(this.Handle, WindowPlacementOptions.TOP, Left, Top, cp.Width, cp.Height, SetWindowPosFlags.SHOWWINDOW); - context = new GLContext(mode, window); - context.CreateContext(); + //context = new GLContext(mode, window); + //context.CreateContext(); + + context = new WinGLContext(); + (context as IGLContextCreationHack).SetWindowHandle(window.Handle); + (context as IGLContextCreationHack).SelectDisplayMode(mode, window); + context.CreateContext(true, null); Debug.Unindent(); } diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs index 908ad78c..44b58425 100644 --- a/Source/OpenTK/Platform/X11/X11GLNative.cs +++ b/Source/OpenTK/Platform/X11/X11GLNative.cs @@ -334,7 +334,7 @@ namespace OpenTK.Platform.X11 #endregion - #region public void CreateWindow(DisplayMode mode, out GLContext glContext) + #region public void CreateWindow(DisplayMode mode, out IGLContext glContext) /// /// Opens a new render window with the given DisplayMode. @@ -347,7 +347,7 @@ namespace OpenTK.Platform.X11 /// Colormap creation is currently disabled. /// /// - public void CreateWindow(DisplayMode mode, out GLContext glContext) + public void CreateWindow(DisplayMode mode, out IGLContext glContext) { if (exists) throw new ApplicationException("Render window already exists!"); @@ -355,12 +355,12 @@ namespace OpenTK.Platform.X11 Debug.Print("Creating GameWindow with mode: {0}", mode != null ? mode.ToString() : "default"); Debug.Indent(); - glContext = new GLContext(mode, window); + glContext = new X11GLContext(); (glContext as IGLContextCreationHack).SelectDisplayMode(mode, window); if (glContext == null) throw new ApplicationException("Could not create GLContext"); Debug.Print("Created GLContext"); - window.VisualInfo = ((glContext as IGLContextInternal).Info as X11.WindowInfo).VisualInfo; + window.VisualInfo = ((X11.WindowInfo)(glContext as IGLContextInternal).Info).VisualInfo; //window.VisualInfo = Marshal.PtrToStructure(Glx.ChooseVisual(window.Display, window.Screen, // Create a window on this display using the visual above