你的问题是: 在程序初始化 OpenGL的时候没有采用异常捕获,结果
出现初始化发生错误时系统中止你的程序执行。
可以在OpenGL的初始化代码处加入
try ,catch捕获异常,将错误的地方修改过来。还有,静态连接三个库没有问题的。最好 你将你的初始化部分代码贴出来看看。

解决方案 »

  1.   

    int CDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    if (CView::OnCreate(lpCreateStruct) == -1)
    return -1;

    // TODO: Add your specialized creation code here
    PIXELFORMATDESCRIPTOR pfd={
    sizeof(PIXELFORMATDESCRIPTOR),
    1,
    PFD_DRAW_TO_WINDOW|
    PFD_SUPPORT_OPENGL|
    PFD_DOUBLEBUFFER,
    PFD_TYPE_RGBA,
    24,
    0,0,0,0,0,0,
    0,
    0,
    0,
    0,0,0,0,
    32,
    0,
    0,
    PFD_MAIN_PLANE,
    0,
    0,0,0,
    };
    //GET THe DC for the client area
    CClientDC clientdc(this);
    //return the requested pixel format closely matched
        int pf=ChoosePixelFormat(clientdc.m_hDC,&pfd);
    //set the pixel format
    BOOL rt=SetPixelFormat(clientdc.m_hDC,pf,&pfd);
    hglrc=wglCreateContext(clientdc.m_hDC);
    return 0;
    }BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    if( !CFrameWnd::PreCreateWindow(cs) )
    return FALSE;
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs
        cs.cx=500;
    cs.cy=400;
    //caption definition
    cs.lpszName="Generic";
    //
    cs.style&=~FWS_ADDTOTITLE;
    return CFrameWnd::PreCreateWindow(cs);
    return TRUE;
    }
    这位兄弟,我可否将程序打包,给你发过去,你帮我看看吧,谢了
      

  2.   

    void CDemoView::OnDraw(CDC* pDC)
    {
    CDemoDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
    wglMakeCurrent(pDC->m_hDC,hglrc);
    draw1();
        wglMakeCurrent(pDC->m_hDC,NULL);
        SwapBuffers(pDC->m_hDC);
    }
    void CDemoView::OnDestroy() 
    {
    if(wglGetCurrentContext()!=NULL)
         wglMakeCurrent(NULL,NULL);
        if(hglrc!=NULL)
    {  
    wglDeleteContext(hglrc);
    hglrc=NULL;
    }
    CView::OnDestroy();

    // TODO: Add your message handler code here
    }