Java Code Examples for android.opengl.GLES20#glValidateProgram()

The following examples show how to use android.opengl.GLES20#glValidateProgram() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shader.java    From Tanks with MIT License 6 votes vote down vote up
public void validate()
{
  if (!GameContext.debuggable)
    return;

  int[] result = new int[1];

  GLES20.glValidateProgram(programHandle);
  GLES20.glGetProgramiv(programHandle, GLES20.GL_VALIDATE_STATUS, result, 0);

  if (result[0] == 0)
  {
    String message = !GLES20.glIsProgram(programHandle)
      ? "Program handle deprecated!"
      : "Program do not validated!";

    throw new GLException(result[0], message);
  }
}
 
Example 2
Source File: GLDrawer2DES2.java    From libcommon with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean validateProgram(final int program) {
	if (program >= 0) {
		GLES20.glValidateProgram(program);
		GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
		return status[0] == GLES20.GL_TRUE;
	}
	return false;
}
 
Example 3
Source File: CameraGLRendererBase.java    From FaceT with Mozilla Public License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 4
Source File: CameraGLRendererBase.java    From Image-Detection-Samples with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 5
Source File: CameraGLRendererBase.java    From opencv-documentscanner-android with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 6
Source File: CameraGLRendererBase.java    From MOAAP with MIT License 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 7
Source File: CameraGLRendererBase.java    From OpenCvFaceDetect with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 8
Source File: CameraGLRendererBase.java    From ml-authentication with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 9
Source File: CameraGLRenderer.java    From VideoRecorder with Apache License 2.0 4 votes vote down vote up
private int loadShader(String vss, String fss) {
    LogUtil.logd("loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        LogUtil.loge("Could not compile vertex shader: " + GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        LogUtil.loge("Could not compile fragment shader:" + GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        LogUtil.loge("Could not link shader program: " + GLES20.glGetProgramInfoLog(program));
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0) {
        LogUtil.loge("Shader program validation error: " + GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        return 0;
    }
    LogUtil.logd("Shader program is built OK");
    return program;
}
 
Example 10
Source File: CameraGLRendererBase.java    From react-native-documentscanner-android with MIT License 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 11
Source File: CameraGLRendererBase.java    From VIA-AI with MIT License 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 12
Source File: Utils.java    From Paddle-Lite-Demo with Apache License 2.0 4 votes vote down vote up
public static int createShaderProgram(String vss, String fss) {
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    return program;
}
 
Example 13
Source File: CameraGLRendererBase.java    From sudokufx with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 14
Source File: Utils.java    From Paddle-Lite-Demo with Apache License 2.0 4 votes vote down vote up
public static int createShaderProgram(String vss, String fss) {
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e(TAG, GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    return program;
}
 
Example 15
Source File: CameraGLRendererBase.java    From ml-authentication with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 16
Source File: CameraGLRendererBase.java    From MOAAP with MIT License 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 17
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void validateProgram(int program) {
    GLES20.glValidateProgram(program);

}
 
Example 18
Source File: CameraGLRendererBase.java    From real_time_circle_detection_android with MIT License 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 19
Source File: CameraGLRendererBase.java    From LicensePlateDiscern with MIT License 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
Example 20
Source File: CameraGLRendererBase.java    From LPR with Apache License 2.0 4 votes vote down vote up
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}