// Path: opengl/src/main/java/com/doctoror/particlesdrawable/opengl/util/GLErrorChecker.java
// @KeepAsApi
// public final class GLErrorChecker {
// 
//     private static boolean shouldThrowOnGlError = true;
//     private static boolean shouldCheckGlError = true;
// 
//     public static void setShouldCheckGlError(final boolean shouldCheckGlError) {
//         GLErrorChecker.shouldCheckGlError = shouldCheckGlError;
//     }
// 
//     public static void setShouldThrowOnGlError(final boolean shouldThrowOnGlError) {
//         GLErrorChecker.shouldThrowOnGlError = shouldThrowOnGlError;
//     }
// 
//     public static void checkGlError(@NonNull final String tag) {
//         if (shouldCheckGlError) {
//             final int error = GLES20.glGetError();
//             if (error != GLES20.GL_NO_ERROR) {
//                 if (shouldThrowOnGlError) {
//                     throw new GlException(error, tag);
//                 } else {
//                     Log.e("GLErrorChecker", "GLError" + Integer.toString(error) + ", tag = " + tag);
//                 }
//             }
//         }
//     }
// }
// 
// Path: opengl/src/main/java/com/doctoror/particlesdrawable/opengl/util/ShaderLoader.java
// public final class ShaderLoader {
// 
//     private ShaderLoader() {}
// 
//     public static int loadShader(final int type, @NonNull final String shaderCode) {
//         final int shader = GLES20.glCreateShader(type);
// 
//         GLES20.glShaderSource(shader, shaderCode);
//         GLES20.glCompileShader(shader);
// 
//         return shader;
//     }
// }


import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import com.doctoror.particlesdrawable.opengl.util.GLErrorChecker;
import com.doctoror.particlesdrawable.opengl.util.ShaderLoader;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
    private static final String FRAGMENT_SHADER_CODE =
            "precision mediump float;" +
                    "varying vec2 vTexCoord;" +
                    "uniform sampler2D sTexture;" +
                    "void main() {" +
                    "  gl_FragColor = texture2D(sTexture, vTexCoord);" +
                    "}";

    private static final int BYTES_PER_SHORT = 2;
    private static final int COORDINATES_PER_VERTEX = 2;

    private volatile boolean backgroundCoordinatesDirty;

    private ShortBuffer backgroundCoordinates;
    private ByteBuffer backgroundTextureCoordinates;

    private short width;
    private short height;

    private int program;

    private int textureId;
    private boolean hasTexture;

    void init(final int textureId) {
        this.textureId = textureId;

        final int vertexShader = ShaderLoader.loadShader(
                GLES20.GL_VERTEX_SHADER,
                VERTEX_SHADER_CODE);
// Path: opengl/src/main/java/com/doctoror/particlesdrawable/opengl/util/GLErrorChecker.java
// @KeepAsApi
// public final class GLErrorChecker {
// 
//     private static boolean shouldThrowOnGlError = true;
//     private static boolean shouldCheckGlError = true;
// 
//     public static void setShouldCheckGlError(final boolean shouldCheckGlError) {
//         GLErrorChecker.shouldCheckGlError = shouldCheckGlError;
//     }
// 
//     public static void setShouldThrowOnGlError(final boolean shouldThrowOnGlError) {
//         GLErrorChecker.shouldThrowOnGlError = shouldThrowOnGlError;
//     }
// 
//     public static void checkGlError(@NonNull final String tag) {
//         if (shouldCheckGlError) {
//             final int error = GLES20.glGetError();
//             if (error != GLES20.GL_NO_ERROR) {
//                 if (shouldThrowOnGlError) {
//                     throw new GlException(error, tag);
//                 } else {
//                     Log.e("GLErrorChecker", "GLError" + Integer.toString(error) + ", tag = " + tag);
//                 }
//             }
//         }
//     }
// }
// 
// Path: opengl/src/main/java/com/doctoror/particlesdrawable/opengl/util/ShaderLoader.java
// public final class ShaderLoader {
// 
//     private ShaderLoader() {}
// 
//     public static int loadShader(final int type, @NonNull final String shaderCode) {
//         final int shader = GLES20.glCreateShader(type);
// 
//         GLES20.glShaderSource(shader, shaderCode);
//         GLES20.glCompileShader(shader);
// 
//         return shader;
//     }
// }


// Path: opengl/src/main/java/com/doctoror/particlesdrawable/opengl/renderer/GlSceneRendererBackground.java
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import com.doctoror.particlesdrawable.opengl.util.GLErrorChecker;
import com.doctoror.particlesdrawable.opengl.util.ShaderLoader;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

    private static final String FRAGMENT_SHADER_CODE =
            "precision mediump float;" +
                    "varying vec2 vTexCoord;" +
                    "uniform sampler2D sTexture;" +
                    "void main() {" +
                    "  gl_FragColor = texture2D(sTexture, vTexCoord);" +
                    "}";

    private static final int BYTES_PER_SHORT = 2;
    private static final int COORDINATES_PER_VERTEX = 2;

    private volatile boolean backgroundCoordinatesDirty;

    private ShortBuffer backgroundCoordinates;
    private ByteBuffer backgroundTextureCoordinates;

    private short width;
    private short height;

    private int program;

    private int textureId;
    private boolean hasTexture;

    void init(final int textureId) {
        this.textureId = textureId;

        final int vertexShader = ShaderLoader.loadShader(
                GLES20.GL_VERTEX_SHADER,
                VERTEX_SHADER_CODE);
        GLErrorChecker.checkGlError("background glCompileShader vertex");