日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

第一个QGLViewer程序

發布時間:2025/3/16 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第一个QGLViewer程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境:vs2017 + qt5.11 + QGLViewer2.7.1

1、新建QtGUIApplication

新建一個QtGUIApplication(勾上opengl或者自己配置opengl32.lib,glu32.lib)

2、?配置QGLViewer

配置QGLViewer(包含目錄、庫目錄、附加依賴項)

release模式QGLViewer2.lib(release模式QGLViewerd2.lib)?

3、加入QGLViewer窗口

ui文件(Form Files/mainwindow.ui)

?文件中填上頭文件,運行報錯

缺少XML module,Qt Project Settings->Qt Modules

?

?ok,跑起來了

4、繪制圖像

頭文件mainwindow.h中添加:

protected Q_SLOTS:void draw();

?mainwindow.cpp文件中添加:

void MainWindow::draw() {//官方圖像鎮樓// Draws a spiralconst float nbSteps = 200.0;glBegin(GL_QUAD_STRIP);for (float i = 0; i < nbSteps; ++i) {float ratio = i / nbSteps;float angle = 21.0 * ratio;float c = cos(angle);float s = sin(angle);float r1 = 1.0 - 0.8 * ratio;float r2 = 0.8 - 0.8 * ratio;float alt = ratio - 0.5;const float nor = .5;const float up = sqrt(1.0 - nor * nor);glColor3f(1.0 - ratio, 0.2f, ratio);glNormal3f(nor * c, up, nor * s);glVertex3f(r1 * c, alt, r1 * s);glVertex3f(r2 * c, alt + 0.05, r2 * s);}glEnd(); }

初始化時連接viewer和draw函數:

MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {ui.setupUi(this);connect(ui.viewer, SIGNAL(drawNeeded()), this, SLOT(draw())); }

運行(官方圖鎮樓)

源碼:

總結

以上是生活随笔為你收集整理的第一个QGLViewer程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。