[SailfishDevel] Sailfish opengl es problem.

Bartosz Remisz bartrem737 at student.polsl.pl
Tue Oct 8 18:15:27 UTC 2013


Hello,

I have quite strange problem with openg gl and shaders on Sailfish. My shaders code looks like this: 

const char *fragmentShaderSnake = "precision mediump float;\
        varying vec4 z_Color;\
void main()\
{\
    gl_FragColor = z_Color;\
}";

const char *vertexShaderSnake = "uniform mat4 x_Matrix;\
        attribute vec4 x_Position;\
        attribute float ccColor;\
        varying vec4 z_Color;\
        void main()\
        {\
            if (ccColor == 0.7f)\
            {\
                z_Color = vec4(1.0 - ccColor, 1.0, ccColor, 1.0);\
            }\
            else if (ccColor == 0.2f)\
            {\
                z_Color = vec4(0.0, 0.0, 0.0, 1.0);\
            }\
            else\
            {\
                z_Color = vec4(1.0 - ccColor, 0.0, ccColor, 1.0);\
            }\
            gl_Position = x_Matrix * x_Position;\
        }";


attrib pointer:

void setVertexAttribPointer( int vrpDataOffset, int vrpAttributeLocation, int vrpComponentCount, int vrpStride )
{
       glVertexAttribPointer(vrpAttributeLocation, vrpComponentCount, GL_FLOAT, GL_FALSE, vrpStride, (const void *)vrpDataOffset);
       glEnableVertexAttribArray(vrpAttributeLocation);
}

and draw function: 

vrcVertexArray->bindBuffer();
vrcVertexArray->setVertexAttribPointer(0, vrpPositionLocation, 3, 4 * sizeof(float);
vrcVertexArray->setVertexAttribPointer(3, vrpColorLocation, 1, 4 * sizeof(float); 
glDrawArrays( GL_TRIANGLE_STRIP, 0, 26 );
[...]


I have created 26 points (3 floats for position and 1 float for color) to make cuboid with triangle strip. I know all of them are correct, because changing start index and count values of glDrawArrays draws correct part of cuboid. However setting code as it is stated, makes some faces disappear, some of them change color to red or black, also attribute ccColor is not working at all (as if the value is not passed). I have tried almost everything but nothing helps. Same code on Android works fine. Any help or clue would be greatly appreciated.

Thanks in advance,
Bartek


 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20131008/e760e191/attachment.html>


More information about the Devel mailing list