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


Java GLES20.glUniform2f方法代碼示例

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


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

示例1: updateFloatValue

import android.opengl.GLES20; //導入方法依賴的package包/類
private void updateFloatValue(float... value) {
    switch (value.length) {
        case 1:
            GLES20.glUniform1f(handle(), value[0]);
            break;
        case 2:
            GLES20.glUniform2f(handle(), value[0], value[1]);
            break;
        case 3:
            GLES20.glUniform3f(handle(), value[0], value[1], value[2]);
            break;
        case 4:
            GLES20.glUniform4f(handle(), value[0], value[1], value[2], value[3]);
            break;
        case 16:
            GLES20.glUniformMatrix4fv(handle(), 1, false, value, 0);
        default:
            break;
    }
}
 
開發者ID:gplibs,項目名稱:android-magic-surface-view,代碼行數:21,代碼來源:GLUniformParameter.java

示例2: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
public void draw() {
    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    GLES20.glUseProgram(mProgram);

    int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    int vertexStride = COORDS_PER_VERTEX * 4;
    GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, mVertexBuffer);

    GLES20.glUniform4fv(GLES20.glGetUniformLocation(mProgram, "aColor"), 1, mColor, 0);
    GLES20.glUniform2f(GLES20.glGetUniformLocation(mProgram, "aCirclePosition"), mCenterX, mCenterY);
    GLES20.glUniform1f(GLES20.glGetUniformLocation(mProgram, "aRadius"), mRadius);
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, mDrawOrder.length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer);
    GLES20.glDisableVertexAttribArray(mPositionHandle);
}
 
開發者ID:beetsolutions,項目名稱:opengl_circle,代碼行數:17,代碼來源:GLCircleSprite.java

示例3: 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:MLNO,項目名稱:airgram,代碼行數:71,代碼來源:PhotoFilterView.java

示例4: value2f

import android.opengl.GLES20; //導入方法依賴的package包/類
public void value2f(float v1, float v2) {
	GLES20.glUniform2f(location, v1, v2);
}
 
開發者ID:G2159687,項目名稱:ESPD,代碼行數:4,代碼來源:Uniform.java

示例5: drawFinalScene

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawFinalScene() {
    GLES20.glUseProgram(mSceneGLProgram);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUseProgram");

    mTexHandle = GLES20.glGetUniformLocation(mSceneGLProgram, "s_texture");
    mTexCoordHandle = GLES20.glGetAttribLocation(mSceneGLProgram, "a_texCoord");
    mTriangleVerticesHandle = GLES20.glGetAttribLocation(mSceneGLProgram, "vPosition");
    mProjectionHandle = GLES20.glGetUniformLocation(mSceneGLProgram, "u_projectionRatio");
    
    GLES20.glDisable(GLES20.GL_BLEND);
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);

    GLES20.glViewport(0, 0, mViewWidth, mViewHeight);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");

    GLES20.glUniform1i(mTexHandle, 2);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUniform1i");
    
    GLES20.glUniform2f(mProjectionHandle, DISTORTION_COEF, (DISTORTION_COEF * mViewHeight /(mViewWidth/2.0f)));

    GLES20.glEnableVertexAttribArray(mTexCoordHandle);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glEnableVertexAttribArray");
    GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
            false, 0, mVideoTextureFinalScene);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");

    GLES20.glEnableVertexAttribArray(mTriangleVerticesHandle);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glEnableVertexAttribArray");
    GLES20.glVertexAttribPointer(mTriangleVerticesHandle, 3, GLES20.GL_FLOAT,
            false, 0, mVerticesFinalScene);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glDrawArrays");

    GLES20.glDisableVertexAttribArray(mTexCoordHandle);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glDisableVertexAttribArray");

    GLES20.glDisableVertexAttribArray(mTriangleVerticesHandle);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glDisableVertexAttribArray");
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:42,代碼來源:StereoDiveEffect.java

示例6: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 *
 *  This method takes in the current CameraView Matrix and the Camera's Projection Matrix, the
 *  current position and pose of the device, uses those to calculate the ModelViewMatrix and
 *  ModelViewProjectionMatrix.  It binds the VBO, enables the custom attribute locations,
 *  binds and uploads the shader uniforms, calls our single DrawArray call, and finally disables
 *  and unbinds the shader attributes and VBO.
 *
 * @param cameraView
 * @param cameraPerspective
 * @param screenWidth
 * @param screenHeight
 * @param nearClip
 * @param farClip
 */
public void draw(float[] cameraView, float[] cameraPerspective, float screenWidth, float screenHeight, float nearClip, float farClip) {


    Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0);
    Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0);

    ShaderUtil.checkGLError(TAG, "Before draw");

    GLES20.glUseProgram(mProgramName);
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
    GLES20.glVertexAttribPointer(
            mPositionAttribute, FLOATS_PER_POINT, GLES20.GL_FLOAT, false, BYTES_PER_POINT, mPositionAddress);
    GLES20.glVertexAttribPointer(
            mPreviousAttribute, FLOATS_PER_POINT, GLES20.GL_FLOAT, false, BYTES_PER_POINT, mPreviousAddress);
    GLES20.glVertexAttribPointer(
            mNextAttribute, FLOATS_PER_POINT, GLES20.GL_FLOAT, false, BYTES_PER_POINT, mNextAddress);
    GLES20.glVertexAttribPointer(
            mSideAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mSideAddress);
    GLES20.glVertexAttribPointer(
            mWidthAttribte, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mWidthAddress);
    GLES20.glVertexAttribPointer(
            mCountersAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mCounterAddress);
    GLES20.glUniformMatrix4fv(
            mModelViewUniform, 1, false, mModelViewMatrix, 0);
    GLES20.glUniformMatrix4fv(
            mProjectionUniform, 1, false, cameraPerspective, 0);


    GLES20.glUniform2f(mResolutionUniform, screenWidth, screenHeight);
    GLES20.glUniform1f(mLineWidthUniform, 0.01f);
    GLES20.glUniform3f(mColorUniform, mColor.x, mColor.y, mColor.z);
    GLES20.glUniform1f(mOpacityUniform, 1.0f);
    GLES20.glUniform1f(mNearUniform, nearClip);
    GLES20.glUniform1f(mFarUniform, farClip);
    GLES20.glUniform1f(mSizeAttenuationUniform, 1.0f);
    GLES20.glUniform1f(mVisibility, 1.0f);
    GLES20.glUniform1f(mAlphaTest, 1.0f);
    GLES20.glUniform1f(mDrawModeUniform, mDrawMode?1.0f:0.0f);
    GLES20.glUniform1f(mNearCutoffUniform,  mDrawDistance - 0.0075f);
    GLES20.glUniform1f(mFarCutoffUniform, mDrawDistance + 0.0075f);
    GLES20.glUniform1f(mLineDepthScaleUniform, mLineDepthScale);

    GLES20.glEnableVertexAttribArray(mPositionAttribute);
    GLES20.glEnableVertexAttribArray(mPreviousAttribute);
    GLES20.glEnableVertexAttribArray(mNextAttribute);
    GLES20.glEnableVertexAttribArray(mSideAttribute);
    GLES20.glEnableVertexAttribArray(mWidthAttribte);
    GLES20.glEnableVertexAttribArray(mCountersAttribute);


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


    GLES20.glDisableVertexAttribArray(mCountersAttribute);
    GLES20.glDisableVertexAttribArray(mWidthAttribte);
    GLES20.glDisableVertexAttribArray(mSideAttribute);
    GLES20.glDisableVertexAttribArray(mNextAttribute);
    GLES20.glDisableVertexAttribArray(mPreviousAttribute);
    GLES20.glDisableVertexAttribArray(mPositionAttribute);


    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

    ShaderUtil.checkGLError(TAG, "Draw");
}
 
開發者ID:googlecreativelab,項目名稱:ar-drawing-java,代碼行數:81,代碼來源:LineShaderRenderer.java


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