[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/krita/ui
From:       Tom Burdick <tburdi1 () uic ! edu>
Date:       2007-11-04 0:04:47
Message-ID: 1194134687.650120.11482.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 732483 by tburdick:

modified kis_opengl_shader and friends to allow creating shaders from a \
QVector<QString> as well as the original from a file situation

 M  +5 -0      kis_opengl_fragment_shader.cpp  
 M  +7 -0      kis_opengl_fragment_shader.h  
 M  +19 -0     kis_opengl_shader.cpp  
 M  +11 -0     kis_opengl_shader.h  
 M  +5 -0      kis_opengl_vertex_shader.cpp  
 M  +7 -0      kis_opengl_vertex_shader.h  


--- trunk/koffice/krita/ui/kis_opengl_fragment_shader.cpp #732482:732483
@@ -26,3 +26,8 @@
     loadSourceCode(sourceCodeFilename);
 }
 
+KisOpenGLFragmentShader::KisOpenGLFragmentShader(const QVector<QString>& \
sourceCodeStrings) +    : KisOpenGLShader(GL_FRAGMENT_SHADER_ARB)
+{
+    loadSourceCode(sourceCodeStrings);
+}
--- trunk/koffice/krita/ui/kis_opengl_fragment_shader.h #732482:732483
@@ -36,6 +36,13 @@
      * @param sourceCodeFilename the file to read the source code from
      */
     KisOpenGLFragmentShader(const QString& sourceCodeFilename);
+
+    /**
+     * Loads the shader source code from the given QVector<QString>
+     *
+     * @param sourceCodeStrings the vector of source strings to load from
+     */
+    KisOpenGLFragmentShader(const QVector<QString> &sourceCodeStrings);
 };
 
 #endif // KIS_OPENGL_FRAGMENT_SHADER_H_
--- trunk/koffice/krita/ui/kis_opengl_shader.cpp #732482:732483
@@ -113,6 +113,25 @@
     loadSourceCode(sourceCodeStrings.count(), &(sourceCodeStrings[0]), NULL);
 }
 
+void KisOpenGLShader::loadSourceCode(QVector<QString> sourceCodeStrings)
+{
+    QVector<const GLcharARB *> sourceCodeStringsGL;
+    QVector<GLsizei> sourceCodeStringLengths;
+
+    foreach(const QString &sourceString, sourceCodeStrings) {
+        QByteArray string = sourceString.toAscii();
+        sourceCodeStringsGL.append(string.constData());
+        sourceCodeStringLengths.append(string.size());
+    }
+
+    if (sourceCodeStrings.isEmpty()) {
+        kDebug(DBG_AREA_UI) <<"Shader source code vector is empty";
+        return;
+    }
+
+    loadSourceCode(sourceCodeStringsGL.count(), &(sourceCodeStringsGL[0]), \
&(sourceCodeStringLengths[0])); +}
+
 bool KisOpenGLShader::isValid() const
 {
     return m_valid;
--- trunk/koffice/krita/ui/kis_opengl_shader.h #732482:732483
@@ -42,6 +42,17 @@
     virtual ~KisOpenGLShader();
 
     /**
+     * Load the shader source code from the QVector<QString> of strings specified by \
sourceCodeStrings. +     *
+     * The source code strings can be freed after loading as the shader makes a \
copy. +     *
+     * This is a wrapper for the glShaderSource() function.
+     *
+     * @param sourceCodeStrings An array of pointers to the source code strings
+     */
+    void loadSourceCode(QVector<QString> sourceCodeStrings);
+
+    /**
      * Load the shader source code from the array of strings specified by \
                sourceCodeStrings. The number of strings
      * in the array is specified by numSourceCodeStrings. If stringLengths is NULL, \
                each string is assumed to be
      * null terminated. If stringLengths is a value other than NULL, it points to an \
                array containing a string length
--- trunk/koffice/krita/ui/kis_opengl_vertex_shader.cpp #732482:732483
@@ -26,3 +26,8 @@
     loadSourceCode(sourceCodeFilename);
 }
 
+KisOpenGLVertexShader::KisOpenGLVertexShader(const QVector<QString>& \
sourceCodeStrings) +    : KisOpenGLShader(GL_VERTEX_SHADER_ARB)
+{
+    loadSourceCode(sourceCodeStrings);
+}
\ No newline at end of file
--- trunk/koffice/krita/ui/kis_opengl_vertex_shader.h #732482:732483
@@ -35,6 +35,13 @@
      * @param sourceCodeFilename the file to read the source code from
      */
     KisOpenGLVertexShader(const QString& sourceCodeFilename);
+
+    /**
+     * Loads the shader source code from the given QVector<QString>
+     *
+     * @param sourceCodeStrings the vector of source strings to load from
+     */
+    KisOpenGLVertexShader(const QVector<QString> &sourceCodeStrings);
 };
 
 #endif // KIS_OPENGL_VERTEX_SHADER_H_


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic