資源簡(jiǎn)介
此程序附帶了演示程序和源代碼。
-------------------------------------------------
歡迎訪問我的博客:
http://blog.csdn.net/gamesdev
此資源相關(guān)的博文:
http://blog.csdn.net/gamesdev/article/details/10295961
http://blog.csdn.net/gamesdev/article/details/10296587
-------------------------------------------------
我的計(jì)算機(jī)換成新的了,可以支持OpenGL2.0以及以上的規(guī)范,這樣我開始正式涉足OpenGL高級(jí)的內(nèi)容了。目前我的OpenGL基礎(chǔ)庫(kù)是Qt,它有完備的功能,以及對(duì)OpenGL一層好的封裝,所以用它來(lái)開發(fā)基于OpenGL的應(yīng)用程序非常合適。下面是我就來(lái)介紹一下如何開發(fā)基于Qt和GLSL的程序。
我制作的這個(gè)小例子還帶了一個(gè)著色器編輯器。支持即時(shí)編譯鏈接著色器,支持在GLSL規(guī)定的語(yǔ)法高亮,有關(guān)語(yǔ)法高亮的內(nèi)容,感興趣的同學(xué)可以下載一下。

代碼片段和文件信息
/*?┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
?*?┃?????┏━┣━┣┓ ┏┓┏┓┳┓┏━━┓┣┣━┓ ┓ ┓┣┳━┓???????┃
?*?┃?????┏┏┏╯━┓┳┳━┛┏╯┃┃┃ ┃┣┣━┓┃┃ ┃┃┃ ???????┃
?*?┃?????┃┃┏━╮┃┗┗┏╯┗┃┃╯┃ ┃┏┣━┓┃┃ ┃╯┣━┓???????┃
?*?┃?????╰┫┏━┻╯┗┳┣┛┏┛┃┃┣━━┫┃┃ ┃┃┃┗╯ ┃ ???????┃
?*?┃?????┏┫━┳━┫┏┃┣┓┗┃┃╯┃ ┃┃┃ ┃ ┃ ┃ ┣━┓???????┃
?*?┃?????┗┗┗━━╯┗┛┛╯┗╯╰ ┗━━╯ ┛ ┛┗╯ ╰┛┗ ???????┃
?*?┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
?*?┃?????????????????????Copyright?(c)?2013?jiangcaiyang????????????????????┃
?*?┃?This?software?is?provided?‘a(chǎn)s-is‘?without?any?express?or?implied??????┃
?*?┃?warranty.?In?no?event?will?the?authors?be?held?liable?for?any?damages??┃
?*?┃?arising?from?the?use?of?this?software.?????????????????????????????????┃
?*?┃????????????????????????????????????????????????????????????????????????┃
?*?┃?Permission?is?granted?to?anyone?to?use?this?software?for?any?purpose??┃
?*?┃?including?commercial?applications?and?to?alter?it?and?redistribute?it?┃
?*?┃?freely?subject?to?the?following?restrictions:?????????????????????????┃
?*?┃????????????????????????????????????????????????????????????????????????┃
?*?┃?1.?The?origin?of?this?software?must?not?be?misrepresented;?you?must????┃
?*?┃????not?claim?that?you?wrote?the?original?software.?If?you?use?this?????┃
?*?┃????software?in?a?product?an?acknowledgment?in?the?product?????????????┃
?*?┃????documentation?would?be?appreciated?but?is?not?required.?????????????┃
?*?┃?2.?Altered?source?versions?must?be?plainly?marked?as?such?and?must????┃
?*?┃????not?be?misrepresented?as?being?the?original?software.???????????????┃
?*?┃?3.?This?notice?may?not?be?removed?or?altered?from?any?source???????????┃
?*?┃????distribution.???????????????????????????????????????????????????????┃
?*?┃????????????????????????????????????????????????????????????????????????┃
?*?┃?jiangcaiyang?jiangcaiyang123@163.com???????????????????????????????????┃
?*?┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
?*?┃?file?name:?Camera.cpp??????????????????????????????????????????????????┃
?*?┃?create?date:?2013年8月2日星期五?14時(shí)12分49秒???????????????????????????┃
?*?┃?last?modified?date:?2013年8月22日星期四?22時(shí)46分0秒????????????????????┃
?*?┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
?*/
#include?
#include?“Camera.h“
/*---------------------------------------------------------------------------*/
Camera::Camera(?void?)
{
????m_Pos?=?QVector3D(?0?0?0?);
????m_RotateY?=?0.0;
????m_RotateH?=?0.0;
????m_Len?=?QVector3D(?0?0?0?);
????m_TryPos?=?QVector3D(?0?0?0?);
????m_TryRotateY?=?0.0;
????m_TryRotateH?=?0.0;
????m_Try?=?false;
}
/*---------------------------------------------------------------------------*/
void?Camera::SetPos(?const?QVector3D?pos?bool?_try?)
{
????m_Try?=?_try;
????if?(?m_Try?)?m_TryPos?=?pos;
????else
????{
????????m_Pos?+=?pos;
????????m_Offset2D?+=?QVector3D(?pos.x(?)?pos.y(?)?0?);
????????m_TryPos?=?QVector3D(?0?0?0?);
????}
}
void?Camera::SetRotateY(?float?rotateY?bool?_try?)
{
????m_Try?=?_try;
????if?(?m_Try?)?m_TryRotateY?=?rotateY;
?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-08-24?23:48??bin\
?????文件?????6257152??2013-08-24?23:45??bin\QtShader.exe
?????目錄???????????0??2013-08-24?23:50??source\
?????文件???????16958??2013-08-24?23:39??source\appIcon.ico
?????文件????????4940??2013-08-24?23:30??source\Camera.cpp
?????文件????????3999??2013-08-24?23:30??source\Camera.h
?????文件??????????55??2013-08-18?21:26??source\DefaultShader.frag
?????文件?????????117??2013-08-19?23:42??source\DefaultShader.vert
?????目錄???????????0??2013-08-24?23:50??source\Feedback\
?????文件?????????205??2013-08-23?22:25??source\Feedback\Feedback.pri
?????文件?????????147??2013-08-04?19:45??source\Feedback\Feedback.qrc
?????文件????????4042??2013-08-24?23:32??source\Feedback\FeedbackDialog.h
?????文件????????2789??2013-07-12?20:40??source\Feedback\pushButtonBackground.png
?????文件??????100003??2013-07-12?20:34??source\Feedback\textEditBackground.png
?????文件???????12743??2013-08-24?23:30??source\GLWidget.cpp
?????文件????????4349??2013-08-24?23:30??source\GLWidget.h
?????目錄???????????0??2013-08-24?23:50??source\Icon\
?????文件?????????138??2013-08-21?22:26??source\Icon.qrc
?????文件?????????532??2013-08-18?21:59??source\Icon\compileIcon.png
?????文件????????1384??2013-08-21?22:24??source\Icon\saveIcon.png
?????目錄???????????0??2013-08-24?23:50??source\lib\
?????文件??????594648??2013-08-24?22:33??source\lib\libFeedback.a
?????文件????????3285??2013-08-24?23:30??source\main.cpp
?????文件????????7162??2013-08-24?23:30??source\MainWindow.cpp
?????文件????????3377??2013-08-24?23:30??source\MainWindow.h
?????文件????????3522??2013-08-24?23:45??source\QtShader_3.pro
?????文件?????????143??2013-08-18?20:22??source\Shader.qrc
?????文件????????5484??2013-08-24?23:30??source\ShaderDialog.cpp
?????文件????????3746??2013-08-24?23:30??source\ShaderDialog.h
?????文件????????2470??2013-08-23?22:18??source\ShaderDialog.ui
?????目錄???????????0??2013-08-24?23:50??source\ShaderEditor\
............此處省略8個(gè)文件信息
評(píng)論
共有 條評(píng)論