Dim m_hGLRC As Long Private Sub Form_Initialize() Initialize ViewSet 50, Picture1.ScaleHeight / Picture1.ScaleWidth, 1, 100 End Sub Private Sub Picture1_Paint() Draw End Sub Private Function Initialize() As Boolean Dim pfd As PIXELFORMATDESCRIPTOR Dim R As Long Picture1.ScaleMode = vbPixels 'set standard parameters pfd.nSize = Len(pfd) pfd.nVersion = 1 pfd.dwFlags = PFD_SUPPORT_OPENGL Or PFD_DRAW_TO_WINDOW Or PFD_SINGLE Or PFD_TYPE_RGBA pfd.iPixelType = PFD_TYPE_RGBA pfd.cColorBits = 24 pfd.cDepthBits = 16 pfd.iLayerType = PFD_MAIN_PLANE R = ChoosePixelFormat(Picture1.hDC, pfd) If R = 0 Then MsgBox "ChoosePixelFormat failed" Exit Function End If R = SetPixelFormat(Picture1.hDC, R, pfd) m_hGLRC = wglCreateContext(Picture1.hDC) wglMakeCurrent Picture1.hDC, m_hGLRC Initialize = True End Function Private Sub Form_Unload(Cancel As Integer) If m_hGLRC <> 0 Then wglMakeCurrent 0, 0 wglDeleteContext m_hGLRC End If End Sub Private Sub ViewSet(fov As Single, aspect As Single, near As Single, far As Single) glMatrixMode GL_PROJECTION glLoadIdentity gluPerspective fov, aspect, near, far glMatrixMode GL_MODELVIEW End Sub Public Sub Draw() glClearColor 0, 0, 0, 0 glClear GL_COLOR_BUFFER_BIT glColor3f 1#, 1#, 1# glLoadIdentity glTranslatef 0#, 0#, -5# glScalef 1#, 1#, 1# glutWireCube 1 glFlush End Sub