Ejemplo n.º 1
0
  Shader loadShaderXml(QIODevice & ioDevice) {
    QDomDocument dom;
    Shader result;
    dom.setContent(&ioDevice);

    auto children = dom.documentElement().childNodes();
    for (int i = 0; i < children.count(); ++i) {
      auto child = children.at(i);
      if (child.nodeName() == "url") {
        result.url = child.firstChild().nodeValue();
      } if (child.nodeName() == XML_FRAGMENT_SOURCE) {
        result.fragmentSource = child.firstChild().nodeValue();
      } if (child.nodeName() == XML_NAME) {
        result.name = child.firstChild().nodeValue();
      } else if (child.nodeName() == XML_CHANNEL) {
        auto attributes = child.attributes();
        int channelIndex = -1;
        QString source;
        if (attributes.contains(XML_CHANNEL_ATTR_ID)) {
          channelIndex = attributes.namedItem(XML_CHANNEL_ATTR_ID).nodeValue().toInt();
        }

        if (channelIndex < 0 || channelIndex >= shadertoy::MAX_CHANNELS) {
          continue;
        }


        // Compatibility mode
        if (attributes.contains(XML_CHANNEL_ATTR_SOURCE)) {
          source = attributes.namedItem(XML_CHANNEL_ATTR_SOURCE).nodeValue();
          QRegExp re(CHANNEL_REGEX);
          if (!re.exactMatch(source)) {
            continue;
          }
          result.channelTypes[channelIndex] = channelTypeFromString(re.cap(1));
          result.channelTextures[channelIndex] = ("preset://" + re.cap(1) + "/" + re.cap(2));
          continue;
        }

        if (attributes.contains(XML_CHANNEL_ATTR_TYPE)) {
          result.channelTypes[channelIndex] = channelTypeFromString(attributes.namedItem(XML_CHANNEL_ATTR_SOURCE).nodeValue());
          result.channelTextures[channelIndex] = child.firstChild().nodeValue();
        }
      }
    }
    result.vrEnabled = result.fragmentSource.contains("#pragma vr");
    return result;
  }
Ejemplo n.º 2
0
void CameraInfoChannel::setChannelType(const QString &channelTypeName)
{
    setChannelType(channelTypeFromString(channelTypeName));
}
Ejemplo n.º 3
0
CameraInfoChannel::CameraInfoChannel(const QString &channelTypeName, int id)
{
    setChannelType(channelTypeFromString(channelTypeName));
    _id = id;
}