当前位置: 首页>>代码示例>>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;未经允许,请勿转载。