Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Shaders loaded from a file won't compile in armv7
Forum Update on Monday, May 27th 2025

Shaders loaded from a file won't compile in armv7

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
opengl esopengl es2.0androidshaders
4 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Metadr
    wrote on 6 Feb 2016, 20:07 last edited by
    #1

    It works while building for the desktop, but as soon as I compile this little snippet to load shaders from a file with armv7 it somehow can't retrieve the file and just return an empty string
    Here's how i'm handling the routine which loads my shaders:

    void MainWindow::initShaders(const GLchar *vertexPath, const GLchar *fragmentPath, GLuint& Program)
    {
        std::string vertexCode;
        std::string fragmentCode;
        std::ifstream vShaderFile;
        std::ifstream fShaderFile;
    
        vShaderFile.exceptions(std::ifstream::badbit);
        fShaderFile.exceptions(std::ifstream::badbit);
        try
        {
            vShaderFile.open(vertexPath);
            fShaderFile.open(fragmentPath);
            std::stringstream vShaderStream, fShaderStream;
    
            vShaderStream << vShaderFile.rdbuf();
            fShaderStream << fShaderFile.rdbuf();
    
            vShaderFile.close();
            fShaderFile.close();
            // Convert stream into string, returns an empty one if compiling with armv7
            vertexCode = vShaderStream.str();
            fragmentCode = fShaderStream.str();
        }
    //...
    //linking & compiling
    //...
    }
    

    I'm pretty new to android development and i'm not sure if something's missing
    jdk, ant, android sdk & ndk are properly set up and the few opengl samples I tried to run work fine, but my shaders need to be directly written as const GLchar* inside the program to compile

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Feb 2016, 20:50 last edited by
      #2

      Hi,

      Where are your shaders located ?

      By the way, why not make use of QOpenGLShader ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Metadr
        wrote on 6 Feb 2016, 23:20 last edited by Metadr 2 Jun 2016, 23:20
        #3

        The shaders are in the project file, saved as text files with .vert & .frag extensions. It goes fine while building for the desktop but It fails on armv7 somehow

        I haven't looked at that helper class and It would be better if I understand now what's the problem to hopefully not get stuck again for future similiar operations

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Feb 2016, 21:42 last edited by
          #4

          Then you should use the Qt resource system to embed the shader in your application. You current shader files are accessible on your host. When you start your application on your device, they won't be there.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          6 Feb 2016, 20:07

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved