Example #1
0
        public void InitializeOpenGL( )
        {
            this.dcHandle = USER32.GetDC(this.wHandle);

            GDI32.PIXELFORMATDESCRIPTOR pfd = new GDI32.PIXELFORMATDESCRIPTOR( );
            pfd.nSize        = ( ushort )Marshal.SizeOf(pfd);
            pfd.nVersion     = 1;
            pfd.dwFlags      = (OPENGL32.PFD_DRAW_TO_WINDOW | OPENGL32.PFD_SUPPORT_OPENGL | OPENGL32.PFD_DOUBLEBUFFER);
            pfd.iPixelType   = OPENGL32.PFD_TYPE_RGBA;
            pfd.cColorBits   = 24;
            pfd.cDepthBits   = 16;
            pfd.cStencilBits = 8;
            pfd.iLayerType   = OPENGL32.PFD_MAIN_PLANE;

            int pixelFormat = GDI32.ChoosePixelFormat(this.dcHandle, pfd);

            GDI32.SetPixelFormat(this.dcHandle, pixelFormat, pfd);

            this.wglContext = OPENGL32.wglCreateContext(this.dcHandle);
            OPENGL32.wglMakeCurrent(this.dcHandle, this.wglContext);

            this.Initialize( );
        }