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

The following examples show how to use android.opengl.GLES20#glUniform3f() . 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: ColorFilterRender.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 6 votes vote down vote up
@Override
protected void drawFilter() {
  GLES20.glUseProgram(program);

  squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET);
  GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aPositionHandle);

  squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET);
  GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aTextureHandle);

  GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0);
  GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0);
  GLES20.glUniform3f(uColorHandle, red, green, blue);
  GLES20.glUniform1i(uSamplerHandle, 4);
  GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId);
}
 
Example 2
Source File: SaturationFilterRender.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 6 votes vote down vote up
@Override
protected void drawFilter() {
  GLES20.glUseProgram(program);

  squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET);
  GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aPositionHandle);

  squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET);
  GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aTextureHandle);

  GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0);
  GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0);
  GLES20.glUniform1f(uShiftHandle, shift);
  GLES20.glUniform3f(uWeightsHandle, weights[0], weights[1], weights[2]);
  GLES20.glUniform3f(uExponentsHandle, exponents[0], exponents[1], exponents[2]);
  GLES20.glUniform1f(uSaturationHandle, saturation);

  GLES20.glUniform1i(uSamplerHandle, 4);
  GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId);
}
 
Example 3
Source File: RGBSaturationFilterRender.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 6 votes vote down vote up
@Override
protected void drawFilter() {
  GLES20.glUseProgram(program);

  squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET);
  GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aPositionHandle);

  squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET);
  GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aTextureHandle);

  GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0);
  GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0);
  GLES20.glUniform3f(uRGBSaturationHandle, r, g, b);

  GLES20.glUniform1i(uSamplerHandle, 4);
  GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId);
}
 
Example 4
Source File: DuotoneFilterRender.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 6 votes vote down vote up
@Override
protected void drawFilter() {
  GLES20.glUseProgram(program);

  squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET);
  GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aPositionHandle);

  squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET);
  GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false,
      SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aTextureHandle);

  GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0);
  GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0);
  GLES20.glUniform3f(uColorHandle, red, green, blue);
  GLES20.glUniform3f(uColor2Handle, red2, green2, blue2);

  GLES20.glUniform1i(uSamplerHandle, 4);
  GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId);
}
 
Example 5
Source File: ShaderProgram.java    From Animer with Apache License 2.0 5 votes vote down vote up
public void setOnDrawFrame(float[] resolution,float time,float[] factors,float mode,float duration,float[] mainColor,float[] secondaryColor){
    // ######################### clear the canvas #########################
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    // #########################   first program  #########################
    GLES20.glUseProgram(program);
    if (positionLoc > -1){ GLES20.glVertexAttribPointer(positionLoc, mPositionDataSize, GLES20.GL_FLOAT, false,0, vertexBuffer); }
    if (resolutionLoc > -1) { GLES20.glUniform2fv(resolutionLoc,1,resolution,0); }
    if (timeLoc > -1) { GLES20.glUniform1f(timeLoc,time); }
    if (modeLoc > -1) { GLES20.glUniform1f(modeLoc,mode); }
    if (durationLoc > -1) { GLES20.glUniform1f(durationLoc,duration); }
    if (mainColorLoc > -1) { GLES20.glUniform3f(mainColorLoc,mainColor[0],mainColor[1],mainColor[2]); }
    if (secondaryColorLoc > -1) { GLES20.glUniform3f(secondaryColorLoc,secondaryColor[0],secondaryColor[1],secondaryColor[2]); }

    //5 Factors
    for (int i = 0; i < factorLength; ++i) { //factorLocs.length
        factorLocs[i] = GLES20.glGetUniformLocation(program,UNIFORM_FACTOR + (i+1));
        GLES20.glUniform1f(factorLocs[i],factors[i]);
    }


    //Draw the triangle facing straight on.
    if(mvpLoc > -1){
        Matrix.setIdentityM(mModelMatrix, 0);
        Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
        Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
        GLES20.glUniformMatrix4fv(mvpLoc, 1, false, mMVPMatrix, 0);
    }


    GLES20.glViewport(0,0,(int) resolution[0],(int) resolution[1]);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glDrawArrays(GL_TRIANGLE_STRIP,0,4);
}
 
Example 6
Source File: RenderFeature2.java    From geoar-app with Apache License 2.0 4 votes vote down vote up
public void setLightPosition(float[] lightPosInEyeSpace) {
	GLES20.glUniform3f(renderer.getLightPosHandle(), lightPosInEyeSpace[0],
			lightPosInEyeSpace[1], lightPosInEyeSpace[2]);
}
 
Example 7
Source File: PhotoFilterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void drawCustomParamsPass() {
    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(toolsShaderProgram);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
    GLES20.glUniform1i(sourceImageHandle, 0);
    if (showOriginal) {
        GLES20.glUniform1f(shadowsHandle, 1);
        GLES20.glUniform1f(highlightsHandle, 1);
        GLES20.glUniform1f(exposureHandle, 0);
        GLES20.glUniform1f(contrastHandle, 1);
        GLES20.glUniform1f(saturationHandle, 1);
        GLES20.glUniform1f(warmthHandle, 0);
        GLES20.glUniform1f(vignetteHandle, 0);
        GLES20.glUniform1f(grainHandle, 0);
        GLES20.glUniform1f(fadeAmountHandle, 0);
        GLES20.glUniform3f(highlightsTintColorHandle, 0, 0, 0);
        GLES20.glUniform1f(highlightsTintIntensityHandle, 0);
        GLES20.glUniform3f(shadowsTintColorHandle, 0, 0, 0);
        GLES20.glUniform1f(shadowsTintIntensityHandle, 0);
        GLES20.glUniform1f(skipToneHandle, 1);
    } else {
        GLES20.glUniform1f(shadowsHandle, getShadowsValue());
        GLES20.glUniform1f(highlightsHandle, getHighlightsValue());
        GLES20.glUniform1f(exposureHandle, getExposureValue());
        GLES20.glUniform1f(contrastHandle, getContrastValue());
        GLES20.glUniform1f(saturationHandle, getSaturationValue());
        GLES20.glUniform1f(warmthHandle, getWarmthValue());
        GLES20.glUniform1f(vignetteHandle, getVignetteValue());
        GLES20.glUniform1f(grainHandle, getGrainValue());
        GLES20.glUniform1f(fadeAmountHandle, getFadeValue());
        GLES20.glUniform3f(highlightsTintColorHandle, (tintHighlightsColor >> 16 & 0xff) / 255.0f, (tintHighlightsColor >> 8 & 0xff) / 255.0f, (tintHighlightsColor & 0xff) / 255.0f);
        GLES20.glUniform1f(highlightsTintIntensityHandle, getTintHighlightsIntensityValue());
        GLES20.glUniform3f(shadowsTintColorHandle, (tintShadowsColor >> 16 & 0xff) / 255.0f, (tintShadowsColor >> 8 & 0xff) / 255.0f, (tintShadowsColor & 0xff) / 255.0f);
        GLES20.glUniform1f(shadowsTintIntensityHandle, getTintShadowsIntensityValue());
        boolean skipTone = curvesToolValue.shouldBeSkipped();
        GLES20.glUniform1f(skipToneHandle, skipTone ? 1.0f : 0.0f);
        if (!skipTone) {
            curvesToolValue.fillBuffer();
            GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
            GLES20.glBindTexture(GL10.GL_TEXTURE_2D, curveTextures[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, 200, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, curvesToolValue.curveBuffer);
            GLES20.glUniform1i(curvesImageHandle, 1);
        }
    }

    GLES20.glUniform1f(widthHandle, renderBufferWidth);
    GLES20.glUniform1f(heightHandle, renderBufferHeight);
    GLES20.glEnableVertexAttribArray(inputTexCoordHandle);
    GLES20.glVertexAttribPointer(inputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
 
Example 8
Source File: LineShaderRenderer.java    From justaline-android with Apache License 2.0 4 votes vote down vote up
/**
     * 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.
     */
    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.glDisable(GLES20.GL_DEPTH_TEST);

        // Blending setup
        GLES20.glEnable(GLES20.GL_BLEND);
//        GLES20.glBlendFuncSeparate(
//                GLES20.GL_SRC_ALPHA, GLES20.GL_DST_ALPHA, // RGB (src, dest)
//                GLES20.GL_ZERO, GLES20.GL_ONE); // ALPHA (src, dest)
        GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

        // Attach the texture.
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);

//        GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
//        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[1]);

//        GLES20.glUniform1i(mTextureUniform, 0);
        GLES20.glUniform1i(mEndCapTextureUniform, 0);
//
        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(
                mWidthAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mWidthAddress);
        GLES20.glVertexAttribPointer(
                mLengthsAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mLengthAddress);
        GLES20.glVertexAttribPointer(
                mEndCapsAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mEndCapsAddress);
//

        GLES20.glUniformMatrix4fv(
                mModelViewUniform, 1, false, mModelViewMatrix, 0);
        GLES20.glUniformMatrix4fv(
                mProjectionUniform, 1, false, cameraPerspective, 0);

        GLES20.glUniform2f(mResolutionUniform, screenWidth, screenHeight);
        GLES20.glUniform3f(mColorUniform, mColor.x, mColor.y, mColor.z);
        GLES20.glUniform1f(mNearUniform, nearClip);
        GLES20.glUniform1f(mFarUniform, farClip);
        GLES20.glUniform1f(mLineDepthScaleUniform, mLineDepthScale);
        GLES20.glUniform1f(mDrawingDistUniform, mDrawDistance);

        GLES20.glEnableVertexAttribArray(mPositionAttribute);
        GLES20.glEnableVertexAttribArray(mPreviousAttribute);
        GLES20.glEnableVertexAttribArray(mNextAttribute);
        GLES20.glEnableVertexAttribArray(mSideAttribute);
        GLES20.glEnableVertexAttribArray(mWidthAttribute);
        GLES20.glEnableVertexAttribArray(mLengthsAttribute);
        GLES20.glEnableVertexAttribArray(mEndCapsAttribute);

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

        GLES20.glDisableVertexAttribArray(mEndCapsAttribute);
        GLES20.glDisableVertexAttribArray(mLengthsAttribute);
        GLES20.glDisableVertexAttribArray(mWidthAttribute);
        GLES20.glDisableVertexAttribArray(mSideAttribute);
        GLES20.glDisableVertexAttribArray(mNextAttribute);
        GLES20.glDisableVertexAttribArray(mPreviousAttribute);
        GLES20.glDisableVertexAttribArray(mPositionAttribute);


        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
//        GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
//        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
//        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

        GLES20.glDisable(GLES20.GL_BLEND);
        GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    }
 
Example 9
Source File: LineShaderRenderer.java    From ar-drawing-java with Apache License 2.0 4 votes vote down vote up
/**
 *
 *  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");
}
 
Example 10
Source File: ShaderProgram.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public void setUniformOptional(final String pUniformName, final float pX, final float pY, final float pZ) {
	final int location = this.getUniformLocationOptional(pUniformName);
	if(location != ShaderProgramConstants.LOCATION_INVALID) {
		GLES20.glUniform3f(this.getUniformLocationOptional(pUniformName), pX, pY, pZ);
	}
}
 
Example 11
Source File: GLES20DrawContext.java    From settlers-remake with MIT License 4 votes vote down vote up
@Override
public void drawUnified2D(GeometryHandle geometry, TextureHandle texture, int primitive, int offset, int vertices, boolean image, boolean shadow, float x, float y, float z, float sx, float sy, float sz, AbstractColor color, float intensity) {
	useProgram(prog_unified);
	bindTexture(texture);

	if(image) {
		float r, g, b, a;
		if (color != null) {
			r = color.red * intensity;
			g = color.green * intensity;
			b = color.blue * intensity;
			a = color.alpha;
		} else {
			r = g = b = intensity;
			a = 1;
		}

		if(ulr != r || ulg != g || ulb != b || ula != a) {
			ulr = r;
			ulg = g;
			ulb = b;
			ula = a;
			GLES20.glUniform4f(prog_unified.ufs[COLOR], r, g, b, a);
		}
	}

	if(ulim != image || ulsh != shadow || uli != intensity) {
		GLES20.glUniform3f(prog_unified.ufs[UNI_INFO], image?1:0, shadow?1:0, intensity);
		ulim = image;
		ulsh = shadow;
		uli = intensity;
	}

	GLES20.glUniform3fv(lastProgram.ufs[TRANS], 2, new float[] {x, y, z, sx, sy, sz}, 0);

	if(gles3) {
		bindFormat(geometry.getInternalFormatId());
	} else {
		bindGeometry(geometry);
		specifyFormat(geometry.getFormat());
	}
	GLES20.glDrawArrays(primitive, offset*vertices, vertices);
}
 
Example 12
Source File: TextureSobelShaderProgram.java    From Spectaculum with Apache License 2.0 4 votes vote down vote up
public void setColor(float r, float g, float b) {
    use();
    GLES20.glUniform3f(mColorHandle, r, g, b);
}
 
Example 13
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void uniform3f(int location, float x, float y, float z) {
    GLES20.glUniform3f(location, x, y, z);

}
 
Example 14
Source File: ShaderProgram.java    From tilt-game-android with MIT License 4 votes vote down vote up
public void setUniform(final String pUniformName, final float pX, final float pY, final float pZ) {
	GLES20.glUniform3f(this.getUniformLocation(pUniformName), pX, pY, pZ);
}
 
Example 15
Source File: FilterShaders.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void drawCustomParamsPass() {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[isVideo ? 0 : 1]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[isVideo ? 0 : 1], 0);

    GLES20.glUseProgram(toolsShaderProgram);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[isVideo ? 1 : 0]);
    GLES20.glUniform1i(sourceImageHandle, 0);
    if (delegate == null || delegate.shouldShowOriginal()) {
        GLES20.glUniform1f(shadowsHandle, 1);
        GLES20.glUniform1f(highlightsHandle, 1);
        GLES20.glUniform1f(exposureHandle, 0);
        GLES20.glUniform1f(contrastHandle, 1);
        GLES20.glUniform1f(saturationHandle, 1);
        GLES20.glUniform1f(warmthHandle, 0);
        GLES20.glUniform1f(vignetteHandle, 0);
        GLES20.glUniform1f(grainHandle, 0);
        GLES20.glUniform1f(fadeAmountHandle, 0);
        GLES20.glUniform3f(highlightsTintColorHandle, 0, 0, 0);
        GLES20.glUniform1f(highlightsTintIntensityHandle, 0);
        GLES20.glUniform3f(shadowsTintColorHandle, 0, 0, 0);
        GLES20.glUniform1f(shadowsTintIntensityHandle, 0);
        GLES20.glUniform1f(skipToneHandle, 1);
    } else {
        GLES20.glUniform1f(shadowsHandle, delegate.getShadowsValue());
        GLES20.glUniform1f(highlightsHandle, delegate.getHighlightsValue());
        GLES20.glUniform1f(exposureHandle, delegate.getExposureValue());
        GLES20.glUniform1f(contrastHandle, delegate.getContrastValue());
        GLES20.glUniform1f(saturationHandle, delegate.getSaturationValue());
        GLES20.glUniform1f(warmthHandle, delegate.getWarmthValue());
        GLES20.glUniform1f(vignetteHandle, delegate.getVignetteValue());
        GLES20.glUniform1f(grainHandle, delegate.getGrainValue());
        GLES20.glUniform1f(fadeAmountHandle, delegate.getFadeValue());
        int tintHighlightsColor = delegate.getTintHighlightsColor();
        int tintShadowsColor = delegate.getTintShadowsColor();
        GLES20.glUniform3f(highlightsTintColorHandle, (tintHighlightsColor >> 16 & 0xff) / 255.0f, (tintHighlightsColor >> 8 & 0xff) / 255.0f, (tintHighlightsColor & 0xff) / 255.0f);
        GLES20.glUniform1f(highlightsTintIntensityHandle, delegate.getTintHighlightsIntensityValue());
        GLES20.glUniform3f(shadowsTintColorHandle, (tintShadowsColor >> 16 & 0xff) / 255.0f, (tintShadowsColor >> 8 & 0xff) / 255.0f, (tintShadowsColor & 0xff) / 255.0f);
        GLES20.glUniform1f(shadowsTintIntensityHandle, delegate.getTintShadowsIntensityValue());
        boolean shouldDrawCurvesPass = delegate.shouldDrawCurvesPass();
        GLES20.glUniform1f(skipToneHandle, shouldDrawCurvesPass ? 0.0f : 1.0f);
        if (shouldDrawCurvesPass) {
            ByteBuffer curveBuffer = delegate.fillAndGetCurveBuffer();
            GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
            GLES20.glBindTexture(GL10.GL_TEXTURE_2D, curveTextures[0]);
            GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 200, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, curveBuffer);
            GLES20.glUniform1i(curvesImageHandle, 1);
        }
    }

    GLES20.glUniform1f(widthHandle, renderBufferWidth);
    GLES20.glUniform1f(heightHandle, renderBufferHeight);
    GLES20.glEnableVertexAttribArray(inputTexCoordHandle);
    GLES20.glVertexAttribPointer(inputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
 
Example 16
Source File: ChromaKeyFilter.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform3f(colourHandle, colour[0], colour[1], colour[2]);
		GLES20.glUniform1f(thresholdHandle, threshold);
		GLES20.glUniform1f(smoothingHandle, smoothing);
	} 
Example 17
Source File: VignetteFilter.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform2f(centerHandle, center.x, center.y);
		GLES20.glUniform3f(colourHandle, colour[0], colour[1], colour[2]);
		GLES20.glUniform1f(startHandle, start);
		GLES20.glUniform1f(endHandle, end);
	} 
Example 18
Source File: ChromaKeyBlendFilter.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform3f(colourHandle, colour[0], colour[1], colour[2]);
		GLES20.glUniform1f(thresholdHandle, threshold);
		GLES20.glUniform1f(smoothingHandle, smoothing);
	} 
Example 19
Source File: FalseColourFilter.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform3f(shadowColourHandle, shadowColour[0], shadowColour[1], shadowColour[2]);
		GLES20.glUniform3f(highlightColourHandle, highlightColour[0], highlightColour[1], highlightColour[2]);
	} 
Example 20
Source File: VignetteFilter.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform2f(centerHandle, center.x, center.y);
		GLES20.glUniform3f(colourHandle, colour[0], colour[1], colour[2]);
		GLES20.glUniform1f(startHandle, start);
		GLES20.glUniform1f(endHandle, end);
	}