QT 學習OpenGL序列 Helloworld

2021-10-03 21:23:09 字數 1572 閱讀 7752

本序列幾乎是按照learnopengl在qt上進行實現:

(1) 標頭檔案

#ifndef copenglwidgethellowidget_h

#define copenglwidgethellowidget_h

/* * 控制項名稱:hello qopenglwidget

* ** 注意:std c++ version >= c++11

* author: hsw

**/#include // opengl函式

class copenglwidgethellowidget : public qopenglwidget, public qopenglfunctions

;#endif // copenglwidgethellowidget_h

#ifndef mainwindow_h

#define mainwindow_h

#include "copenglwidgethellowidget.h"

#include namespace ui

class mainwindow : public qmainwindow

;#endif // mainwindow_h

(2) cpp檔案

#include "copenglwidgethellowidget.h"

copenglwidgethellowidget::copenglwidgethellowidget(qwidget *parent) : qopenglwidget(parent)

copenglwidgethellowidget::~copenglwidgethellowidget()

void copenglwidgethellowidget::initializegl()

// 視窗調整

void copenglwidgethellowidget::resizegl(int width, int height)

// 視窗重新繪製

// 注意:呼叫update()和paintevent()時都會自動呼叫paintgl()

//void copenglwidgethellowidget::paintgl()

bool copenglwidgethellowidget::eventfilter(qobject *obj, qevent * event)}}

}return false;

}

#include "mainwindow.h"

#include "ui_mainwindow.h"

mainwindow::mainwindow(qwidget *parent) :

qmainwindow(parent),

ui(new ui::mainwindow)

mainwindow::~mainwindow()

3. 效果

QT學習OpenGL序列 HelloShaders

學習opengl sharder 注意opengl 3.3版本以上支援 1 標頭檔案 ifndef copenglwidgethelloshaders h define copenglwidgethelloshaders h 控制項名稱 hello shaders 注意 std c version ...

qt環境下學習OpenGL

當你開始選在在linux平台,或者其他非windows平台搗鼓opengl的時候,你就會感受到了opengl比dx強大的地方了。切入正題。其次,你完全可以搬nehe教程 該教程是在win平台的 來學習,opengl是支援跨平台的。而你程式無法執行都是非gl函式造成的。如果你是在qt下的話,你可以參考...

QT學習VTK序列 Cone

學習vtk繪製圓錐體 vtkconesource 表示生成圓錐資料,其中,圓錐資料報含幾個部分 1 底面圓中心 2 底面半徑 3 圓錐角度 和半徑相似的功能 4 圓錐高度 5 圓錐角度 setcenter 設定圓底面中心位置 setradius 設定圓底面半徑 setangle 設定圓錐頂角,單位為...