opengl.cpp
资源名称:XLT.rar [点击查看]
上传用户:yunyi28
上传日期:2021-04-25
资源大小:6978k
文件大小:1k
源码类别:
分形几何
开发平台:
Visual C++
- #include "opengl.h"
- #include "math.h"
- HGLRC hRC=NULL;
- HWND hwd=NULL;
- opengl::opengl(void)
- {
- }
- opengl::~opengl(void)
- {
- }
- BOOL opengl::SetupPixelFormat(HDC hDC)
- {
- int nPixelFormat;
- PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,PFD_TYPE_RGBA,16,0,0,0,0,0,0,
- 0,0,0,
- 0,0,0,0,32,1,0,PFD_MAIN_PLANE,0,0,0,0};
- if(!(nPixelFormat=ChoosePixelFormat(hDC,&pfd)))
- {
- MessageBox(NULL,"找不到","Error",MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
- }
- SetPixelFormat(hDC,nPixelFormat,&pfd);
- hRC=wglCreateContext(hDC);
- wglMakeCurrent(hDC,hRC);
- return true;
- }
- void opengl::init(HWND hwnd,int Width,int Height)
- {
- hwd = hwnd;
- glViewport(0,0,Width,Height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(45.0f,(float)Width/Height,1.0f,500.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- void opengl::CleanUp()
- {
- wglMakeCurrent(hDC,NULL);
- wglDeleteContext(hRC);
- }
- void opengl::Render()
- {
- // for(int r=0;r<=360;r++)
- // {
- // glClearColor(0.0f,0.0f,0.0f,0.0f);
- // glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- // glLoadIdentity();
- ///
- // m_bsipic.airplane(0,8,-50,r);
- ///
- //
- // }
- // m_bsipic.TriAndQuad_3D();
- // m_bsipic.Pbmp();
- // m_bsipic.StencilQuads();
- m_bsipic.Trees();
- // m_bsipic.IsPlane();
- glFlush();
- SwapBuffers(hDC);
- }
- void opengl::ClearUI()
- {
- //glutCreateSubWindow((int)hwd, 0, 0, 200, 200);
- }