Esempio n. 1
0
    def InitOpenGLContext(self):
        _user32 = WinDLL('user32')
        GetDC = _user32.GetDC
        GetDC.restype = HDC
        GetDC.argtypes = [c_void_p]
        pfd = PIXELFORMATDESCRIPTOR()
        PFD_TYPE_RGBA = 0
        PFD_MAIN_PLANE = 0
        PFD_DOUBLEBUFFER = 0x00000001
        PFD_DRAW_TO_WINDOW = 0x00000004
        PFD_SUPPORT_OPENGL = 0x00000020
        pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER
        pfd.iPixelType = PFD_TYPE_RGBA
        pfd.cColorBits = 24
        pfd.cDepthBits = 16
        pfd.iLayerType = PFD_MAIN_PLANE

        self.hwnd = self.winfo_id()
        self.hdc = GetDC(self.hwnd)
        pixelformat = ChoosePixelFormat(self.hdc, pfd)
        SetPixelFormat(self.hdc, pixelformat, pfd)
        self.hrc = wglCreateContext(self.hdc)
        self.OpenGLActiveContext()
        self.OpenGLResizeViewport()
Esempio n. 2
0
 def tkCreateContext(self):
     self.__window = GetDC(self.winfo_id())
     pixelformat = ChoosePixelFormat(self.__window, pfd)
     SetPixelFormat(self.__window, pixelformat, pfd)
     self.__context = wglCreateContext(self.__window)
     wglMakeCurrent(self.__window, self.__context)