OpenGL-为什么使用传递参数在OnDraw函数中绘制线条不起作用?

时间:2014-07-20 07:49:42

标签: c++ opengl mfc drawing

我正在研究MFC项目和3d图形我正在使用opengl;

在OnDraw()函数中我编写了这段代码:

            int idx1 = MarkerCoordinates[SourceMarkerIndex];
            int idx2 = MarkerCoordinates[SourceMarkerIndex + 1];
            int idx3 = MarkerCoordinates[SourceMarkerIndex + 2];

            int idx4 = MarkerCoordinates[DestMarkerIndex];
            int idx5 = MarkerCoordinates[DestMarkerIndex+1];
            int idx6 = MarkerCoordinates[DestMarkerIndex+2];

            glBegin(GL_LINES);

            glVertex3f(idx1,idx2,idx3);
            glVertex3f(idx4,idx5,idx6);

            glEnd();

因为用户在运行时确定参数以定义骨骼我必须将参数传递给glVertex3f()(idxi,i = 1,2,...);但是这样,输出中没有行;如果我明确地将整数传递给glVertex3f,则绘制线条;

你能告诉我哪里错了吗?

1 个答案:

答案 0 :(得分:0)

调用Invalidate()函数来触发WM_PAINT消息,然后调用OnDraw()