QT中使用OpenGL绘图(2)

#include <QtGui/QApplication> 
#include "glwidget.h" 
 
int main(int argc, char *argv[]) 

    QApplication a(argc, argv); 
    GLWidget w; 
    w.show(); 
     
    return a.exec(); 

QT中使用OpenGL绘图

说明:
(1) 绘图工作:

voidGLWidget::paintGL()

这个是主要的绘图函数,整个的绘图工作都在这个里面。

(2) 坐标点:

OpenGL的坐标点的范围-1到1。

(3) 如何在OpenGL图形周围写字:

renderText(20,100,"HelloJcy,MyfirstOpenGLapp.");

第一个跟第二个参数是坐标位置,第三个是需要显示的字。

可能出现的错误:

(1)错误:C1083: Cannot open include file: 'QtOpenGL': No such file or directory

如果你是这个错误,那么你需要在.pro文件中添加QT += opengl

(2)错误:C2504: 'QGLWidget' : base class undefined

如果你是这个错误,那么请你在.h文件中添加 #include<QtOpenGL>

(3)错误:C2039: 'show' : is not a member of 'GLWidget'

如果你是这个错误,那么请你在.h文件中添加 #include<QtOpenGL>

上面的代码参考了Qt_OpenGL教程

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/ce3b47a2126f8e6ec8fa33c5c9c177b6.html