diff options
author | Mark Janes <mark.a.janes@intel.com> | 2017-10-31 15:23:48 -0700 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2017-11-27 11:29:20 -0800 |
commit | a2a2c2872533685f0878584a61813bc795f60f2a (patch) | |
tree | 8147be3771160e4dd9d86fb5f233824204109d90 /retrace | |
parent | af7612e02e8c16e4a6b1477288024e6d2b7aa874 (diff) |
State: Handle GL_LINE_WIDTH
Diffstat (limited to 'retrace')
-rw-r--r-- | retrace/daemon/gldispatch/glframe_glhelper.cpp | 9 | ||||
-rw-r--r-- | retrace/daemon/gldispatch/glframe_glhelper.hpp | 1 | ||||
-rw-r--r-- | retrace/daemon/glframe_state_enums.cpp | 1 | ||||
-rw-r--r-- | retrace/daemon/glframe_state_override.cpp | 31 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_state_model.cpp | 41 | ||||
-rw-r--r-- | retrace/daemon/ui/qml/StateControl.qml | 18 |
6 files changed, 84 insertions, 17 deletions
diff --git a/retrace/daemon/gldispatch/glframe_glhelper.cpp b/retrace/daemon/gldispatch/glframe_glhelper.cpp index aa2a4357..501d0942 100644 --- a/retrace/daemon/gldispatch/glframe_glhelper.cpp +++ b/retrace/daemon/gldispatch/glframe_glhelper.cpp @@ -121,6 +121,7 @@ static void *pUniformMatrix4x2fv = NULL; static void *pUniformMatrix4x3fv = NULL; static void *pFinish = NULL; static void *pCullFace = NULL; +static void *pLineWidth = NULL; } // namespace @@ -333,6 +334,8 @@ GlFunctions::Init(void *lookup_fn) { assert(pFinish); pCullFace = _GetProcAddress("glCullFace"); assert(pCullFace); + pLineWidth = _GetProcAddress("glLineWidth"); + assert(pLineWidth); } GLuint @@ -959,3 +962,9 @@ GlFunctions::CullFace(GLenum mode) { typedef void (*CULLFACE)(GLenum mode); return ((CULLFACE)pCullFace)(mode); } + +void +GlFunctions::LineWidth(GLfloat width) { + typedef void (*LINEWIDTH)(GLfloat width); + return ((LINEWIDTH)pLineWidth)(width); +} diff --git a/retrace/daemon/gldispatch/glframe_glhelper.hpp b/retrace/daemon/gldispatch/glframe_glhelper.hpp index 6398881a..2154b70d 100644 --- a/retrace/daemon/gldispatch/glframe_glhelper.hpp +++ b/retrace/daemon/gldispatch/glframe_glhelper.hpp @@ -176,6 +176,7 @@ class GlFunctions { GLboolean transpose, const GLfloat *value); static void Finish(); static void CullFace(GLenum mode); + static void LineWidth(GLfloat width); private: GlFunctions(); diff --git a/retrace/daemon/glframe_state_enums.cpp b/retrace/daemon/glframe_state_enums.cpp index 1ec9428a..a40ec2f8 100644 --- a/retrace/daemon/glframe_state_enums.cpp +++ b/retrace/daemon/glframe_state_enums.cpp @@ -58,6 +58,7 @@ glretrace::state_name_to_enum(const std::string &value) { {"GL_CONSTANT_ALPHA", GL_CONSTANT_ALPHA}, {"GL_ONE_MINUS_CONSTANT_ALPHA", GL_ONE_MINUS_CONSTANT_ALPHA}, {"GL_BLEND_COLOR", GL_BLEND_COLOR}, + {"GL_LINE_WIDTH", GL_LINE_WIDTH}, {"true", 1}, {"false", 0} }; diff --git a/retrace/daemon/glframe_state_override.cpp b/retrace/daemon/glframe_state_override.cpp index 93438967..42e70e4d 100644 --- a/retrace/daemon/glframe_state_override.cpp +++ b/retrace/daemon/glframe_state_override.cpp @@ -89,6 +89,10 @@ StateOverride::getState(const StateKey &item, get_float_state(n, data); break; } + case GL_LINE_WIDTH: { + get_float_state(n, data); + break; + } } } @@ -185,6 +189,14 @@ StateOverride::enact_state(const KeyMap &m) const { assert(GL::GetError() == GL_NO_ERROR); break; } + case GL_LINE_WIDTH: { + // assert(i.second.size() == 1); + IntFloat u; + u.i = i.second[0]; + GlFunctions::LineWidth(u.f); + assert(GL::GetError() == GL_NO_ERROR); + break; + } case GL_INVALID_ENUM: default: assert(false); @@ -196,16 +208,20 @@ StateOverride::enact_state(const KeyMap &m) const { void floatStrings(const std::vector<uint32_t> &i, std::vector<std::string> *s) { s->clear(); - union { - uint32_t i; - float f; - } u; + IntFloat u; for (auto d : i) { u.i = d; s->push_back(std::to_string(u.f)); } } +void floatString(const uint32_t i, + std::string *s) { + IntFloat u; + u.i = i; + *s = std::to_string(u.f); +} + void StateOverride::onState(SelectionId selId, ExperimentId experimentCount, @@ -249,4 +265,11 @@ StateOverride::onState(SelectionId selId, floatStrings(data, &color); callback->onState(selId, experimentCount, renderId, k, color); } + { + StateKey k("Rendering", "Line State", "GL_LINE_WIDTH"); + getState(k, &data); + std::string value; + floatString(data[0], &value); + callback->onState(selId, experimentCount, renderId, k, {value}); + } } diff --git a/retrace/daemon/ui/glframe_state_model.cpp b/retrace/daemon/ui/glframe_state_model.cpp index 8316bb5a..f293fe94 100644 --- a/retrace/daemon/ui/glframe_state_model.cpp +++ b/retrace/daemon/ui/glframe_state_model.cpp @@ -60,6 +60,9 @@ QStateValue::QStateValue(QObject *parent, m_visible(true), m_type(QStateValue::KglDirectory) { moveToThread(parent->thread()); + if (!_choices.empty()) + m_type = QStateValue::KglEnum; + for (auto c : _choices) m_choices.append(QVariant(c.c_str())); m_indent = static_cast<int>(std::count(_path.begin(), _path.end(), '/')) + @@ -70,26 +73,38 @@ QStateValue::QStateValue(QObject *parent, void QStateValue::insert(const std::string &value) { - m_type = QStateValue::KglEnum; int value_index = 0; QVariant qvalue(value.c_str()); - for (auto c : m_choices) { - if (qvalue == c) - break; - ++value_index; + if (m_type == QStateValue::KglEnum) { + for (auto c : m_choices) { + if (qvalue == c) + break; + ++value_index; + } + // value must be found + assert(value_index < m_choices.size()); + if (m_value == kUninitializedValue) { + // first render, display the value + m_value = value_index; + return; + } + + if (m_value != value_index) + // selected renders have different values + m_value = kMixedValue; + + return; } - // value must be found - assert(value_index < m_choices.size()); + // else + m_type = QStateValue::KglFloat; + const QString new_val = QString::fromStdString(value); if (m_value == kUninitializedValue) { - // first render, display the value - m_value = value_index; + m_value = new_val; return; } - - if (m_value != value_index) - // selected renders have different values - m_value = kMixedValue; + if (m_value != new_val) + m_value = "###"; } void diff --git a/retrace/daemon/ui/qml/StateControl.qml b/retrace/daemon/ui/qml/StateControl.qml index 1e79f01f..ff54c76d 100644 --- a/retrace/daemon/ui/qml/StateControl.qml +++ b/retrace/daemon/ui/qml/StateControl.qml @@ -55,6 +55,24 @@ Item { anchors.verticalCenter: parent.verticalCenter text: modelData.name + " : " } + TextInput { + anchors.margins: 3 + anchors.verticalCenter: parent.verticalCenter + visible: (modelData.valueType == QStateValue.KglFloat) + validator: DoubleValidator{} + text: (modelData.valueType == QStateValue.KglFloat) ? modelData.value : "" + Keys.onReturnPressed: { + if (!acceptableInput) { + text = modelData.value; + return; + } + stateModel.setState(modelData.group, + modelData.path, + modelData.name, + 0, + text); + } + } Row { anchors.verticalCenter: parent.verticalCenter spacing: 10 |