Hi,
I've modified a Qt textures example (http://doc.qt.io/qt-5/qtopengl-textures-example.html ) to test out UBO functionality on the iMX6 (using a SABRE board with 6QP AP) - see attachment for the complete modifications. Below I have reproduced the shaders. When the example is run, a lot of graphical corruption can be seen in the spinning cubes.
Has anyone else experienced this ? Do you know of any workarounds / fixes ?
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
QString vsrc =
"in vec4 vertex;\n"
"in vec2 texCoord;\n"
"out vec2 texc;\n"
"uniform int rotIndex;\n"
"\n"
"int getRotoationIndex(void);\n"
"mat4 getRotationMatrix(int Index);\n"
"mat4 getRotationMatrix(void);\n"
"\n"
"struct VertexData {\n"
" mat4 rotMatrix;\n"
"};\n"
"layout(std140) uniform u_VertexData {\n"
" VertexData vData[64];\n"
"};\n"
"\n"
"int getRotationIndex(void) { return rotIndex; }\n"
"mat4 getRotationMatrix(int Index) { return vData[Index].rotMatrix; }\n"
"mat4 getRotationMatrix(void) { return getRotationMatrix(getRotationIndex()); }\n"
"\n"
"void main(void)\n"
"{\n"
" mat4 rotMatrix = getRotationMatrix(rotIndex);\n"
" gl_Position = rotMatrix * vertex;\n"
" texc = texCoord;\n"
"}\n";
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
QString fsrc =
"#ifdef GL_ES\n"
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"#else\n"
"precision mediump float;\n"
"precision mediump sampler2D;\n"
"#endif\n"
"#endif\n"
"in vec2 texc;\n"
"out vec4 fragColor;\n"
"uniform sampler2D tex;\n"
"void main(void)\n"
"{\n"
" fragColor = texture(tex, texc);\n"
"}\n";
Original Attachment has been moved to: GLWidget.cpp.zip
Original Attachment has been moved to: Window.cpp.zip