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. Image support using OpenGL ES 3.0 on S32V234
Forum Updated to NodeBB v4.3 + New Features

Image support using OpenGL ES 3.0 on S32V234

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 289 Views 2 Watching
  • 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.
  • R Offline
    R Offline
    Raghuprasanth
    wrote on last edited by
    #1

    Hello,

    Integrated Meta_QT5 in our S32V234 yocto environment.
    We are loading image ( PNG/JPEG etc) and applying texture using QT5.10 and OpenGL ES 3.0 APIs.
    But the image is not being displayed.
    Any pointers on this would be much appreciated.

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You are not giving enough details on how you implement that nor if you have that working on your desktop machine nor if you have anything OpenGL shown on your device.

      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
      • R Offline
        R Offline
        Raghuprasanth
        wrote on last edited by
        #3

        Hello,

        Here are the code details,

        We are writing OpenGL ES 2.0 simple application of loading a texture(.png) on QT 5.10 using QOpenGLWidget.
        We are able to build and run in both Windows and Ubuntu version 16.04 Environment, but we are targetting the NXP S32V234 board.

        We have QT 5.10, OpenGL ES 2.0, Linux 4.19 version running on NXP S32V234 board, there it fails to load the texture. Pointers would be much appreciated.

        Here is the vertex and fragment shader code which are compiled using normal gl functions not the QT's addShaderFromSourceFile function.

        //Vertex Shader

        #ifdef GL_ES
        precision mediump int;
        precision mediump float;
        #endif

        attribute vec3 position;
        attribute vec3 color;
        attribute vec2 texCoord;

        varying vec3 Color;
        varying vec2 TexCoord;

        uniform mat4 transform;

        void main()
        {
        gl_Position = transform * vec4(position, 1.0);
        Color = color;
        TexCoord = texCoord;
        }

        //Fragment Shader

        #ifdef GL_ES
        precision mediump int;
        precision mediump float;
        #endif

        uniform sampler2D outputTexture;

        varying vec3 Color;
        varying vec2 TexCoord;

        void main()
        {
        gl_FragColor = texture2D(outputTexture, TexCoord) * vec4(Color, 1.0);
        }

        Here is the initialization and loading of texture

        void MyGL::initializeTextureBuffer()
        {
        float vertices[] = {
        // positions // texture coords
        0.0f, 0.3f, 0.0f, 1.0f,0.0f,0.0f, 0.0f, 0.0f, // bottom left /* @pixel (35,57)
        0.0f, 0.6f, 0.0f,0.0f,1.0f,0.0f, 0.0f, 1.0f, // top left @pixel (35,27)
        0.5f, 0.6f, 0.0f,0.0f,0.0f,1.0f, 1.0f, 1.0f, // top right @pixel (76,27)
        0.5f, 0.3f, 0.0f, 1.0f,1.0f,1.0f, 1.0f, 0.0f, // bottom right @pixel (76,57) */
        };

                    glGenBuffers(1, &camTextureBufferObject);
        
        
                    glBindBuffer(GL_ARRAY_BUFFER, camTextureBufferObject);
                    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
        
        
                    glBindBuffer(GL_ARRAY_BUFFER, 0); //unbinding
        
        
                    textureQT = loadTexture(":/images/images/CamRedA.PNG");
        

        }

        QOpenGLTexture* MyGL::loadTexture(const char * path)
        {
        QOpenGLTexture* texture;
        texture = new QOpenGLTexture(QImage(path).mirrored());
        texture->setMinificationFilter(QOpenGLTexture::Nearest);
        texture->setMagnificationFilter(QOpenGLTexture::Linear);
        texture->setWrapMode(QOpenGLTexture::Repeat);
        return texture;
        }

        Here is the main render loop

        void MyGL::paintGL()
        {
        glClearColor(0.0f, 0.0f, 0.0f, 0.05f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

                    ///********************************* Texture Rendering ********************************************************/
                    glUseProgram(shaderpgmTexture);
                   
        
        
                    glm::mat4 projection = glm::perspective(glm::radians(camspec.fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
                    glm::mat4 view = glm::lookAt(camspec.cameraPos, camspec.cameraPos + camspec.cameraFront, camspec.cameraUp);
                    glm::mat4 model = glm::mat4(1.0f);
        
        
                    glm::mat4 transform = projection * view * model;
                    glUniformMatrix4fv(glGetUniformLocation(shaderpgmTexture, "transform"), 1, false, &transform[0][0]);
        
        
        
        
                    glEnable(GL_BLEND);
                    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
        
                    glUniform1i(glGetUniformLocation(shaderpgmTexture, "outputTexture"), 0);
                    glActiveTexture(GL_TEXTURE0);
                    textureQT->bind();
        
        
                    glBindBuffer(GL_ARRAY_BUFFER, camTextureBufferObject);
                    // position attribute
                    GLint vertexLocation = glGetAttribLocation(shaderpgmTexture,"position");
                    glEnableVertexAttribArray(vertexLocation);
                    glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
                    // color
                    GLint colorLocation = glGetAttribLocation(shaderpgmTexture, "color");
                    glEnableVertexAttribArray(colorLocation);
                    glVertexAttribPointer(colorLocation, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
                    // texture coord attribute
                    GLint vertexTex = glGetAttribLocation(shaderpgmTexture, "texCoord");
                    glEnableVertexAttribArray(vertexTex);
                    glVertexAttribPointer(vertexTex, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
        
        
                    glDrawArrays(GL_QUADS, 0, 4);
        
        
                    glDisable(GL_BLEND);
        
        
                    glUseProgram(0);
                    /********************************* Texture Rendering - End ********************************************************/
        

        }

        1 Reply Last reply
        0

        • Login

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