在MFC的单文档中用OpenGL画图,画图函数明明运行了,为什么就是显示不出来?画图函数如下: 20
voidCMyView::DrawScene(void){glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glBegin...
void CMyView::DrawScene(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES); // 绘制三角形
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 10.0f, 0.0f); // 上顶点
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(10.0f,0.0f, 0.0f); // 左下
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 10.0f,20.0f, 0.0f); // 右下
glEnd();
glFinish();
CString str("Hello,World!");
m_pDC->TextOut(10,109,str);
}
hello world 可以显示出来
m_pDC= new CClientDC(this);
m_hDC=m_pDC->GetSafeHdc();//创建DC
ASSERT(m_pDC != NULL);
if (!SetupPixelFormat()) //设定绘图的位图格式,函数下面列出
return;
m_hRC= wglCreateContext(m_pDC->m_hDC);//创建 RC
wglMakeCurrent(m_pDC->m_hDC, m_hRC); //RC 与当前 DC 相关联 展开
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES); // 绘制三角形
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 10.0f, 0.0f); // 上顶点
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(10.0f,0.0f, 0.0f); // 左下
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 10.0f,20.0f, 0.0f); // 右下
glEnd();
glFinish();
CString str("Hello,World!");
m_pDC->TextOut(10,109,str);
}
hello world 可以显示出来
m_pDC= new CClientDC(this);
m_hDC=m_pDC->GetSafeHdc();//创建DC
ASSERT(m_pDC != NULL);
if (!SetupPixelFormat()) //设定绘图的位图格式,函数下面列出
return;
m_hRC= wglCreateContext(m_pDC->m_hDC);//创建 RC
wglMakeCurrent(m_pDC->m_hDC, m_hRC); //RC 与当前 DC 相关联 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询