public WindowsGameWindow(WindowsProgramContext context) { RegisterClass(); CreateWindow(context); _stopwatch = new Stopwatch(); _stopwatch2 = new Stopwatch(); }
private void CreateWindow(WindowsProgramContext context) { _title = context.Name; var style = Win32.WindowStyles.OverlappedWindow; if (!context.AllowWindowResize) { style &= ~Win32.WindowStyles.ThickFrame; } _hwnd = Win32.CreateWindowEx(0, ClassName, context.Name, (uint)style, 100, 100, 800, 600, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (context.WindowSize.x > 0 && context.WindowSize.y > 0) { Resize(context.WindowSize); } _hdc = Win32.GetDC(_hwnd); Win32.RECT clientRect = new Win32.RECT(); Win32.GetClientRect(_hwnd, out clientRect); _clientSize = new Win32.SIZE(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); // Set the pixel format for this DC var pfd = new Win32.PixelFormatDescriptor { Size = (short)Marshal.SizeOf <Win32.PixelFormatDescriptor>(), Version = 1, Flags = Win32.PixelFormatDescriptorFlags.DRAW_TO_WINDOW | Win32.PixelFormatDescriptorFlags.SUPPORT_OPENGL | Win32.PixelFormatDescriptorFlags.DOUBLEBUFFER, PixelType = Win32.PixelType.Rgba, ColorBits = 32, RedBits = 0, RedShift = 0, GreenBits = 0, GreenShift = 0, BlueBits = 0, BlueShift = 0, AlphaBits = 0, AlphaShift = 0, AccumBits = 0, AccumRedBits = 0, AccumGreenBits = 0, AccumBlueBits = 0, AccumAlphaBits = 0, DepthBits = 32, StencilBits = 8, AuxBuffers = 0, LayerType = 0, LayerMask = 0, DamageMask = 0 }; int id = Win32.ChoosePixelFormat(_hdc, ref pfd); Win32.SetPixelFormat(_hdc, id, ref pfd); _hglrc = Win32.CreateContext(_hdc); Win32.MakeCurrent(_hdc, _hglrc); // Disable V-Sync ? GL.Imports.wglSwapIntervalEXT(0); }