Commit 57168b8c authored by Christopher Tenter's avatar Christopher Tenter

add tessellation shader preview in renderobject widget

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@19509 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e54137b1
......@@ -55,6 +55,10 @@
QString const TextBrowserWidget::startRenderObjectTag_ = "name:";
QString const TextBrowserWidget::startVertexShaderTag_ = "--vertex-shader--";
QString const TextBrowserWidget::endVertexShaderTag_ = "--end-vertex-shader--";
QString const TextBrowserWidget::startTessControlShaderTag_ = "---tesscontrol-shader--";
QString const TextBrowserWidget::endTessControlShaderTag_ = "--end-tesscontrol-shader--";
QString const TextBrowserWidget::startTessEvalShaderTag_ = "--tesseval-shader--";
QString const TextBrowserWidget::endTessEvalShaderTag_ = "--end-tesseval-shader--";
QString const TextBrowserWidget::startGeometryShaderTag_ = "--geometry-shader--";
QString const TextBrowserWidget::endGeometryShaderTag_ = "--end-geometry-shader--";
QString const TextBrowserWidget::startFragmentShaderTag_ = "--fragment-shader--";
......@@ -134,6 +138,10 @@ void TextBrowserWidget::sideAreaPaintEvent(QPaintEvent *event) {
// only draw line numbers on actual shader code
if (text.contains(TextBrowserWidget::startVertexShaderTag_) ||
text.contains(TextBrowserWidget::endVertexShaderTag_) ||
text.contains(TextBrowserWidget::startTessControlShaderTag_) ||
text.contains(TextBrowserWidget::endTessControlShaderTag_) ||
text.contains(TextBrowserWidget::startTessEvalShaderTag_) ||
text.contains(TextBrowserWidget::endTessEvalShaderTag_) ||
text.contains(TextBrowserWidget::startGeometryShaderTag_) ||
text.contains(TextBrowserWidget::endGeometryShaderTag_) ||
text.contains(TextBrowserWidget::startFragmentShaderTag_) ||
......@@ -284,6 +292,62 @@ void TextBrowserWidget::updateFolds() {
endCursor = document()->find(TextBrowserWidget::endVertexShaderTag_, endCursor, QTextDocument::FindWholeWords);
}
// search for all tesscontrol shader
startCursor = document()->find(TextBrowserWidget::startTessControlShaderTag_, 0, QTextDocument::FindWholeWords);
endCursor = document()->find(TextBrowserWidget::endTessControlShaderTag_, 0, QTextDocument::FindWholeWords);
while (!startCursor.isNull() && !endCursor.isNull()) {
startCursor.movePosition(QTextCursor::StartOfLine);
endCursor.movePosition(QTextCursor::EndOfLine);
folds_.push_back(Fold(startCursor.position(),endCursor.position(),SHADER));
// map block position to fold
int startPos = startCursor.position();
const int endPos = endCursor.position();
for (; startPos < endPos; ++startPos) {
QTextBlock block = document()->findBlock(startPos);
blockPosToFold_[block.position()] = folds_.size() - 1;
}
bool moved = startCursor.movePosition(QTextCursor::Down);
if (!moved)
break;
moved = endCursor.movePosition(QTextCursor::Down);
if (!moved)
break;
startCursor = document()->find(TextBrowserWidget::startTessControlShaderTag_, startCursor, QTextDocument::FindWholeWords);
endCursor = document()->find(TextBrowserWidget::endTessControlShaderTag_, endCursor, QTextDocument::FindWholeWords);
}
// search for all tesseval shader
startCursor = document()->find(TextBrowserWidget::startTessEvalShaderTag_, 0, QTextDocument::FindWholeWords);
endCursor = document()->find(TextBrowserWidget::endTessEvalShaderTag_, 0, QTextDocument::FindWholeWords);
while (!startCursor.isNull() && !endCursor.isNull()) {
startCursor.movePosition(QTextCursor::StartOfLine);
endCursor.movePosition(QTextCursor::EndOfLine);
folds_.push_back(Fold(startCursor.position(),endCursor.position(),SHADER));
// map block position to fold
int startPos = startCursor.position();
const int endPos = endCursor.position();
for (; startPos < endPos; ++startPos) {
QTextBlock block = document()->findBlock(startPos);
blockPosToFold_[block.position()] = folds_.size() - 1;
}
bool moved = startCursor.movePosition(QTextCursor::Down);
if (!moved)
break;
moved = endCursor.movePosition(QTextCursor::Down);
if (!moved)
break;
startCursor = document()->find(TextBrowserWidget::startTessEvalShaderTag_, startCursor, QTextDocument::FindWholeWords);
endCursor = document()->find(TextBrowserWidget::endTessEvalShaderTag_, endCursor, QTextDocument::FindWholeWords);
}
// search for all geometry shader
startCursor = document()->find(TextBrowserWidget::startGeometryShaderTag_, 0, QTextDocument::FindWholeWords);
endCursor = document()->find(TextBrowserWidget::endGeometryShaderTag_, 0, QTextDocument::FindWholeWords);
......
......@@ -122,6 +122,10 @@ class TextBrowserWidget : public QPlainTextEdit
static QString const startRenderObjectTag_;
static QString const startVertexShaderTag_;
static QString const endVertexShaderTag_;
static QString const startTessControlShaderTag_;
static QString const endTessControlShaderTag_;
static QString const startTessEvalShaderTag_;
static QString const endTessEvalShaderTag_;
static QString const startGeometryShaderTag_;
static QString const endGeometryShaderTag_;
static QString const startFragmentShaderTag_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment