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

The following examples show how to use android.opengl.GLES20#glIsProgram() . 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: GLRenderer.java    From HoloKilo with GNU General Public License v3.0 6 votes vote down vote up
static void printLog(int shader) {

        IntBuffer logLength = IntBuffer.allocate(1);
        if (GLES20.glIsShader(shader)) {
            GLES20.glGetShaderiv(shader, GLES20.GL_INFO_LOG_LENGTH, logLength);
        } else if (GLES20.glIsProgram(shader)) {
            GLES20.glGetProgramiv(shader, GLES20.GL_INFO_LOG_LENGTH, logLength);
        } else {
            Log.e(Config.TAG, "printlog: Not a shader or a program");
            return;
        }

        String result = "";
        if (GLES20.glIsShader(shader))
            result = GLES20.glGetShaderInfoLog(shader);
        else if (GLES20.glIsProgram(shader))
            result = GLES20.glGetProgramInfoLog(shader);

        Log.e(Config.TAG, result);

    }
 
Example 2
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 3
Source File: BaseMovieFilter.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
@Override
public void release() {
    mIsInitialized = false;
    if (GLES20.glIsProgram(mProgId)) {
        GLES20.glDeleteProgram(mProgId);
        mProgId = 0;
    }
}
 
Example 4
Source File: Shader.java    From Tanks with MIT License 5 votes vote down vote up
private void deleteProgram()
{
  if (GLES20.glIsShader(vertexShaderHandle))
    GLES20.glDeleteShader(vertexShaderHandle);

  if (GLES20.glIsShader(fragmentShaderHandle))
    GLES20.glDeleteShader(fragmentShaderHandle);

  if (GLES20.glIsProgram(programHandle))
    GLES20.glDeleteProgram(programHandle);
}
 
Example 5
Source File: BaseMovieFilter.java    From PhotoMovie with Apache License 2.0 4 votes vote down vote up
public void drawFrame(PhotoMovie photoMovie, int elapsedTime, FboTexture inputTexture) {
    if (!mIsInitialized) {
        return;
    }
    GLHelper.checkGlError();
    if (!GLES20.glIsProgram(mProgId)) {
        initShader();
        GlUtil.checkGlError("initShader");
    }
    GLES20.glUseProgram(mProgId);

    onPreDraw(photoMovie, elapsedTime, inputTexture);

    FloatBuffer cubeBuffer = mCubeBuffer;
    FloatBuffer textureCubeBuffer = mTextureCubeBuffer;

    if (mIsOpaque) {
        GLES20.glDisable(GLES20.GL_BLEND);
    } else {
        GLES20.glEnable(GLES20.GL_BLEND);
    }

    cubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
    GLES20.glEnableVertexAttribArray(mAttribPosition);

    textureCubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mAttribTexCoord, 2, GLES20.GL_FLOAT, false, 0,
            textureCubeBuffer);
    GLES20.glEnableVertexAttribArray(mAttribTexCoord);

    int glTextureId = inputTexture.getId();
    if (glTextureId != GLHelper.NO_TEXTURE) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, glTextureId);
        GLES20.glUniform1i(mUniformTexture, 0);
    }
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

    GLES20.glDisableVertexAttribArray(mAttribPosition);
    GLES20.glDisableVertexAttribArray(mAttribTexCoord);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glDisable(GLES20.GL_BLEND);

}
 
Example 6
Source File: TwoTextureMovieFilter.java    From PhotoMovie with Apache License 2.0 4 votes vote down vote up
@Override
public void drawFrame(PhotoMovie photoMovie, int elapsedTime, FboTexture inputTexture) {
    if (!mIsInitialized) {
        return;
    }
    GLHelper.checkGlError();
    if (!GLES20.glIsProgram(mProgId)) {
        initShader();
        GlUtil.checkGlError("initShader");
    }
    GLES20.glUseProgram(mProgId);

    loadBitmap();
    onPreDraw(photoMovie, elapsedTime, inputTexture);

    FloatBuffer cubeBuffer = mCubeBuffer;
    FloatBuffer textureCubeBuffer = mTextureCubeBuffer;
    ;

    if (mIsOpaque) {
        GLES20.glDisable(GLES20.GL_BLEND);
    } else {
        GLES20.glEnable(GLES20.GL_BLEND);
    }

    cubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
    GLES20.glEnableVertexAttribArray(mAttribPosition);

    textureCubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mAttribTexCoord, 2, GLES20.GL_FLOAT, false, 0,
            textureCubeBuffer);
    GLES20.glEnableVertexAttribArray(mAttribTexCoord);

    int glTextureId = inputTexture.getId();
    if (glTextureId != GLHelper.NO_TEXTURE) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, glTextureId);
        GLES20.glUniform1i(mUniformTexture, 0);
    }
    //加载第二纹理
    if (mTexture2CoordinateAttribute >= 0) {
        GLES20.glEnableVertexAttribArray(mTexture2CoordinateAttribute);
        mTexture2CoordinatesBuffer.position(0);
        GLES20.glVertexAttribPointer(mTexture2CoordinateAttribute, 2, GLES20.GL_FLOAT, false, 0, mTexture2CoordinatesBuffer);
    }

    if (mTexture2Id >= 0) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture2Id);
        GLES20.glUniform1i(mTexture2Uniform2, 3);
    }


    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

    GLES20.glDisableVertexAttribArray(mAttribPosition);
    GLES20.glDisableVertexAttribArray(mAttribTexCoord);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glDisable(GLES20.GL_BLEND);
}
 
Example 7
Source File: MovieFilter.java    From PhotoMovie with Apache License 2.0 4 votes vote down vote up
public void drawFrame(float progress, int glTextureId, Rect textureRext, RectF srcRect, RectF dstRect) {
    if (!mIsInitialized) {
        return;
    }
    GLHelper.checkGlError();
    if (!GLES20.glIsProgram(mProgId)) {
        initShader();
    }
    GLES20.glUseProgram(mProgId);

    preDraw(progress);

    FloatBuffer cubeBuffer = getCubeBuffer(dstRect);
    FloatBuffer textureCubeBuffer = getTextureCubeBuffer(textureRext, srcRect);

    if (mIsOpaque) {
        GLES20.glDisable(GLES20.GL_BLEND);
    } else {
        GLES20.glEnable(GLES20.GL_BLEND);
    }

    cubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
    GLES20.glEnableVertexAttribArray(mAttribPosition);

    textureCubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mAttribTexCoord, 2, GLES20.GL_FLOAT, false, 0,
            textureCubeBuffer);
    GLES20.glEnableVertexAttribArray(mAttribTexCoord);

    if (glTextureId != GLHelper.NO_TEXTURE) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, glTextureId);
        GLES20.glUniform1i(mUniformTexture, 0);
    }
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

    GLES20.glDisableVertexAttribArray(mAttribPosition);
    GLES20.glDisableVertexAttribArray(mAttribTexCoord);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glDisable(GLES20.GL_BLEND);

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