diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index a023f7198fa9e279ffd92d62a837528eedeb49b0..9caf26ddf00624ff8d06bc59ae3f20d83c142084 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -102,6 +102,10 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), error_message)) return false; + m_glsl_120_frag = glslFile(QLatin1String("glsl_120.frag")); + m_glsl_120_vert = glslFile(QLatin1String("glsl_120.vert")); + m_glsl_120_common = glslFile(QLatin1String("glsl_120_common.glsl")); + // m_modelManager = new ModelManager(this); // addAutoReleasedObject(m_modelManager); @@ -224,4 +228,30 @@ Core::Command *GLSLEditorPlugin::addToolAction(QAction *a, Core::ActionManager * return command; } +QByteArray GLSLEditorPlugin::glslFile(const QString &fileName) +{ + QString path = Core::ICore::instance()->resourcePath(); + path += QLatin1String("/glsl/"); + path += fileName; + QFile file(path); + if (file.open(QFile::ReadOnly)) + return file.readAll(); + return QByteArray(); +} + +QByteArray GLSLEditorPlugin::fragmentShaderInit() const +{ + return m_glsl_120_frag; +} + +QByteArray GLSLEditorPlugin::vertexShaderInit() const +{ + return m_glsl_120_vert; +} + +QByteArray GLSLEditorPlugin::shaderInit() const +{ + return m_glsl_120_common; +} + Q_EXPORT_PLUGIN(GLSLEditorPlugin) diff --git a/src/plugins/glsleditor/glsleditorplugin.h b/src/plugins/glsleditor/glsleditorplugin.h index a7d716373639aa87f19d289649c4b4721980ac3b..32806fd0beedc53b1302f48ca97e8ad1aa4f9b3a 100644 --- a/src/plugins/glsleditor/glsleditorplugin.h +++ b/src/plugins/glsleditor/glsleditorplugin.h @@ -83,7 +83,13 @@ public: void initializeEditor(GLSLEditor::GLSLTextEditor *editor); + QByteArray fragmentShaderInit() const; + QByteArray vertexShaderInit() const; + QByteArray shaderInit() const; + private: + QByteArray glslFile(const QString &fileName); + Core::Command *addToolAction(QAction *a, Core::ActionManager *am, Core::Context &context, const QString &name, Core::ActionContainer *c1, const QString &keySequence); @@ -93,6 +99,9 @@ private: TextEditor::TextEditorActionHandler *m_actionHandler; QPointer<TextEditor::ITextEditable> m_currentTextEditable; + QByteArray m_glsl_120_frag; + QByteArray m_glsl_120_vert; + QByteArray m_glsl_120_common; }; } // namespace Internal