在mfc下使用opengl中的vbo进行绘制,绘制失败
我在原来的mfc程序中使用了立即模式(glvertex)进行绘制,现在将代码改为使用vbo进行绘制,运行成功,但是屏幕输出为白色。ondraw绘制函数如下
wglMakeCurrent(m_pDC->GetSafeHdc(),m_hRC);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor4f(1.0,1.0,0.5,0.0);
GLfloat vertices[]={-1.0,-1.0,0.0,
1.0,0.0,0.0,
0.0,1.0,0.0};
glGenBuffers(1,&VBOId);
glBindBuffer(GL_ARRAY_BUFFER,VBOId);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW);
glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,3*sizeof(float),(GLvoid*)0);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES,0,3);
glFlush();