From 519b432cd7c8a5e3b86ae89fc14ed6bde1e7cf5d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 5 Aug 2007 10:33:23 +0000 Subject: [PATCH] Updated documentation on the *GLNative classes. X11/X11GLNative.cs now doesn't create a render window during the constructor call, but rather when CreateWindow is called explicitly. --- Source/OpenTK/Platform/Windows/WinGLNative.cs | 3 +- Source/OpenTK/Platform/X11/X11GLContext.cs | 40 ++--------- Source/OpenTK/Platform/X11/X11GLNative.cs | 72 +++++++++---------- 3 files changed, 43 insertions(+), 72 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index 6c47c925..5a01f83e 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -33,7 +33,8 @@ namespace OpenTK.Platform.Windows #region --- Contructors --- /// - /// Constructs a new WinGLNative window, using safe defaults for the DisplayMode. + /// Constructs a new WinGLNative class. Call CreateWindow to create the + /// actual render window. /// public WinGLNative() { diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs index 3bdf8396..8be60566 100644 --- a/Source/OpenTK/Platform/X11/X11GLContext.cs +++ b/Source/OpenTK/Platform/X11/X11GLContext.cs @@ -37,12 +37,12 @@ namespace OpenTK.Platform.X11 #region --- Public Constructor --- - private X11GLContext() + internal X11GLContext() { this.mode = new DisplayMode(); } - public X11GLContext(IWindowInfo info, DisplayMode mode) + internal X11GLContext(IWindowInfo info, DisplayMode mode) { X11WindowInfo xInfo = info as X11WindowInfo; this.windowInfo.Window = xInfo.Window; @@ -54,32 +54,6 @@ namespace OpenTK.Platform.X11 this.mode = mode; } - public X11GLContext( - IntPtr handle, - IntPtr display, - IntPtr rootWindow, - int screenNo, - IntPtr handleToTopLevelControl, - ColorDepth color, - ColorDepth accum, - int depthBits, - int stencilBits, - int auxBits, - bool stereo, - bool doublebuffer - ) - { - Trace.WriteLine("Creating opengl context (X11GLContext driver)"); - Trace.Indent(); - - this.display = display; - this.screenNo = screenNo; - //this.depthBits = depthBits; - //this.stencilBits = stencilBits; - - this.CreateVisual(); - } - #endregion #region --- IGLContext Members --- @@ -210,8 +184,8 @@ namespace OpenTK.Platform.X11 public void CreateVisual() { - Trace.WriteLine("Creating visual."); - Trace.Indent(); + Debug.WriteLine("Creating visual."); + Debug.Indent(); ColorDepth color = new ColorDepth(24); int depthBits = 16; @@ -248,7 +222,7 @@ namespace OpenTK.Platform.X11 visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER); visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE); */ - Trace.Write( + Debug.Write( String.Format( "Requesting visual: {0} ({1}{2}{3}{4})... ", mode.ToString(), @@ -266,8 +240,8 @@ namespace OpenTK.Platform.X11 } visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo)); - Trace.WriteLine(String.Format("done! (id: {0})", x11context)); - Trace.Unindent(); + Debug.Print("done! (id: {0})", x11context); + Debug.Unindent(); } #endregion diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs index d3b9e069..e24ca300 100644 --- a/Source/OpenTK/Platform/X11/X11GLNative.cs +++ b/Source/OpenTK/Platform/X11/X11GLNative.cs @@ -26,57 +26,39 @@ namespace OpenTK.Platform.X11 private IntPtr window; private DisplayMode mode = new DisplayMode(); - - private bool created; - - //private X11Keyboard key; // Number of pending events. private int pending = 0; + // C# ResizeEventArgs private ResizeEventArgs resizeEventArgs = new ResizeEventArgs(); + // Low level X11 resize request private X11.Event xresize = new Event(); - // This is never written in the code. If at some point it gets != 0, - // then memory corruption is taking place from the xresize struct. // Event used for event loop. private Event e = new Event(); + // This is never written in the code. If at some point it gets != 0, + // then memory corruption is taking place from the xresize struct. + int memGuard = 0; private ConfigureNotifyEvent configure = new ConfigureNotifyEvent(); private ReparentNotifyEvent reparent = new ReparentNotifyEvent(); private ExposeEvent expose = new ExposeEvent(); private CreateWindowEvent createWindow = new CreateWindowEvent(); private DestroyWindowEvent destroyWindow = new DestroyWindowEvent(); - // This is never written in the code. If at some point it gets != 0, - // then memory corruption is taking place from the xresize struct. - int memGuard = 0; - - //private int width, height; private bool disposed; + private bool created; #endregion #region --- Public Constructors --- /// - /// Constructs a new X11GLNative window, with its associated context. - /// Safe defaults for visual, colormap, etc. + /// Constructs and initializes a new X11GLNative window. + /// Call CreateWindow to create the actual render window. /// public X11GLNative() { - Trace.WriteLine("Creating GameWindow (X11GLNative driver)"); - Trace.Indent(); - - // Set default (safe) DisplayMode. - mode.Width = 640; - mode.Height = 480; - mode.Color = new ColorDepth(24); - mode.DepthBits = 16; - mode.Buffers = 2; - - Trace.WriteLine(String.Format("Display mode: {0}", mode)); - - this.CreateWindow(mode); } #endregion @@ -85,8 +67,24 @@ namespace OpenTK.Platform.X11 #region public void CreateWindow(DisplayMode mode) + /// + /// Opens a new render window with the given DisplayMode. + /// + /// The DisplayMode of the render window. + /// + /// Creates the window visual and colormap. Associates the colormap/visual + /// with the window and raises the window on top of the window stack. + /// + /// Colormap creation is currently disabled. + /// + /// public void CreateWindow(DisplayMode mode) { + Debug.WriteLine("Creating GameWindow (X11GLNative driver)"); + Debug.Indent(); + + Debug.WriteLine(String.Format("Display mode: {0}", mode)); + windowInfo.Display = display = API.OpenDisplay(null); // null == default display if (display == IntPtr.Zero) { @@ -95,20 +93,18 @@ namespace OpenTK.Platform.X11 windowInfo.Screen = screen = API.DefaultScreen(display); windowInfo.RootWindow = rootWindow = API.RootWindow(display, screen); - Trace.WriteLine( - String.Format( - "Display: {0}, Screen {1}, Root window: {2}", - windowInfo.Display, - windowInfo.Screen, - windowInfo.RootWindow - ) + Debug.Print( + "Display: {0}, Screen {1}, Root window: {2}", + windowInfo.Display, + windowInfo.Screen, + windowInfo.RootWindow ); glContext = new X11GLContext(windowInfo, mode); glContext.CreateVisual(); // Create a window on this display using the visual above - Trace.Write("Creating output window... "); + Debug.Write("Creating output window... "); SetWindowAttributes wnd_attributes = new SetWindowAttributes(); wnd_attributes.background_pixel = 0; @@ -146,7 +142,7 @@ namespace OpenTK.Platform.X11 throw new Exception("Could not create window."); } - Trace.WriteLine("done! (id: " + window + ")"); + Debug.WriteLine("done! (id: " + window + ")"); // Set the window hints /* @@ -177,12 +173,12 @@ namespace OpenTK.Platform.X11 API.MapRaised(display, window); - Trace.WriteLine("Mapped window."); + Debug.WriteLine("Mapped window."); //glContext.MakeCurrent(); - Trace.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!"); - Trace.Unindent(); + Debug.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!"); + Debug.Unindent(); created = true; }