关于openGL的问题,兄弟们多多指教啊 你的问题是: 在程序初始化 OpenGL的时候没有采用异常捕获,结果出现初始化发生错误时系统中止你的程序执行。可以在OpenGL的初始化代码处加入try ,catch捕获异常,将错误的地方修改过来。还有,静态连接三个库没有问题的。最好 你将你的初始化部分代码贴出来看看。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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;}这位兄弟,我可否将程序打包,给你发过去,你帮我看看吧,谢了 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} CDC.SelectObject(CDC.GetCurrentBitmap)后图像显示不出来 关于文件头的定义 MFC什么控件可以显示HTML格式的文件 求此函数的详解? 如何改变文件夹的图标,不使用Desktop.ini Opera无法浏览 如何对话框中加入状态栏 怎么做??从VARIANT*转换到AnsiString! 一个有关VC中头文件的引用问题? 多线程的问题!急!! !!!!一个关于ODBC的问题!!!!! 请问,怎样在菜单中加入图标?
{
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;
}
这位兄弟,我可否将程序打包,给你发过去,你帮我看看吧,谢了
{
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
}