1.ç¨vb çOpenGL å¨pictureä¸ç»ä¸ä¸ªä¸è§å½¢ã
2.å¦ä½è·å¾wglswapbuffers
ç¨vb çOpenGL å¨pictureä¸ç»ä¸ä¸ªä¸è§å½¢ã
è¦æ³å¨VB6.0ä¸ä½¿ç¨OpenGLç»å¾ï¼å¿ é¡»å ä¸è½½ä¸ä¸ªSDK,源码防伪溯源码次数ååå«vbogl.tlbã
ä¸è½½è¯¥æ件åï¼ç´æ¥å¨VB6.0âå·¥ç¨â-âå¼ç¨âéé¢å¼ç¨
1ãå¨formä¸å å ¥ä¸ä¸ªPictureBoxæ§ä»¶
2ãè¦å¨Windowséé¢ä½¿ç¨OpenGLï¼å¿ é¡»å è¿è¡åç´ æ ¼å¼è®¾ç½®ï¼å½æ°ä»£ç å¦ä¸
Dim hRC As Longâå ¨å±åé
'å¯ç¨OGL
Sub EnableOpenGL(ghDC As Long)
On Error GoTo Err
Dim pfd As PIXELFORMATDESCRIPTOR 'pfdåç´ æ ¼å¼è®¾ç½®.
ZeroMemory pfd, Len(pfd)
pfd.nSize = Len(pfd) '大å°
pfd.nVersion = 1 'çæ¬
pfd.dwFlags = PFD_DRAW_TO_WINDOW Or PFD_SUPPORT_OPENGL Or PFD_DOUBLEBUFFER 'æ å¿
pfd.iPixelType = PFD_TYPE_RGBA 'åç´ ç±»å
pfd.cColorBits = 'é¢è²ä½æ°
pfd.cDepthBits = 'ä½å®½
pfd.iLayerType = PFD_MAIN_PLANE 'å¾å±ç±»å
Dim PixFormat As Long
PixFormat = ChoosePixelFormat(ghDC, pfd) 'éæ©è®¾å¤ä¸æå¹é æ们æ设置çåç´
SetPixelFormat ghDC, PixFormat, pfd '设置æå½åçåç´
hRC = wglCreateContext(ghDC) '建ç«ç¿»è¯æ述表
wglMakeCurrent ghDC, hRC 'å°å»ºç«çç¿»è¯æ述表设置为å½å
Exit Sub
Err:
MsgBox "Can't create OpenGL context!", vbCritical, "Error"
End
End Sub
å¨å·¥ç¨çFORMçloadä¸å å ¥è°ç¨ä»£ç
Call EnableOpenGL(Picture1.hDC)
3ãä¸å¯ç¨å¯¹åºçç¦ç¨
'ç¦ç¨OGL
Sub DisableOpenGL()
wglMakeCurrent 0, 0
wglDeleteContext hRC
End Sub
å¨å·¥ç¨çformçunloadä¸å å ¥ç¦ç¨ä»£ç
Call DisableOpenGL
4ãç»å¾
Private Sub Display()
glClearColor 0#, 0#, 1#, 0# 'æ¸ ç©ºé¢è²ç¼åçRGBAé¢è²å¼
glClear clrColorBufferBit '为ç»ä¸å¸§æ²é¢æ¸ é¤ç¼å²åº
glColor3f 0.8, 0.3, 0.5 '设置æ¾ç¤ºçåä½é¢è²
glPushMatrix 'ä¾æ®å½å模å¼ï¼æ¨¡å¼-è§å¾ç©éµï¼ä½¿ç©éµå ¥æ
glBegin glBeginModeConstants.bmPolygon 'å¼å§ç»å¾ï¼ç»å¶ä¸ä¸ªä¸è§å½¢
glVertex2f -0.5, -0.5 'ä¸è§å½¢ç3个顶ç¹
glVertex2f -0.5, 0.5
glVertex2f 0.5, -0.5
glEnd
glPopMatrix 'ä¾æ®å½å模å¼ï¼æ¨¡å¼-è§å¾ç©éµï¼ä½¿ç©éµåºæ
SwapBuffers Picture1.hDC 'åæ¢ç¼å
End Sub
5ãå¨PictureBox1çPAINTäºä»¶ï¼è°ç¨æ¾ç¤ºçå½æ°
Display
å¦ä½è·å¾wglswapbuffers
å¦ä½è·å¾wglswapbuffers
wglswapbuffers
æ¯åå驱å¨å¸¦æ¥ç
ms opengl 1.1 ä¸çsourceï¼
__inline FARPROC GetAPI(char *szDll, char *szAPI, HMODULE *phDll)
{
*phDll = LoadLibraryA(szDll);
if (*phDll == NULL)
{
return NULL;
}
return GetProcAddress(*phDll, szAPI);
}
/