SGX ES2.0 multitexture problem

This topic contains 3 replies, has 2 voices, and was last updated by  chithize 7 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30251

    chithize
    Member

    hi

    I am working with SGX es2.0 texturing on OMAP3530 platform.
    I had defined two texture, one is for video frame data(gray value), another is 256 entries
    LUT(palette, I defined it as 256 width, 1 height 2D texture, as es2 driver of SGX  can’t support
    texture1D),   but when it run, the display window just dark, can’t display any color remapped texture, can you help to identify what is wrong with it, SGX can’t work correctly?

    below is the related codes(Qt wrapped).



      QGLShader *fshader2 = new QGLShader(QGLShader::Fragment);
      
        const char *fsrc2 =
            “varying highp vec4 texc;n”
            “precision mediump float;n”
            “uniform sampler2D tex;n”
            “uniform sampler2D palette;n”
            “varying mediump float angle;n”
            “void main(void)n”
            “{n”
            “float i = texture2D(tex, texc.st).r;n”
            “gl_FragColor = vec4(texture2D(palette, vec2(i,1)).rgb,1.0);n”
            “}n”;
        fshader2->compileSourceCode(fsrc2);

        program2.addShader(vshader2);
        program2.addShader(fshader2);
        program2.link();

        vertexAttr2 = program2.attributeLocation(“vertex”);
        normalAttr2 = program2.attributeLocation(“normal”);
        texCoordAttr2 = program2.attributeLocation(“texCoord”);
        matrixUniform2 = program2.uniformLocation(“matrix”);
        textureUniform2 = program2.uniformLocation(“tex”);
        lutColormap =  program2.uniformLocation(“palette”);

    and the display part:

        glEnable(GL_TEXTURE_2D);
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, m_uiTexture);
        glTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE, buffer_width,buffer_height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_camera->m_buffer);
                 
       glActiveTexture(GL_TEXTURE1);

        glBindTexture(GL_TEXTURE_2D,m_uiPalette);

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 1,0, GL_RGB, GL_UNSIGNED_BYTE, lutData);

        GLfloat afVertices[] = {
            -1.0, -1.0, -1.0, 1.0,-1.0,-1.0,-1.0,1.0,-1.0,
            1.0, 1.0, -1.0, -1.0,1.0,-1.0,1.0,-1.0,-1.0,
        };

        glVertexAttribPointer(vertexAttr2, 3, GL_FLOAT, GL_FALSE, 0, afVertices);
        glEnableVertexAttribArray(vertexAttr2);

        GLfloat afTexCoord[] = {
            1.0f,1.0f, 0.0f,1.0f, 1.0f,0.0f,
            0.0f,0.0f, 1.0f,0.0f, 0.0f,1.0f,
        };
        glVertexAttribPointer(texCoordAttr2, 2, GL_FLOAT, GL_FALSE, 0, afTexCoord);
        glEnableVertexAttribArray(texCoordAttr2);

        GLfloat afNormals[] = {
            0,0,1, 0,0,1, 0,0,1,
            0,0,1, 0,0,1, 0,0,1,
        };
        glVertexAttribPointer(normalAttr2, 3, GL_FLOAT, GL_FALSE, 0, afNormals);
        glEnableVertexAttribArray(normalAttr2);

        glUniform1i(textureUniform2, 0);    // use texture unit 0
        glUniform1i(lutColormap, 1);

      

        glDrawArrays(GL_TRIANGLES, 0, 6);

        glDisableVertexAttribArray(vertexAttr2);
        glDisableVertexAttribArray(normalAttr2);
        glDisableVertexAttribArray(texCoordAttr2);

    texture2 data is defined as below:
    unsigned char *lp=lutData;
        int i;
        for(i=0;i<64;i++)
        {
            lp[0]=0;
            lp[1]=0;
            lp[2]=255;
            lp+=3 ; }
        for(;i<192;i++)
            {
            lp[0]=0;
            lp[1]=255;
            lp[2]=127;
            lp+=3 ; }
        for(;i<256;i++)
            {
            lp[0]=255;
            lp[1]=0;
            lp[2]=0;
            lp+=3 ; }


    chithize2010-08-18 09:08:32

    #34229

    I guess one would start by setting gl_FragColor to some constant color to see whether any visible geometry is produced. If not, something is wrong with the definition of the geometry and you have to fix that before worrying about the textures.

    Then you work you way backwards by replacing “i” in “texture2D(palette, vec2(i,1))” by a constant number (e.g. 0.5) to see whether you can get any of the specified colors out of the palette texture for a specific value of “i”. If not, you have to check this texture.

    If it works for one value of “i” you should see what values “i” as by setting “gl_FragColor” to vec4(i, i, i, 1.0) or something like this to see whether “i” has the values that you expect.

    If “i” has the correct values and you get the correct values out of the palette texture for specific values of “i”, it should work. 😉

    #34230

    chithize
    Member

    hi Martin
    Thanks for your reply, I had tried the ways you said.
    vec4(i,i,i,1.0) work, the screen show luminance data, it is ok,
    but when I tried “texture2D(palette, vec2(0.5,1))”  or “texture2D(palette, vec2(0.5,0))”,
    no color show, just dark,  and I tried to extend palette to 256X2(height=2) , it still dark,
    it seem the second texture “palette” is not activated, can you help to check if my code sequence is correct?

    and the below is my texture initialization code before the above draw.



        glGenTextures(1, &m_uiTexture);
        glGenTextures(1,&m_uiPalette);
        m_uiTexture = bindTexture(QImage(“:/qt.png”));

    thanks very much

    #34231

    chithize
    Member

    hi Martin,

    I had fixed it,  texture bind code just happen after glUseProgram, that is fault
    but thank you , anyway

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.