Utility method for debugging OpenGL calls. - Android android.opengl

Android examples for android.opengl:OpenGL

Description

Utility method for debugging OpenGL calls.

Demo Code


//package com.java2s;

import android.opengl.GLES20;

import android.util.Log;

public class Main {
    private final static String TAG = "MyGlUtils";

    /**//w w  w  .ja  v  a  2 s.c o  m
     * Utility method for debugging OpenGL calls. Provide the name of the call
     * just after making it:
     *
     * <pre>
     * mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");
     * MyGLRenderer.checkGlError("glGetUniformLocation");</pre>
     *
     * If the operation is not successful, the check throws an error.
     *
     * @param glOperation - Name of the OpenGL call to check.
     */
    public static void checkGlError(String glOperation) {
        int error;
        while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
            Log.e(TAG, glOperation + ": glError " + error);
            throw new RuntimeException(glOperation + ": glError " + error);
        }
    }
}

Related Tutorials