diff options
Diffstat (limited to 'examples/opengl')
-rw-r--r-- | examples/opengl/hellogl_es/hellogl_es.pro | 9 | ||||
-rw-r--r-- | examples/opengl/hellogl_es2/glwidget.cpp | 30 | ||||
-rw-r--r-- | examples/opengl/hellogl_es2/hellogl_es2.pro | 6 | ||||
-rw-r--r-- | examples/opengl/textures/glwidget.cpp | 12 |
4 files changed, 25 insertions, 32 deletions
diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro index 3168743415..80ef7df315 100644 --- a/examples/opengl/hellogl_es/hellogl_es.pro +++ b/examples/opengl/hellogl_es/hellogl_es.pro @@ -20,15 +20,6 @@ HEADERS += bubble.h RESOURCES += texture.qrc QT += opengl -wince*:{ - contains(QT_CONFIG,opengles1) { - QMAKE_LIBS += "libGLES_CM.lib" - } - contains(QT_CONFIG,opengles1cl) { - QMAKE_LIBS += "libGLES_CL.lib" - } -} - # install target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es.pro diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp index a31c34a3c0..08e887af21 100644 --- a/examples/opengl/hellogl_es2/glwidget.cpp +++ b/examples/opengl/hellogl_es2/glwidget.cpp @@ -92,6 +92,8 @@ void GLWidget::showBubbles(bool bubbles) void GLWidget::paintQtLogo() { + program1.enableAttributeArray(normalAttr1); + program1.enableAttributeArray(vertexAttr1); program1.setAttributeArray(vertexAttr1, vertices.constData()); program1.setAttributeArray(normalAttr1, normals.constData()); glDrawArrays(GL_TRIANGLES, 0, vertices.size()); @@ -159,6 +161,10 @@ void GLWidget::paintTexturedCube() program2.setUniformValue(textureUniform2, 0); // use texture unit 0 + program2.enableAttributeArray(vertexAttr2); + program2.enableAttributeArray(normalAttr2); + program2.enableAttributeArray(texCoordAttr2); + glDrawArrays(GL_TRIANGLES, 0, 36); program2.disableAttributeArray(vertexAttr2); @@ -173,7 +179,7 @@ void GLWidget::initializeGL () glGenTextures(1, &m_uiTexture); m_uiTexture = bindTexture(QImage(":/qt.png")); - QGLShader *vshader1 = new QGLShader(QGLShader::VertexShader, this); + QGLShader *vshader1 = new QGLShader(QGLShader::Vertex, this); const char *vsrc1 = "attribute highp vec4 vertex;\n" "attribute mediump vec3 normal;\n" @@ -188,16 +194,16 @@ void GLWidget::initializeGL () " color = clamp(color, 0.0, 1.0);\n" " gl_Position = matrix * vertex;\n" "}\n"; - vshader1->compile(vsrc1); + vshader1->compileSourceCode(vsrc1); - QGLShader *fshader1 = new QGLShader(QGLShader::FragmentShader, this); + QGLShader *fshader1 = new QGLShader(QGLShader::Fragment, this); const char *fsrc1 = "varying mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" "}\n"; - fshader1->compile(fsrc1); + fshader1->compileSourceCode(fsrc1); program1.addShader(vshader1); program1.addShader(fshader1); @@ -207,7 +213,7 @@ void GLWidget::initializeGL () normalAttr1 = program1.attributeLocation("normal"); matrixUniform1 = program1.uniformLocation("matrix"); - QGLShader *vshader2 = new QGLShader(QGLShader::VertexShader); + QGLShader *vshader2 = new QGLShader(QGLShader::Vertex); const char *vsrc2 = "attribute highp vec4 vertex;\n" "attribute highp vec4 texCoord;\n" @@ -222,9 +228,9 @@ void GLWidget::initializeGL () " gl_Position = matrix * vertex;\n" " texc = texCoord;\n" "}\n"; - vshader2->compile(vsrc2); + vshader2->compileSourceCode(vsrc2); - QGLShader *fshader2 = new QGLShader(QGLShader::FragmentShader); + QGLShader *fshader2 = new QGLShader(QGLShader::Fragment); const char *fsrc2 = "varying highp vec4 texc;\n" "uniform sampler2D tex;\n" @@ -235,7 +241,7 @@ void GLWidget::initializeGL () " color = color * 0.2 + color * 0.8 * angle;\n" " gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n" "}\n"; - fshader2->compile(fsrc2); + fshader2->compileSourceCode(fsrc2); program2.addShader(vshader2); program2.addShader(fshader2); @@ -284,15 +290,15 @@ void GLWidget::paintGL() modelview.translate(0.0f, -0.2f, 0.0f); if (qtLogo) { - program1.enable(); + program1.bind(); program1.setUniformValue(matrixUniform1, modelview); paintQtLogo(); - program1.disable(); + program1.release(); } else { - program2.enable(); + program2.bind(); program1.setUniformValue(matrixUniform2, modelview); paintTexturedCube(); - program2.disable(); + program2.release(); } glDisable(GL_DEPTH_TEST); diff --git a/examples/opengl/hellogl_es2/hellogl_es2.pro b/examples/opengl/hellogl_es2/hellogl_es2.pro index d5ad4b81ec..92b42248de 100644 --- a/examples/opengl/hellogl_es2/hellogl_es2.pro +++ b/examples/opengl/hellogl_es2/hellogl_es2.pro @@ -25,9 +25,3 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es2 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es2.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es2 INSTALLS += target sources - - -wince*: { - QMAKE_LIBS += "libGLESv2.lib" - -}
\ No newline at end of file diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index 6efd31a5bb..0f50e2dff8 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -99,7 +99,7 @@ void GLWidget::initializeGL() #define PROGRAM_VERTEX_ATTRIBUTE 0 #define PROGRAM_TEXCOORD_ATTRIBUTE 1 - QGLShader *vshader = new QGLShader(QGLShader::VertexShader, this); + QGLShader *vshader = new QGLShader(QGLShader::Vertex, this); const char *vsrc = "attribute highp vec4 vertex;\n" "attribute mediump vec4 texCoord;\n" @@ -110,9 +110,9 @@ void GLWidget::initializeGL() " gl_Position = matrix * vertex;\n" " texc = texCoord;\n" "}\n"; - vshader->compile(vsrc); + vshader->compileSourceCode(vsrc); - QGLShader *fshader = new QGLShader(QGLShader::FragmentShader, this); + QGLShader *fshader = new QGLShader(QGLShader::Fragment, this); const char *fsrc = "uniform sampler2D texture;\n" "varying mediump vec4 texc;\n" @@ -120,7 +120,7 @@ void GLWidget::initializeGL() "{\n" " gl_FragColor = texture2D(texture, texc.st);\n" "}\n"; - fshader->compile(fsrc); + fshader->compileSourceCode(fsrc); program = new QGLShaderProgram(this); program->addShader(vshader); @@ -129,7 +129,7 @@ void GLWidget::initializeGL() program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); program->link(); - program->enable(); + program->bind(); program->setUniformValue("texture", 0); #endif @@ -163,6 +163,8 @@ void GLWidget::paintGL() m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); program->setUniformValue("matrix", m); + program->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE); + program->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE); program->setAttributeArray (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); program->setAttributeArray |