Translate

tutorial graphic halaman 4

Selamat datang di eagleboot dan selamat membaca.

}} else { /*OpenGLanimationcodegoeshere*/ glClearColor(1.0f,1.0f,1.0f,0.0f); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); glColor3f(0.0f,0.0f,0.0f);glVertex2f(0.0f,0.5f); glColor3f(0.0f,0.0f,0.0f);glVertex2f(0.0f,‐0.5f); glColor3f(0.0f,0.0f,0.0f);glVertex2f(0.5f,0.0f); glColor3f(0.0f,0.0f,0.0f);glVertex2f(‐0.5f,0.0f); glEnd(); SwapBuffers(hDC); } } /*shutdownOpenGL*/ DisableOpenGL(hWnd,hDC,hRC); /*destroythewindowexplicitly*/ DestroyWindow(hWnd); returnmsg.wParam; } /******************** *WindowProcedure ********************/ LRESULTCALLBACKWndProc(HWNDhWnd,UINTmessage, WPARAMwParam,LPARAMlParam) { switch(message) { caseWM_CREATE: return0; caseWM_CLOSE: PostQuitMessage(0); return0; caseWM_DESTROY: return0; caseWM_KEYDOWN: switch(wParam) { caseVK_ESCAPE: PostQuitMessage(0); return0; } return0; default: returnDefWindowProc(hWnd,message,wParam,lParam); } } /******************* *EnableOpenGL *******************/ voidEnableOpenGL(HWNDhWnd,HDC*hDC,HGLRC*hRC) { PIXELFORMATDESCRIPTORpfd; intiFormat; /*getthedevicecontext(DC)*/ *hDC=GetDC(hWnd); /*setthepixelformatfortheDC*/ ZeroMemory(&pfd,sizeof(pfd)); pfd.nSize=sizeof(pfd); pfd.nVersion=1; 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; iFormat=ChoosePixelFormat(*hDC,&pfd); SetPixelFormat(*hDC,iFormat,&pfd); /*createandenabletherendercontext(RC)*/ *hRC=wglCreateContext(*hDC); wglMakeCurrent(*hDC,*hRC); } /****************** *DisableOpenGL ******************/ voidDisableOpenGL(HWNDhWnd,HDChDC,HGLRChRC) { wglMakeCurrent(NULL,NULL); wglDeleteContext(hRC); ReleaseDC(hWnd,hDC); }

Next read halaman 5.

Share this

Related Posts

Previous
Next Post »