Example #1
0
        internal override void UpdateDeviceParameters(byte colorBits, byte depth, byte stencil)
        {
            if (GraphicsContext != IntPtr.Zero)
            {
                FreeResources();
            }
            windowContext = GetWindowDC(windowHandle);
            PixelFormatDescriptor descriptor = new PixelFormatDescriptor {
                Size = 40, Version = 1, PixelType = ColorFormatPixelType.Rgba, ColorBits = colorBits, DepthBits = depth, StencilBits = stencil, LayerType = WglLayerType.PfdMainPlane, Flags = PixelFormatFlags, RedBits = 8, GreenBits = 8, BlueBits = 8
            };

            if (colorBits == 32)
            {
                descriptor.AlphaBits = 8;
            }
            int cacheKey = colorBits + (depth << 8) + (stencil << 16);
            int flag;

            if (PixelFormatCache.ContainsKey(cacheKey))
            {
                flag = PixelFormatCache[cacheKey];
            }
            else
            {
                flag = ChoosePixelFormat(windowContext, ref descriptor);
                PixelFormatCache.Add(cacheKey, flag);
            }
            SetPixelFormat(windowContext, flag, ref descriptor);
            GraphicsContext = CreateContext(windowContext);
            MakeCurrent();
            LoadExtensions();
        }
		internal override void UpdateDeviceParameters(byte colorBits, byte depth, byte stencil)
		{
			if (GraphicsContext != IntPtr.Zero)
				FreeResources();
			windowContext = GetWindowDC(windowHandle);
			PixelFormatDescriptor descriptor = new PixelFormatDescriptor { Size = 40, Version = 1, PixelType = ColorFormatPixelType.Rgba, ColorBits = colorBits, DepthBits = depth, StencilBits = stencil, LayerType = WglLayerType.PfdMainPlane, Flags = PixelFormatFlags, RedBits = 8, GreenBits = 8, BlueBits = 8 };
			if (colorBits == 32)
				descriptor.AlphaBits = 8;
			int cacheKey = colorBits + (depth << 8) + (stencil << 16);
			int flag;
			if (PixelFormatCache.ContainsKey(cacheKey))
				flag = PixelFormatCache[cacheKey];
			else
			{
				flag = ChoosePixelFormat(windowContext, ref descriptor);
				PixelFormatCache.Add(cacheKey, flag);
			}
			SetPixelFormat(windowContext, flag, ref descriptor);
			GraphicsContext = CreateContext(windowContext);
			MakeCurrent();
			LoadExtensions();
		}
		private static extern bool SetPixelFormat(IntPtr dc, int format, ref PixelFormatDescriptor pfd);
		public static extern int ChoosePixelFormat(IntPtr deviceContext, ref PixelFormatDescriptor pPfd);
Example #5
0
 private static extern bool SetPixelFormat(IntPtr dc, int format, ref PixelFormatDescriptor pfd);
Example #6
0
 public static extern int ChoosePixelFormat(IntPtr deviceContext, ref PixelFormatDescriptor pPfd);