private GetConfig ( |
||
dpy | ||
vis | ||
attrib | GLXAttribute | |
value | int | |
return | int |
private static GraphicsMode CreateGraphicsMode(IntPtr display, ref XVisualInfo info) { // See what we *really* got: int r, g, b, a; Glx.GetConfig(display, ref info, GLXAttribute.ALPHA_SIZE, out a); Glx.GetConfig(display, ref info, GLXAttribute.RED_SIZE, out r); Glx.GetConfig(display, ref info, GLXAttribute.GREEN_SIZE, out g); Glx.GetConfig(display, ref info, GLXAttribute.BLUE_SIZE, out b); int ar, ag, ab, aa; Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_ALPHA_SIZE, out aa); Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_RED_SIZE, out ar); Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_GREEN_SIZE, out ag); Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_BLUE_SIZE, out ab); int depth, stencil, samples, buffers; Glx.GetConfig(display, ref info, GLXAttribute.DEPTH_SIZE, out depth); Glx.GetConfig(display, ref info, GLXAttribute.STENCIL_SIZE, out stencil); Glx.GetConfig(display, ref info, GLXAttribute.SAMPLES, out samples); Glx.GetConfig(display, ref info, GLXAttribute.DOUBLEBUFFER, out buffers); int st; Glx.GetConfig(display, ref info, GLXAttribute.STEREO, out st); // Note: Glx.GetConfig return buffers = 0 (false) or 1 (true). // OpenTK expects buffers = 1 (single-) or 2 (double-buffering), // so increase the GLX value by one. return(new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, samples, new ColorFormat(ar, ag, ab, aa), buffers + 1, st != 0)); }
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo) { GraphicsMode gfx; // The actual GraphicsMode that will be selected. IntPtr visual = IntPtr.Zero; IntPtr display = API.DefaultDisplay; // 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); if (visual == IntPtr.Zero) { visual = SelectVisualUsingChooseVisual(color, depth, stencil, samples, accum, buffers, stereo); } if (visual == IntPtr.Zero) { throw new GraphicsContextException("Requested GraphicsMode not available."); } XVisualInfo info = (XVisualInfo)Marshal.PtrToStructure(visual, typeof(XVisualInfo)); // See what we *really* got: int r, g, b, a; Glx.GetConfig(display, ref info, GLXAttribute.ALPHA_SIZE, out a); Glx.GetConfig(display, ref info, GLXAttribute.RED_SIZE, out r); Glx.GetConfig(display, ref info, GLXAttribute.GREEN_SIZE, out g); Glx.GetConfig(display, ref info, GLXAttribute.BLUE_SIZE, out b); int ar, ag, ab, aa; Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_ALPHA_SIZE, out aa); Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_RED_SIZE, out ar); Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_GREEN_SIZE, out ag); Glx.GetConfig(display, ref info, GLXAttribute.ACCUM_BLUE_SIZE, out ab); Glx.GetConfig(display, ref info, GLXAttribute.DEPTH_SIZE, out depth); Glx.GetConfig(display, ref info, GLXAttribute.STENCIL_SIZE, out stencil); Glx.GetConfig(display, ref info, GLXAttribute.SAMPLES, out samples); Glx.GetConfig(display, ref info, GLXAttribute.DOUBLEBUFFER, out buffers); ++buffers; // the above lines returns 0 - false and 1 - true. int st; Glx.GetConfig(display, ref info, GLXAttribute.STEREO, out st); stereo = st != 0; gfx = new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, samples, new ColorFormat(ar, ag, ab, aa), buffers, stereo); using (new XLock(display)) { Functions.XFree(visual); } return(gfx); }
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo) { IntPtr num1 = IntPtr.Zero; IntPtr defaultDisplay = API.DefaultDisplay; IntPtr num2 = this.SelectVisualUsingFBConfig(color, depth, stencil, samples, accum, buffers, stereo); if (num2 == IntPtr.Zero) { num2 = this.SelectVisualUsingChooseVisual(color, depth, stencil, samples, accum, buffers, stereo); } if (num2 == IntPtr.Zero) { throw new GraphicsModeException("Requested GraphicsMode not available."); } XVisualInfo vis = (XVisualInfo)Marshal.PtrToStructure(num2, typeof(XVisualInfo)); int alpha1; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.ALPHA_SIZE, out alpha1); int red1; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.RED_SIZE, out red1); int green1; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.GREEN_SIZE, out green1); int blue1; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.BLUE_SIZE, out blue1); int alpha2; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.ACCUM_ALPHA_SIZE, out alpha2); int red2; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.ACCUM_RED_SIZE, out red2); int green2; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.ACCUM_GREEN_SIZE, out green2); int blue2; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.ACCUM_BLUE_SIZE, out blue2); Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.DEPTH_SIZE, out depth); Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.STENCIL_SIZE, out stencil); Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.SAMPLES, out samples); Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.DOUBLEBUFFER, out buffers); ++buffers; int num3; Glx.GetConfig(defaultDisplay, ref vis, GLXAttribute.STEREO, out num3); stereo = num3 != 0; GraphicsMode graphicsMode = new GraphicsMode(new IntPtr?(vis.VisualID), new ColorFormat(red1, green1, blue1, alpha1), depth, stencil, samples, new ColorFormat(red2, green2, blue2, alpha2), buffers, stereo); using (new XLock(defaultDisplay)) Functions.XFree(num2); return(graphicsMode); }