當前位置: 首頁>>代碼示例>>Java>>正文


Java GLES20.glUniform1i方法代碼示例

本文整理匯總了Java中android.opengl.GLES20.glUniform1i方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glUniform1i方法的具體用法?Java GLES20.glUniform1i怎麽用?Java GLES20.glUniform1i使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.opengl.GLES20的用法示例。


在下文中一共展示了GLES20.glUniform1i方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindShaderValues

import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void bindShaderValues() {
    mRenderVertices.position(0);
    GLES20.glVertexAttribPointer(mPositionHandle, 2, GLES20.GL_FLOAT, false,
            8, mRenderVertices);
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    mTextureVertices[mCurrentRotation].position(0);
    GLES20.glVertexAttribPointer(mTextureCoordHandle, 2, GLES20.GL_FLOAT, false,
            8, mTextureVertices[mCurrentRotation]);
    GLES20.glEnableVertexAttribArray(mTextureCoordHandle);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureIn);
    GLES20.glUniform1i(mTextureHandle, 0);

    mSurfaceTexture.getTransformMatrix(mMatrix);
    GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMatrix, 0);
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:19,代碼來源:VideoFBORender.java

示例2: YuvConverter

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * This class should be constructed on a thread that has an active EGL context.
 */
public YuvConverter() {
  threadChecker.checkIsOnValidThread();
  textureFrameBuffer = new GlTextureFrameBuffer(GLES20.GL_RGBA);
  shader = new GlShader(VERTEX_SHADER, FRAGMENT_SHADER);
  shader.useProgram();
  texMatrixLoc = shader.getUniformLocation("texMatrix");
  xUnitLoc = shader.getUniformLocation("xUnit");
  coeffsLoc = shader.getUniformLocation("coeffs");
  GLES20.glUniform1i(shader.getUniformLocation("oesTex"), 0);
  GlUtil.checkNoGLES2Error("Initialize fragment shader uniform values.");
  // Initialize vertex shader attributes.
  shader.setVertexAttribArray("in_pos", 2, DEVICE_RECTANGLE);
  // If the width is not a multiple of 4 pixels, the texture
  // will be scaled up slightly and clipped at the right border.
  shader.setVertexAttribArray("in_tc", 2, TEXTURE_RECTANGLE);
}
 
開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:20,代碼來源:YuvConverter.java

示例3: onDrawArraysPre

import android.opengl.GLES20; //導入方法依賴的package包/類
protected void onDrawArraysPre(){
	if (mToneCurveTexture[0] != -1){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]);
		GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3);
    }
	if (mMaskGrey1TextureId != -1){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId);
		GLES20.glUniform1i(mMaskGrey1UniformLocation, 4);
    }
    if (mMaskGrey2TextureId != -1){
    	GLES20.glActiveTexture(GLES20.GL_TEXTURE5);
    	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey2TextureId);
     	GLES20.glUniform1i(mMaskGrey2UniformLocation, 5);
    }
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:18,代碼來源:MagicCalmFilter.java

示例4: drawTex

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawTex(int tex, boolean isOES, int fbo)
{
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo);

    if(fbo == 0)
        GLES20.glViewport(0, 0, mView.getWidth(), mView.getHeight());
    else
        GLES20.glViewport(0, 0, mFBOWidth, mFBOHeight);

    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    if(isOES) {
        GLES20.glUseProgram(progOES);
        GLES20.glVertexAttribPointer(vPosOES, 2, GLES20.GL_FLOAT, false, 4*2, vert);
        GLES20.glVertexAttribPointer(vTCOES,  2, GLES20.GL_FLOAT, false, 4*2, texOES);
    } else {
        GLES20.glUseProgram(prog2D);
        GLES20.glVertexAttribPointer(vPos2D, 2, GLES20.GL_FLOAT, false, 4*2, vert);
        GLES20.glVertexAttribPointer(vTC2D,  2, GLES20.GL_FLOAT, false, 4*2, tex2D);
    }

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

    if(isOES) {
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex);
        GLES20.glUniform1i(GLES20.glGetUniformLocation(progOES, "sTexture"), 0);
    } else {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
        GLES20.glUniform1i(GLES20.glGetUniformLocation(prog2D, "sTexture"), 0);
    }

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glFlush();
}
 
開發者ID:vulovicv23,項目名稱:opencv-documentscanner-android,代碼行數:35,代碼來源:CameraGLRendererBase.java

示例5: prepareShader

import android.opengl.GLES20; //導入方法依賴的package包/類
private void prepareShader(String fragmentShader, float[] texMatrix) {
  final Shader shader;
  if (shaders.containsKey(fragmentShader)) {
    shader = shaders.get(fragmentShader);
  } else {
    // Lazy allocation.
    shader = new Shader(fragmentShader);
    shaders.put(fragmentShader, shader);
    shader.glShader.useProgram();
    // Initialize fragment shader uniform values.
    if (fragmentShader == YUV_FRAGMENT_SHADER_STRING) {
      GLES20.glUniform1i(shader.glShader.getUniformLocation("y_tex"), 0);
      GLES20.glUniform1i(shader.glShader.getUniformLocation("u_tex"), 1);
      GLES20.glUniform1i(shader.glShader.getUniformLocation("v_tex"), 2);
    } else if (fragmentShader == RGB_FRAGMENT_SHADER_STRING) {
      GLES20.glUniform1i(shader.glShader.getUniformLocation("rgb_tex"), 0);
    } else if (fragmentShader == OES_FRAGMENT_SHADER_STRING) {
      GLES20.glUniform1i(shader.glShader.getUniformLocation("oes_tex"), 0);
    } else {
      throw new IllegalStateException("Unknown fragment shader: " + fragmentShader);
    }
    GlUtil.checkNoGLES2Error("Initialize fragment shader uniform values.");
    // Initialize vertex shader attributes.
    shader.glShader.setVertexAttribArray("in_pos", 2, FULL_RECTANGLE_BUF);
    shader.glShader.setVertexAttribArray("in_tc", 2, FULL_RECTANGLE_TEX_BUF);
  }
  shader.glShader.useProgram();
  // Copy the texture transformation matrix over.
  GLES20.glUniformMatrix4fv(shader.texMatrixLocation, 1, false, texMatrix, 0);
}
 
開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:31,代碼來源:GlRectDrawer.java

示例6: bindTextureOES

import android.opengl.GLES20; //導入方法依賴的package包/類
public static void bindTextureOES(int textureId,int activeTextureID,int handle,int idx){
    if (textureId != GLEtc.NO_TEXTURE) {
        GLES20.glActiveTexture(activeTextureID);
        GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId);
        GLES20.glUniform1i(handle, idx);
    }
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:8,代碼來源:TextureUtils.java

示例7: setUniforms

import android.opengl.GLES20; //導入方法依賴的package包/類
public void setUniforms(float[] matrix, int textureId) {
    // Pass the matrix into the shader program.
    GLES20.glUniformMatrix4fv(mUMatrixLocation, 1, false, matrix, 0);

    // Set the active texture unit to texture unit 0.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

    // Bind the texture to this unit.
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);

    // Tell the texture uniform sampler to use this texture in the shader by
    // telling it to read from texture unit 0.
    GLES20.glUniform1i(mUTextureUnitLocation, 0);
}
 
開發者ID:Piasy,項目名稱:OpenGLESTutorial-Android,代碼行數:15,代碼來源:TextureShaderProgram.java

示例8: onDrawArraysPre

import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void onDrawArraysPre() {
    if (mToneCurveTexture[0] != OpenGlUtils.NO_TEXTURE) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]);
        GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3);
    }
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:9,代碼來源:ToneCurveFilter.java

示例9: onDrawFrame

import android.opengl.GLES20; //導入方法依賴的package包/類
public int onDrawFrame(final int textureId, final FloatBuffer cubeBuffer,
                       final FloatBuffer textureBuffer) {
    GLES20.glUseProgram(mGLProgId);
    runPendingOnDrawTasks();
    if (!mIsInitialized) {
        return OpenGlUtils.NOT_INIT;
    }

    cubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
    GLES20.glEnableVertexAttribArray(mGLAttribPosition);
    textureBuffer.position(0);
    GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0,
            textureBuffer);
    GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
    if (textureId != OpenGlUtils.NO_TEXTURE) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
        GLES20.glUniform1i(mGLUniformTexture, 0);
    }
    onDrawArraysPre();
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glDisableVertexAttribArray(mGLAttribPosition);
    GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
    onDrawArraysAfter();
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
    return OpenGlUtils.ON_DRAWN;
}
 
開發者ID:TobiasLee,項目名稱:FilterPlayer,代碼行數:29,代碼來源:GPUImageFilter.java

示例10: drawBlurPass

import android.opengl.GLES20; //導入方法依賴的package包/類
private boolean drawBlurPass() {
    if (showOriginal || blurType == 0) {
        return false;
    }
    if (needUpdateBlurTexture) {
        GLES20.glUseProgram(blurShaderProgram);
        GLES20.glUniform1i(blurSourceImageHandle, 0);
        GLES20.glEnableVertexAttribArray(blurInputTexCoordHandle);
        GLES20.glVertexAttribPointer(blurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
        GLES20.glEnableVertexAttribArray(blurPositionHandle);
        GLES20.glVertexAttribPointer(blurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);

        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
        GLES20.glClear(0);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
        GLES20.glUniform1f(blurWidthHandle, 0.0f);
        GLES20.glUniform1f(blurHeightHandle, 1.0f / renderBufferHeight);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[2]);
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[2], 0);
        GLES20.glClear(0);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
        GLES20.glUniform1f(blurWidthHandle, 1.0f / renderBufferWidth);
        GLES20.glUniform1f(blurHeightHandle, 0.0f);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
        needUpdateBlurTexture = false;
    }

    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
    GLES20.glClear(0);
    if (blurType == 1) {
        GLES20.glUseProgram(radialBlurShaderProgram);
        GLES20.glUniform1i(radialBlurSourceImageHandle, 0);
        GLES20.glUniform1i(radialBlurSourceImage2Handle, 1);
        GLES20.glUniform1f(radialBlurExcludeSizeHandle, blurExcludeSize);
        GLES20.glUniform1f(radialBlurExcludeBlurSizeHandle, blurExcludeBlurSize);
        GLES20.glUniform2f(radialBlurExcludePointHandle, blurExcludePoint.x, blurExcludePoint.y);
        GLES20.glUniform1f(radialBlurAspectRatioHandle, (float) renderBufferHeight / (float) renderBufferWidth);
        GLES20.glEnableVertexAttribArray(radialBlurInputTexCoordHandle);
        GLES20.glVertexAttribPointer(radialBlurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
        GLES20.glEnableVertexAttribArray(radialBlurPositionHandle);
        GLES20.glVertexAttribPointer(radialBlurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
    } else if (blurType == 2) {
        GLES20.glUseProgram(linearBlurShaderProgram);
        GLES20.glUniform1i(linearBlurSourceImageHandle, 0);
        GLES20.glUniform1i(linearBlurSourceImage2Handle, 1);
        GLES20.glUniform1f(linearBlurExcludeSizeHandle, blurExcludeSize);
        GLES20.glUniform1f(linearBlurExcludeBlurSizeHandle, blurExcludeBlurSize);
        GLES20.glUniform1f(linearBlurAngleHandle, blurAngle);
        GLES20.glUniform2f(linearBlurExcludePointHandle, blurExcludePoint.x, blurExcludePoint.y);
        GLES20.glUniform1f(linearBlurAspectRatioHandle, (float) renderBufferHeight / (float) renderBufferWidth);
        GLES20.glEnableVertexAttribArray(linearBlurInputTexCoordHandle);
        GLES20.glVertexAttribPointer(linearBlurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
        GLES20.glEnableVertexAttribArray(linearBlurPositionHandle);
        GLES20.glVertexAttribPointer(linearBlurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
    }

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[2]);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

    return true;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:71,代碼來源:PhotoFilterView.java

示例11: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
void draw() {
    EGLDisplay mSavedEglDisplay = EGL14.eglGetCurrentDisplay();
    EGLSurface mSavedEglDrawSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    EGLSurface mSavedEglReadSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_READ);
    EGLContext mSavedEglContext = EGL14.eglGetCurrentContext();
    {
        AndroidUntil.checkGlError("draw_S");
        if (mRecorderImpl.isFirstSetup()) {
            mRecorderImpl.startSwapAsync();
            mRecorderImpl.makeCurrent();
            AndroidUntil.checkGlError("initGL_S");

            mProgram = AndroidUntil.createProgram();
            maPositionHandle = GLES20.glGetAttribLocation(mProgram, "position");
            maTextCodeHandle = GLES20.glGetAttribLocation(mProgram, "inputTextureCoordinate");
            muSamplerHandle = GLES20.glGetUniformLocation(mProgram, "uSampler");
            muPosMtxHandle = GLES20.glGetUniformLocation(mProgram, "uPosMtx");

            Matrix.scaleM(mSymmetryMtx, 0, -1, 1, 1);
            GLES20.glDisable(GLES20.GL_DEPTH_TEST);
            GLES20.glDisable(GLES20.GL_CULL_FACE);
            GLES20.glDisable(GLES20.GL_BLEND);
            AndroidUntil.checkGlError("initGL_E");
        } else {
            mRecorderImpl.makeCurrent();
        }
        GLES20.glViewport(0, 0, mVideoWidth, mVideoHeight);
        GLES20.glClearColor(0f, 0f, 0f, 1f);
        GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glUseProgram(mProgram);
        mNormalVtxBuf.position(0);
        GLES20.glVertexAttribPointer(maPositionHandle,
                3, GLES20.GL_FLOAT, false, 4 * 3, mNormalVtxBuf);
        GLES20.glEnableVertexAttribArray(maPositionHandle);
        mCameraVertexCoordinatesBuffer.position(0);
        GLES20.glVertexAttribPointer(maTextCodeHandle,
                2, GLES20.GL_FLOAT, false, 4 * 2, mCameraVertexCoordinatesBuffer);
        GLES20.glEnableVertexAttribArray(maTextCodeHandle);
        GLES20.glUniform1i(muSamplerHandle, 0);
        GLES20.glUniformMatrix4fv(muPosMtxHandle, 1, false, mNormalMtx, 0);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFboTexId);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

        mRecorderImpl.swapBuffers();
        AndroidUntil.checkGlError("draw_E");
    }
    if (!EGL14.eglMakeCurrent(
            mSavedEglDisplay,
            mSavedEglDrawSurface,
            mSavedEglReadSurface,
            mSavedEglContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
開發者ID:wuyisheng,項目名稱:libRtmp,代碼行數:56,代碼來源:RendererImpl.java

示例12: setUniform1i

import android.opengl.GLES20; //導入方法依賴的package包/類
public void setUniform1i(final int programId, final String name, final int intValue) {
    int location=GLES20.glGetUniformLocation(programId,name);
    GLES20.glUniform1i(location,intValue);
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:5,代碼來源:AbsFilter.java

示例13: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
public void draw() {

        if (mTexture == 0) {
            mTexture = OpenGLUtils.loadTexture(mResource);
        }

        if (mProgram == null) {
            mProgram = new ImageProgram();
        }

        setCube();

        float translateX = (mPosition.x + mTranslationX) * 2.0f / mViewportSize.x;
        float translateY = (-mPosition.y - mTranslationY) * 2.0f / mViewportSize.y;
        float[] mvp = new float[16];
        Matrix.setIdentityM(mvp, 0);
        Matrix.translateM(mMVPMatrix, 0, mvp, 0, translateX, translateY, 0);
        mMVPBuffer.position(0);
        mMVPBuffer.put(mMVPMatrix).position(0);

        GLES20.glUseProgram(mProgram.mProgram);

        mCubeBuffer.position(0);
        GLES20.glVertexAttribPointer(mProgram.mAPositionHandle, 2, GLES20.GL_FLOAT, false, 0, mCubeBuffer);
        GLES20.glEnableVertexAttribArray(mProgram.mAPositionHandle);

        mTextureBuffer.position(0);
        GLES20.glVertexAttribPointer(mProgram.mATextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, mTextureBuffer);
        GLES20.glEnableVertexAttribArray(mProgram.mATextureCoordinateHandle);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture);
        GLES20.glUniform1i(mProgram.mUTextureHandle, 0);

        mMVPBuffer.position(0);
        GLES20.glUniformMatrix4fv(mProgram.mUMVPMatrixHandle, 1, false, mMVPBuffer);

        GLES20.glUniform1f(mProgram.mUOpacityHandle, mOpacity);

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

        GLES20.glDisableVertexAttribArray(mProgram.mAPositionHandle);
        GLES20.glDisableVertexAttribArray(mProgram.mATextureCoordinateHandle);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
    }
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:46,代碼來源:GLImageView.java

示例14: drawEnhancePass

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawEnhancePass() {
    if (!hsvGenerated) {
        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
        GLES20.glClear(0);

        GLES20.glUseProgram(rgbToHsvShaderProgram);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
        GLES20.glUniform1i(rgbToHsvSourceImageHandle, 0);
        GLES20.glEnableVertexAttribArray(rgbToHsvInputTexCoordHandle);
        GLES20.glVertexAttribPointer(rgbToHsvInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
        GLES20.glEnableVertexAttribArray(rgbToHsvPositionHandle);
        GLES20.glVertexAttribPointer(rgbToHsvPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

        ByteBuffer hsvBuffer = ByteBuffer.allocateDirect(renderBufferWidth * renderBufferHeight * 4);
        GLES20.glReadPixels(0, 0, renderBufferWidth, renderBufferHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);

        GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[0]);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
        GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);

        ByteBuffer buffer = null;
        try {
            buffer = ByteBuffer.allocateDirect(PGPhotoEnhanceSegments * PGPhotoEnhanceSegments * PGPhotoEnhanceHistogramBins * 4);
            Utilities.calcCDT(hsvBuffer, renderBufferWidth, renderBufferHeight, buffer);
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }

        GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[1]);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
        GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 16, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buffer);

        hsvGenerated = true;
    }

    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
    GLES20.glClear(0);

    GLES20.glUseProgram(enhanceShaderProgram);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[0]);
    GLES20.glUniform1i(enhanceSourceImageHandle, 0);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[1]);
    GLES20.glUniform1i(enhanceInputImageTexture2Handle, 1);
    if (showOriginal) {
        GLES20.glUniform1f(enhanceIntensityHandle, 0);
    } else {
        GLES20.glUniform1f(enhanceIntensityHandle, getEnhanceValue());
    }

    GLES20.glEnableVertexAttribArray(enhanceInputTexCoordHandle);
    GLES20.glVertexAttribPointer(enhanceInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
    GLES20.glEnableVertexAttribArray(enhancePositionHandle);
    GLES20.glVertexAttribPointer(enhancePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:68,代碼來源:PhotoFilterView.java


注:本文中的android.opengl.GLES20.glUniform1i方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。