Code example for GL10

Methods: glGetString

         * @param gl 
         * @param extension 
         * @return true if the extension is present in the current context. 
        private boolean checkIfContextSupportsExtension(GL10 gl, String extension) {
            String extensions = " " + gl.glGetString(GL10.GL_EXTENSIONS) + " ";
            // The extensions string is padded with spaces between extensions, but not 
            // necessarily at the beginning or end. For simplicity, add spaces at the 
            // beginning and end of the extensions string and the extension string. 
            // This means we can avoid special-case checks for the first or last 
            // extension, as well as avoid special-case checks when an extension name 
            // is the same as the first part of another extension name. 
            return extensions.indexOf(" " + extension + " ") >= 0;
    static void checkGLError(GL gl) {
        int error = ((GL10) gl).glGetError();
        if (error != GL10.GL_NO_ERROR) {
            throw new RuntimeException("GLError 0x" + Integer.toHexString(error));
Stop searching for code, let great code find you!  Add Codota to your java IDE