Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c43f66d authored by Romain Guy's avatar Romain Guy
Browse files

Fix TextureView OpenGL sample

The sample was doing something dumb: instead of binding the texture unit
to the shader's sampler, it was binding the texture name. Oops.

Change-Id: I13450dacbbd2dad362a2573aebb95e8eb87b25f0
parent c1c14065
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -210,28 +210,31 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa
            glEnableVertexAttribArray(attribTexCoords);
            checkGlError();

            glUniform1i(uniformTexture, texture);
            checkGlError();
            
            while (!mFinished) {
                checkCurrent();

                glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
                checkGlError();

                glClear(GL_COLOR_BUFFER_BIT);
            glUniform1i(uniformTexture, 0);
            checkGlError();

            // drawQuad
            triangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
            glVertexAttribPointer(attribPosition, 3, GL_FLOAT, false,
                    TRIANGLE_VERTICES_DATA_STRIDE_BYTES, triangleVertices);
            checkGlError();

            triangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
            glVertexAttribPointer(attribTexCoords, 3, GL_FLOAT, false,
                    TRIANGLE_VERTICES_DATA_STRIDE_BYTES, triangleVertices);
            checkGlError();

            glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            checkGlError();
            
            while (!mFinished) {
                checkCurrent();

                glClear(GL_COLOR_BUFFER_BIT);
                checkGlError();

                glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
                checkGlError();

                if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
                    throw new RuntimeException("Cannot swap buffers");