1

我必须在左下角的小区域进行openGl绘画。我使用 QT 小部件。 在此处输入图像描述

void GraphWidget::paintGL()
{
    glClear( GL_COLOR_BUFFER_BIT );

    glColor3f( 1 ,1 , 0 );

    glBegin( GL_POLYGON );
        glVertex2f( -0.5, -0.5 );
        glVertex2f( 0.5, -0.5 );
        glVertex2f( 0.5, 0.5 );
        glVertex2f( -0.5, 0.5 );
    glEnd();
}

我需要增加 opengl 视图的“画布”区域。

4

1 回答 1

2

It depends on how you are creating "canvas" of opengl view. In Qt, OpenGL only knows about the surface it needs to draw into, based on the Qt widget it is a part of. In your case, it appears that the widget itself is sized smaller than the mainwindow. So check how the widget you are drawing into, is created and sized. If you can share the code of the initialisation of the widget and how it is positioned in the mainwindow, it will be useful.

于 2014-02-16T17:09:56.283 回答