kvark's picture

Need an ability to make SRGB-capable main framebuffer

Project:The Open Toolkit library
Version:1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:kvark
Status:in progress
Description

According to the following spec:
http://www.opengl.org/registry/specs/ARB/framebuffer_sRGB.txt

wglChoosePixelFormatEXT may accept WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB in the list of attributes.
We need to make it available as a flag upon Window/Context creation.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kvark's picture

#1

Assigned to:Anonymous» kvark

I've implemented a path for SVN trunk that works for GLX and WGL:

EDIT-1: patch removed. Something is not working yet. I'll post a patch when it works at least under windows...
EDIT-2: here it is - the working patch:

Index: Source/OpenTK/Graphics/GraphicsMode.cs
===================================================================
--- Source/OpenTK/Graphics/GraphicsMode.cs	(revision 3069)
+++ Source/OpenTK/Graphics/GraphicsMode.cs	(working copy)
@@ -18,7 +18,7 @@
     {
         ColorFormat color_format, accumulator_format;
         int depth, stencil, buffers, samples;
-        bool stereo;
+        bool stereo, srgb;
         IntPtr? index = null;  // The id of the pixel format or visual.
 
         static GraphicsMode defaultMode;
@@ -42,14 +42,14 @@
         #region internal GraphicsMode(GraphicsMode mode)
 
         internal GraphicsMode(GraphicsMode mode)
-            : this(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo) { }
+            : this(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo, mode.Srgb) { }
 
         #endregion
 
-        #region internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
+        #region internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo, bool srgb)
 
         internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples, ColorFormat accum,
-                              int buffers, bool stereo)
+                              int buffers, bool stereo, bool srgb)
         {
             if (depth < 0) throw new ArgumentOutOfRangeException("depth", "Must be greater than, or equal to zero.");
             if (stencil < 0) throw new ArgumentOutOfRangeException("stencil", "Must be greater than, or equal to zero.");
@@ -64,6 +64,7 @@
             this.AccumulatorFormat = accum;
             this.Buffers = buffers;
             this.Stereo = stereo;
+            this.Srgb = srgb;
         }
 
         #endregion
@@ -160,15 +161,31 @@
         /// <param name="stencil">The number of bits in the stencil buffer.</param>
         /// <param name="samples">The number of samples for FSAA.</param>
         /// <param name="accum">The ColorFormat of the accumilliary buffer.</param>
+        /// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
         /// <param name="stereo">Set to true for a GraphicsMode with stereographic capabilities.</param>
-        /// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
         public GraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
-            : this(null, color, depth, stencil, samples, accum, buffers, stereo) { }
+            : this(color, depth, stencil, samples, accum, buffers, stereo, Default.Srgb) { }
 
         #endregion
+        
+        #region public GraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo, bool srgb)
 
+        /// <summary>Constructs a new GraphicsMode with the specified parameters.</summary>
+        /// <param name="color">The ColorFormat of the color buffer.</param>
+        /// <param name="depth">The number of bits in the depth buffer.</param>
+        /// <param name="stencil">The number of bits in the stencil buffer.</param>
+        /// <param name="samples">The number of samples for FSAA.</param>
+        /// <param name="accum">The ColorFormat of the accumilliary buffer.</param>
+        /// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
+        /// <param name="stereo">Set to true for a GraphicsMode with stereographic capabilities.</param>
+        /// <param name="srgb">Set to true for a GraphicsMode with standard color encoding capabilities.</param>
+        public GraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo, bool srgb)
+            : this(null, color, depth, stencil, samples, accum, buffers, stereo, srgb) { }
+
         #endregion
 
+        #endregion
+
         #region --- Public Methods ---
 
         #region public IntPtr Index
@@ -275,6 +292,24 @@
 
         #endregion
 
+        #region public int Buffers
+
+        /// <summary>
+        /// Gets a System.Int32 containing the number of buffers associated with this
+        /// DisplayMode.
+        /// </summary>
+        public int Buffers
+        {
+            get
+            {
+                LazySelectGraphicsMode();
+                return buffers;
+            }
+            private set { buffers = value; }
+        }
+
+        #endregion
+        
         #region public bool Stereo
 
         /// <summary>
@@ -291,21 +326,20 @@
         }
 
         #endregion
-
-        #region public int Buffers
-
+        
+        #region public bool Srgb
+        
         /// <summary>
-        /// Gets a System.Int32 containing the number of buffers associated with this
-        /// DisplayMode.
+        /// Gets a System.Boolean indicating whether this DisplayMode has standard color encoding.
         /// </summary>
-        public int Buffers
+        public bool Srgb
         {
             get
             {
                 LazySelectGraphicsMode();
-                return buffers;
+                return srgb;
             }
-            private set { buffers = value; }
+            private set { srgb = value; }
         }
 
         #endregion
@@ -321,9 +355,9 @@
                 {
                     if (defaultMode == null)
                     {
-                        Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}, {4}, {5}, {6}).",
-                            DisplayDevice.Default.BitsPerPixel, 16, 0, 0, 0, 2, false);
-                        defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 0, 0, 2, false);
+                        Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}).",
+                            DisplayDevice.Default.BitsPerPixel, 16, 0, 0, 0, 2, false, false);
+                        defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 0, 0, 2, false, false);
                     }
                     return defaultMode;
                 }
@@ -343,7 +377,7 @@
         {
             if (index == null)
             {
-                GraphicsMode mode = implementation.SelectGraphicsMode(color_format, depth, stencil, samples, accumulator_format, buffers, stereo);
+                GraphicsMode mode = implementation.SelectGraphicsMode(color_format, depth, stencil, samples, accumulator_format, buffers, stereo, srgb);
 
                 Index = mode.Index;
                 ColorFormat = mode.ColorFormat;
@@ -353,6 +387,7 @@
                 AccumulatorFormat = mode.AccumulatorFormat;
                 Buffers = mode.Buffers;
                 Stereo = mode.Stereo;
+                Srgb = mode.Srgb;
             }
         }
 
@@ -364,8 +399,8 @@
         /// <returns>! System.String describing the current GraphicsFormat.</returns>
         public override string ToString()
         {
-            return String.Format("Index: {0}, Color: {1}, Depth: {2}, Stencil: {3}, Samples: {4}, Accum: {5}, Buffers: {6}, Stereo: {7}",
-                Index, ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo);
+            return String.Format("Index: {0}, Color: {1}, Depth: {2}, Stencil: {3}, Samples: {4}, Accum: {5}, Buffers: {6}, Stereo: {7}, Srgb: {8}",
+                Index, ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo, Srgb);
         }
 
         /// <summary>
Index: Source/OpenTK/Graphics/IGraphicsMode.cs
===================================================================
--- Source/OpenTK/Graphics/IGraphicsMode.cs	(revision 3069)
+++ Source/OpenTK/Graphics/IGraphicsMode.cs	(working copy)
@@ -17,6 +17,6 @@
         // Creates a temporary OpenGL context (if necessary) and finds the mode which closest matches
         // the specified parameters.
         GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers,
-            bool stereo);
+            bool stereo, bool srgb);
     }
 }
Index: Source/OpenTK/Platform/Dummy/DummyGLContext.cs
===================================================================
--- Source/OpenTK/Platform/Dummy/DummyGLContext.cs	(revision 3069)
+++ Source/OpenTK/Platform/Dummy/DummyGLContext.cs	(working copy)
@@ -32,7 +32,7 @@
         public DummyGLContext()
             : this(new ContextHandle(new IntPtr(++handle_count)))
         {
-            Mode = new GraphicsMode(new IntPtr(2), 32, 16, 0, 0, 0, 2, false);
+            Mode = new GraphicsMode(new IntPtr(2), 32, 16, 0, 0, 0, 2, false, false);
         }
 
         public DummyGLContext(ContextHandle handle)
Index: Source/OpenTK/Platform/Egl/EglContext.cs
===================================================================
--- Source/OpenTK/Platform/Egl/EglContext.cs	(revision 3069)
+++ Source/OpenTK/Platform/Egl/EglContext.cs	(working copy)
@@ -66,7 +66,7 @@
             // and it may not support the desired renderer.
             Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat,
                 mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat,
-                mode.Buffers, mode.Stereo,
+                mode.Buffers, mode.Stereo, mode.Srgb,
                 major > 1 ? RenderableFlags.ES2 : RenderableFlags.ES);
             if (!Mode.Index.HasValue)
                 throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
Index: Source/OpenTK/Platform/Egl/EglGraphicsMode.cs
===================================================================
--- Source/OpenTK/Platform/Egl/EglGraphicsMode.cs	(revision 3069)
+++ Source/OpenTK/Platform/Egl/EglGraphicsMode.cs	(working copy)
@@ -37,11 +37,11 @@
         #region IGraphicsMode Members
 
         public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil,
-            int samples, ColorFormat accum, int buffers, bool stereo)
+            int samples, ColorFormat accum, int buffers, bool stereo, bool srgb)
         {
             // According to the EGL specs, the ES flag should select ES 1.0 or higher, which
             // makes sense as a default. EglContext.cs checks 
-            return SelectGraphicsMode(color, depth, stencil, samples, accum, buffers, stereo,
+            return SelectGraphicsMode(color, depth, stencil, samples, accum, buffers, stereo, srgb,
                 RenderableFlags.ES);
         }
 
@@ -50,7 +50,7 @@
         #region Public Members
 
         public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil,
-            int samples, ColorFormat accum, int buffers, bool stereo,
+            int samples, ColorFormat accum, int buffers, bool stereo, bool srgb,
             RenderableFlags renderable_flags)
         {
             IntPtr[] configs = new IntPtr[1];
@@ -99,7 +99,7 @@
             Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out sample_buffers);
             Egl.GetConfigAttrib(display, active_config, Egl.SAMPLES, out samples);
 
-            return new GraphicsMode(active_config, new ColorFormat(r, g, b, a), d, s, sample_buffers > 0 ? samples : 0, 0, 2, false);
+            return new GraphicsMode(active_config, new ColorFormat(r, g, b, a), d, s, sample_buffers > 0 ? samples : 0, 0, 2, false, false);
         }
 
         #endregion
Index: Source/OpenTK/Platform/MacOS/MacOSGraphicsMode.cs
===================================================================
--- Source/OpenTK/Platform/MacOS/MacOSGraphicsMode.cs	(revision 3069)
+++ Source/OpenTK/Platform/MacOS/MacOSGraphicsMode.cs	(working copy)
@@ -40,9 +40,9 @@
         #region IGraphicsMode Members
 
         public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil,
-            int samples, ColorFormat accum, int buffers, bool stereo)
+            int samples, ColorFormat accum, int buffers, bool stereo, bool srgb)
         {
-            IntPtr pixelformat = SelectPixelFormat(color, depth, stencil, samples, accum, buffers, stereo);
+            IntPtr pixelformat = SelectPixelFormat(color, depth, stencil, samples, accum, buffers, stereo, srgb);
             return GetGraphicsModeFromPixelFormat(pixelformat);
         }
 
@@ -69,12 +69,12 @@
             Agl.aglDescribePixelFormat(pixelformat, Agl.PixelFormatAttribute.AGL_DOUBLEBUFFER, out buffers);
             Agl.aglDescribePixelFormat(pixelformat, Agl.PixelFormatAttribute.AGL_STEREO, out stereo);
 
-            return new GraphicsMode(pixelformat, new ColorFormat(r, g, b, a),
-                depth, stencil, samples, new ColorFormat(ar, ag, ab, aa), buffers + 1, stereo != 0);
+            return new GraphicsMode(pixelformat, new ColorFormat(r, g, b, a),	//todo: SRGB support
+                depth, stencil, samples, new ColorFormat(ar, ag, ab, aa), buffers + 1, stereo != 0, false);
         }
 
         IntPtr SelectPixelFormat(ColorFormat color, int depth, int stencil, int samples,
-            ColorFormat accum, int buffers, bool stereo)
+            ColorFormat accum, int buffers, bool stereo, bool srgb)
         {
             List<int> attribs = new List<int>();
 
Index: Source/OpenTK/Platform/Windows/API.cs
===================================================================
--- Source/OpenTK/Platform/Windows/API.cs	(revision 3069)
+++ Source/OpenTK/Platform/Windows/API.cs	(working copy)
@@ -1,4 +1,4 @@
-#region --- License ---
+#region --- License ---
 /* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
  * Contributions from Erik Ylvisaker
  * See license.txt for license info
@@ -3060,7 +3060,10 @@
         // PixelFormatDescriptor flags for use in ChoosePixelFormat only
         DEPTH_DONTCARE = unchecked((int)0x20000000),
         DOUBLEBUFFER_DONTCARE = unchecked((int)0x40000000),
-        STEREO_DONTCARE = unchecked((int)0x80000000)
+        STEREO_DONTCARE = unchecked((int)0x80000000),
+        
+		// Ignored flags
+        SRGB_CAPABLE	= 0,
     }
     #endregion
 
Index: Source/OpenTK/Platform/Windows/Bindings/WglEnums.cs
===================================================================
--- Source/OpenTK/Platform/Windows/Bindings/WglEnums.cs	(revision 3069)
+++ Source/OpenTK/Platform/Windows/Bindings/WglEnums.cs	(working copy)
@@ -129,8 +129,9 @@
         DrawToBitmapArb = ((int)0x2002),
         BlueShiftArb = ((int)0x201a),
         SwapCopyArb = ((int)0x2029),
+        FramebufferSrgbCapableArb = ((int)0x20a9),
     }
-
+    
     public enum WGL_EXT_pbuffer
     {
         DrawToPbufferExt = ((int)0x202d),
@@ -298,6 +299,11 @@
         TypeRgbaFloatAti = ((int)0x21a0),
     }
 
+    public enum WGL_ARB_framebuffer_sRGB
+    {
+    	 FramebufferSrgbCapableArb = ((int)0x20a9),
+    }
+    
     public enum WGL_font_type
     {
         FontLines = ((int)0),
@@ -476,6 +482,7 @@
         Aux6Arb = ((int)0x208d),
         ShareAccumExt = ((int)0x200e),
         StereoArb = ((int)0x2012),
+        FramebufferSrgbCapableArb = ((int)0x20a9),
         TextureRgbArb = ((int)0x2075),
         AccelerationArb = ((int)0x2003),
         TextureCubeMapPositiveXArb = ((int)0x207d),
Index: Source/OpenTK/Platform/Windows/WinGraphicsMode.cs
===================================================================
--- Source/OpenTK/Platform/Windows/WinGraphicsMode.cs	(revision 3069)
+++ Source/OpenTK/Platform/Windows/WinGraphicsMode.cs	(working copy)
@@ -68,17 +68,17 @@
         #region IGraphicsMode Members
 
         public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples,
-            ColorFormat accum, int buffers, bool stereo)
+            ColorFormat accum, int buffers, bool stereo, bool srgb)
         {
             GraphicsMode mode = null;
             do
             {
                 mode = modes.Find(delegate(GraphicsMode current)
                 {
-                    return ModeSelector(current, color, depth, stencil, samples, accum, buffers, stereo);
+                    return ModeSelector(current, color, depth, stencil, samples, accum, buffers, stereo, srgb);
                 });
             } while (mode == null && RelaxParameters(
-                ref color, ref depth, ref stencil, ref samples, ref accum, ref buffers, ref stereo));
+                ref color, ref depth, ref stencil, ref samples, ref accum, ref buffers, ref stereo, ref srgb));
 
             if (mode == null)
                 mode = modes[0];
@@ -87,8 +87,9 @@
         }
 
         bool RelaxParameters(ref ColorFormat color, ref int depth, ref int stencil, ref int samples,
-            ref ColorFormat accum, ref int buffers, ref bool stereo)
+            ref ColorFormat accum, ref int buffers, ref bool stereo, ref bool srgb)
         {
+        	if (!srgb)	{ srgb = true; return true; }
             if (stereo) { stereo = false; return true; }
             if (buffers != 2) { buffers = 2; return true; }
             if (accum != 0) { accum = 0; return true; }
@@ -165,7 +166,8 @@
                         0,
                         new ColorFormat(pfd.AccumBits),
                         (pfd.Flags & PixelFormatDescriptorFlags.DOUBLEBUFFER) != 0 ? 2 : 1,
-                        (pfd.Flags & PixelFormatDescriptorFlags.STEREO) != 0);
+                        (pfd.Flags & PixelFormatDescriptorFlags.STEREO) != 0,
+                        (pfd.Flags & PixelFormatDescriptorFlags.SRGB_CAPABLE) != 0 );
 
                     yield return fmt;
                 }
@@ -179,7 +181,7 @@
         IEnumerable<GraphicsMode> GetModesARB(INativeWindow native)
         {
             using (IGraphicsContext context = new GraphicsContext(
-                new GraphicsMode(new IntPtr(2), new ColorFormat(), 0, 0, 0, new ColorFormat(), 2, false),
+                new GraphicsMode(new IntPtr(2), new ColorFormat(), 0, 0, 0, new ColorFormat(), 2, false, false),
                 (WinWindowInfo)native.WindowInfo, 1, 0, GraphicsContextFlags.Default))
             {
                 WinWindowInfo window = (WinWindowInfo)native.WindowInfo;
@@ -217,6 +219,7 @@
 
                     (int)WGL_ARB_pixel_format.DoubleBufferArb,
                     (int)WGL_ARB_pixel_format.StereoArb,
+                    (int)WGL_ARB_pixel_format.FramebufferSrgbCapableArb,
                     0
                 };
 
@@ -256,7 +259,8 @@
                                 values[8] != 0 ? values[9] : 0,
                                 new ColorFormat(values[10], values[11], values[12], values[13]),
                                 values[15] == 1 ? 2 : 1,
-                                values[16] == 1 ? true : false);
+                                values[16] == 1 ? true : false,		//stereo
+                                values[17] == 1 ? true : false);	//srgb
 
                             yield return mode;
                         }
@@ -270,7 +274,7 @@
         #region ModeSelector
 
         bool ModeSelector(GraphicsMode current, ColorFormat color, int depth, int stencil, int samples,
-            ColorFormat accum, int buffers, bool stereo)
+            ColorFormat accum, int buffers, bool stereo, bool srgb)
         {
             bool result =
                 (color != ColorFormat.Empty ? current.ColorFormat >= color : true) &&
@@ -279,7 +283,8 @@
                 (samples != 0 ? current.Samples >= samples : true) &&
                 (accum != ColorFormat.Empty ? current.AccumulatorFormat >= accum : true) &&
                 (buffers != 0 ? current.Buffers >= buffers : true) &&
-                current.Stereo == stereo;
+                current.Stereo == stereo &&
+            	current.Srgb == srgb;
             return result;
         }
 
Index: Source/OpenTK/Platform/X11/Bindings/Glx.cs
===================================================================
--- Source/OpenTK/Platform/X11/Bindings/Glx.cs	(revision 3069)
+++ Source/OpenTK/Platform/X11/Bindings/Glx.cs	(working copy)
@@ -134,6 +134,7 @@
         LEVEL = 3,
         CONFIG_CAVEAT = 0x20,
         RENDER_TYPE_SGIX = 0x8011,
+        FRAMEBUFFER_SRGB_CAPABLE = 0x20B2,
     }
 
     enum GLXHyperpipeAttrib : int
Index: Source/OpenTK/Platform/X11/X11GraphicsMode.cs
===================================================================
--- Source/OpenTK/Platform/X11/X11GraphicsMode.cs	(revision 3069)
+++ Source/OpenTK/Platform/X11/X11GraphicsMode.cs	(working copy)
@@ -33,7 +33,7 @@
         #region IGraphicsMode Members
 
         public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum,
-                                               int buffers, bool stereo)
+                                               int buffers, bool stereo, bool srgb)
         {
             GraphicsMode gfx;
             // The actual GraphicsMode that will be selected.
@@ -42,10 +42,10 @@
 
             // Try to select a visual using Glx.ChooseFBConfig and Glx.GetVisualFromFBConfig.
             // This is only supported on GLX 1.3 - if it fails, fall back to Glx.ChooseVisual.
-            visual = SelectVisualUsingFBConfig(color, depth, stencil, samples, accum, buffers, stereo);
+            visual = SelectVisualUsingFBConfig(color, depth, stencil, samples, accum, buffers, stereo, srgb);
 
             if (visual == IntPtr.Zero)
-                visual = SelectVisualUsingChooseVisual(color, depth, stencil, samples, accum, buffers, stereo);
+                visual = SelectVisualUsingChooseVisual(color, depth, stencil, samples, accum, buffers, stereo, srgb);
 
             if (visual == IntPtr.Zero)
                 throw new GraphicsModeException("Requested GraphicsMode not available.");
@@ -69,12 +69,14 @@
             Glx.GetConfig(display, ref info, GLXAttribute.DOUBLEBUFFER, out buffers);
             ++buffers;
             // the above lines returns 0 - false and 1 - true.
-            int st;
+            int st,sc;
             Glx.GetConfig(display, ref info, GLXAttribute.STEREO, out st);
+            Glx.GetConfig(display, ref info, GLXAttribute.FRAMEBUFFER_SRGB_CAPABLE, out sc);
             stereo = st != 0;
+            srgb = sc != 0;
 
             gfx = new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, samples,
-            new ColorFormat(ar, ag, ab, aa), buffers, stereo);
+            new ColorFormat(ar, ag, ab, aa), buffers, stereo, srgb);
 
             using (new XLock(display))
             {
@@ -91,7 +93,7 @@
         // See http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ib...
         // for the attribute declarations. Note that the attributes are different than those used in Glx.ChooseVisual.
         IntPtr SelectVisualUsingFBConfig(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum,
-                                               int buffers, bool stereo)
+                                               int buffers, bool stereo, bool srgb)
         {
             List<int> visualAttributes = new List<int>();
             IntPtr visual = IntPtr.Zero;
@@ -160,6 +162,12 @@
                 visualAttributes.Add((int)GLXAttribute.STEREO);
                 visualAttributes.Add(1);
             }
+            
+            if (srgb)
+            {
+            	visualAttributes.Add((int)GLXAttribute.FRAMEBUFFER_SRGB_CAPABLE);
+            	visualAttributes.Add(1);
+            }
 
             visualAttributes.Add(0);
 
@@ -199,7 +207,7 @@
 
         // See http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ib...
         IntPtr SelectVisualUsingChooseVisual(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum,
-                                                  int buffers, bool stereo)
+                                                  int buffers, bool stereo, bool srgb)
         {
             List<int> visualAttributes = new List<int>();
 
@@ -258,6 +266,9 @@
 
             if (stereo)
                 visualAttributes.Add((int)GLXAttribute.STEREO);
+           	
+            if (srgb)
+                visualAttributes.Add((int)GLXAttribute.FRAMEBUFFER_SRGB_CAPABLE);
 
             visualAttributes.Add(0);
 

I'm a bit confused about the NativeWindow default constructor. It is called while the platform factory is initialized. The constructor makes a use of GraphicsMode.Default, but how do we dare to access default graphics mode (supposed to be platform-specific) if the platform is not yet initialized? I suggest creating a new dummy GraphicsMode in the NativeWindow constructor, so that the default is not touched.

the Fiddler's picture

#2

Status:open» confirmed

sRGB is something I've been meaning to implement for some time now. Thanks for the patch I'll review later today and commit.

kvark's picture

#3

Just a note for people interested in SRGB support:

On my machine all available graphics modes appear to be SRGB-compatible. Maybe it's a mistake in my OpenTK patch logic, or it's just that ATI Catalyst supports SRGB so easily.
So, If you want to use it right away - just try, maybe it will work without passing any flags to OpenTK (until the patch is committed).

the Fiddler's picture

#4

Status:confirmed» in progress