From a0e95055e3f4ae14c4ecea5b6be90d412146350c Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 8 Nov 2009 22:42:20 +0000 Subject: [PATCH] Added a second terminating 0 to attribute list, trying to work around issue [#1352]: "Occasional AccessViolationExceptions when creating the GLControl". --- Source/OpenTK/Platform/Windows/WinGLContext.cs | 5 +++++ Source/OpenTK/Platform/X11/X11GLContext.cs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Source/OpenTK/Platform/Windows/WinGLContext.cs b/Source/OpenTK/Platform/Windows/WinGLContext.cs index 254a3ec9..a17e6159 100644 --- a/Source/OpenTK/Platform/Windows/WinGLContext.cs +++ b/Source/OpenTK/Platform/Windows/WinGLContext.cs @@ -102,6 +102,11 @@ namespace OpenTK.Platform.Windows #warning "This is not entirely correct: Embedded is not a valid flag! We need to add a GetARBContextFlags(GraphicsContextFlags) method." attributes.Add((int)flags); } + // According to the docs, " specifies a list of attributes for the context. + // The list consists of a sequence of pairs terminated by the + // value 0. [...]" + // Is this a single 0, or a <0, 0> pair? (Defensive coding: add two zeroes just in case). + attributes.Add(0); attributes.Add(0); Handle = new ContextHandle( diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs index c22d47fc..5fbd2bf1 100644 --- a/Source/OpenTK/Platform/X11/X11GLContext.cs +++ b/Source/OpenTK/Platform/X11/X11GLContext.cs @@ -110,9 +110,15 @@ namespace OpenTK.Platform.X11 attributes.Add(minor); if (flags != 0) { +#warning "This is not entirely correct: Embedded is not a valid flag! We need to add a GetARBContextFlags(GraphicsContextFlags) method." attributes.Add((int)ArbCreateContext.Flags); attributes.Add((int)flags); } + // According to the docs, " specifies a list of attributes for the context. + // The list consists of a sequence of pairs terminated by the + // value 0. [...]" + // Is this a single 0, or a <0, 0> pair? (Defensive coding: add two zeroes just in case). + attributes.Add(0); attributes.Add(0); Handle = new ContextHandle(Glx.Arb.CreateContextAttribs(Display, *fbconfigs,