QByteArray compatibleShaderHeader(QOpenGLShader::ShaderType type) { #if BUG_GLES3_ANDROID if (isOpenGLES()) return commonShaderHeader(type); #endif //BUG_GLES3_ANDROID QByteArray h; // #version directive must occur in a compilation unit before anything else, except for comments and white spaces. Default is 100 if not set h.append("#version ").append(QByteArray::number(GLSLVersion())); if (isOpenGLES() && QOpenGLContext::currentContext()->format().majorVersion() > 2) h += " es"; h += "\n"; h += commonShaderHeader(type); if (GLSLVersion() >= 130) { // gl(es) 3 if (type == QOpenGLShader::Vertex) { h += "#define attribute in\n" "#define varying out\n" ; } else if (type == QOpenGLShader::Fragment) { h += "#define varying in\n" "#define gl_FragColor out_color\n" //can not starts with 'gl_' "out vec4 gl_FragColor;\n" ; } } return h; }
void GLSLVersionComparisonTest::testLessThan() { CPPUNIT_ASSERT ( GLSLVersion(4,0) < GLSLVersion(4,1) ); CPPUNIT_ASSERT ( GLSLVersion(3,1) < GLSLVersion(4,0) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,1) < GLSLVersion(4,0)) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,0) < GLSLVersion(3,1)) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,0) < GLSLVersion(4,0)) ); }
void GLSLVersionComparisonTest::testGreaterThan() { CPPUNIT_ASSERT ( GLSLVersion(4,1) > GLSLVersion(4,0) ); CPPUNIT_ASSERT ( GLSLVersion(4,0) > GLSLVersion(3,1) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,0) > GLSLVersion(4,1)) ); CPPUNIT_ASSERT ( !(GLSLVersion(3,1) > GLSLVersion(4,0)) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,0) < GLSLVersion(4,0)) ); }
void GLSLVersionParsingTest::runTest() { char version[4] = "4.1"; GLSLVersion parsed = GLSLVersion::versionFromText(version); CPPUNIT_ASSERT(parsed == GLSLVersion(4,1)); }
void GLSLVersionComparisonTest::testEquality() { CPPUNIT_ASSERT ( GLSLVersion(4,0) == GLSLVersion(4,0) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,0) == GLSLVersion(3,0)) ); CPPUNIT_ASSERT ( !(GLSLVersion(4,0) == GLSLVersion(4,1)) ); }