Java Code Examples for android.opengl.GLES20#glGetUniformLocation()
The following examples show how to use
android.opengl.GLES20#glGetUniformLocation() .
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: FlatShadedProgram.java From AndroidPlayground with MIT License | 6 votes |
/** * Prepares the program in the current EGL context. */ public FlatShadedProgram() { mProgramHandle = GlUtil.createProgram(VERTEX_SHADER, FRAGMENT_SHADER); if (mProgramHandle == 0) { throw new RuntimeException("Unable to create program"); } Log.d(TAG, "Created program " + mProgramHandle); // get locations of attributes and uniforms maPositionLoc = GLES20.glGetAttribLocation(mProgramHandle, "aPosition"); GlUtil.checkLocation(maPositionLoc, "aPosition"); muMVPMatrixLoc = GLES20.glGetUniformLocation(mProgramHandle, "uMVPMatrix"); GlUtil.checkLocation(muMVPMatrixLoc, "uMVPMatrix"); muColorLoc = GLES20.glGetUniformLocation(mProgramHandle, "uColor"); GlUtil.checkLocation(muColorLoc, "uColor"); }
Example 2
Source File: DrawMultiTriangleNet.java From Fatigue-Detection with MIT License | 5 votes |
public void l() { super.l(); this.ej = GLES20.glGetAttribLocation(getProgram(), "inputTextureCoordinate2"); this.ek = GLES20.glGetUniformLocation(getProgram(), "drawMask"); }
Example 3
Source File: ExtractMpegFramesTest_egl14.java From Android-MediaCodec-Examples with Apache License 2.0 | 5 votes |
/** * Initializes GL state. Call this after the EGL surface has been created and made current. */ public void surfaceCreated() { mProgram = createProgram(VERTEX_SHADER, FRAGMENT_SHADER); if (mProgram == 0) { throw new RuntimeException("failed creating program"); } maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition"); checkLocation(maPositionHandle, "aPosition"); maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord"); checkLocation(maTextureHandle, "aTextureCoord"); muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix"); checkLocation(muMVPMatrixHandle, "uMVPMatrix"); muSTMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uSTMatrix"); checkLocation(muSTMatrixHandle, "uSTMatrix"); int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); mTextureID = textures[0]; GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID); checkGlError("glBindTexture mTextureID"); GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); checkGlError("glTexParameter"); }
Example 4
Source File: ExposureFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
@Override protected void initGlFilter(Context context) { String vertexShader = GlUtil.getStringFromRaw(context, R.raw.simple_vertex); String fragmentShader = GlUtil.getStringFromRaw(context, R.raw.exposure_fragment); program = GlUtil.createProgram(vertexShader, fragmentShader); aPositionHandle = GLES20.glGetAttribLocation(program, "aPosition"); aTextureHandle = GLES20.glGetAttribLocation(program, "aTextureCoord"); uMVPMatrixHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix"); uSTMatrixHandle = GLES20.glGetUniformLocation(program, "uSTMatrix"); uSamplerHandle = GLES20.glGetUniformLocation(program, "uSampler"); uExposureHandle = GLES20.glGetUniformLocation(program, "uExposure"); }
Example 5
Source File: MultipleTextureFilter.java From In77Camera with MIT License | 5 votes |
@Override public void init() { super.init(); externalBitmapTextures=new BitmapTexture[textureSize]; for(int i=0;i<textureSize;i++){ externalBitmapTextures[i]=new BitmapTexture(); } externalTextureHandles=new int[textureSize]; for(int i=0;i<textureSize;i++){ externalTextureHandles[i] = GLES20.glGetUniformLocation(glSimpleProgram.getProgramId(),"sTexture"+(i+2)); } }
Example 6
Source File: CartoonFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
@Override protected void initGlFilter(Context context) { String vertexShader = GlUtil.getStringFromRaw(context, R.raw.simple_vertex); String fragmentShader = GlUtil.getStringFromRaw(context, R.raw.cartoon_fragment); program = GlUtil.createProgram(vertexShader, fragmentShader); aPositionHandle = GLES20.glGetAttribLocation(program, "aPosition"); aTextureHandle = GLES20.glGetAttribLocation(program, "aTextureCoord"); uMVPMatrixHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix"); uSTMatrixHandle = GLES20.glGetUniformLocation(program, "uSTMatrix"); uSamplerHandle = GLES20.glGetUniformLocation(program, "uSampler"); uCartoonHandle = GLES20.glGetUniformLocation(program, "uCartoon"); }
Example 7
Source File: GPUImageHalftoneFilter.java From SimpleVideoEditor with Apache License 2.0 | 5 votes |
@Override public void onInit() { super.onInit(); mFractionalWidthOfPixelLocation = GLES20.glGetUniformLocation(getProgram(), "fractionalWidthOfPixel"); mAspectRatioLocation = GLES20.glGetUniformLocation(getProgram(), "aspectRatio"); setFractionalWidthOfAPixel(mFractionalWidthOfAPixel); }
Example 8
Source File: ShaderExplosionParticles.java From Tanks with MIT License | 5 votes |
@Override protected void getLocations() { attributeDirectionVectorHandle = GLES20.glGetAttribLocation(programHandle, "a_directionVector"); uniformLifeTimeHandle = GLES20.glGetUniformLocation(programHandle, "u_lifeTime"); uniformMatrixHandle = GLES20.glGetUniformLocation(programHandle, "u_matrix"); uniformTextureHandle = GLES20.glGetUniformLocation(programHandle, "u_texture"); uniformPointSize = GLES20.glGetUniformLocation(programHandle, "u_pointSize"); uniformExplosionSize = GLES20.glGetUniformLocation(programHandle, "u_explosionSize"); uniformStartColor = GLES20.glGetUniformLocation(programHandle, "u_startColor"); uniformEndColor = GLES20.glGetUniformLocation(programHandle, "u_endColor"); }
Example 9
Source File: TextureKernelShaderProgram.java From Spectaculum with Apache License 2.0 | 5 votes |
public TextureKernelShaderProgram(Kernel kernel) { super("fs_texture_kernel.glsl"); mKernelHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_Kernel"); GLUtils.checkError("glGetUniformLocation u_Kernel"); mTexOffsetHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_TexOffset"); GLUtils.checkError("glGetUniformLocation u_TexOffset"); setKernel(kernel); }
Example 10
Source File: GLRenderer.java From bombsquad-remote-android with Apache License 2.0 | 5 votes |
void draw(float[] mvpMatrix, float r, float g, float b, float a) { // Add program to OpenGL environment GLES20.glUseProgram(mProgram); // get handle to vertex shader's vPosition member int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition"); // Enable a handle to the triangle vertices GLES20.glEnableVertexAttribArray(mPositionHandle); // Prepare the triangle coordinate data int vertexStride = COORDS_PER_VERTEX * 4; GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer); // get handle to fragment shader's vColor member int mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor"); // Set color for drawing the triangle float[] color = {r, g, b, a}; GLES20.glUniform4fv(mColorHandle, 1, color, 0); // get handle to shape's transformation matrix int mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix"); GLRenderer.checkGlError("glGetUniformLocation"); // Apply the projection and view transformation GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0); GLRenderer.checkGlError("glUniformMatrix4fv"); // Draw the square GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT, drawListBuffer); // Disable vertex array GLES20.glDisableVertexAttribArray(mPositionHandle); }
Example 11
Source File: MxOneHashBaseFilter.java From In77Camera with MIT License | 5 votes |
@Override public void init() { super.init(); for(int i=0;i<HISTOGRAM_SIZE;i++){ mHistogram[i]=(rgbMap[i] << 24); } bitmapTexture=new BitmapTexture(); bitmapTexture.loadBitmap(Bitmap.createBitmap(mHistogram, 256, 1, Bitmap.Config.ARGB_8888)); uTextureSamplerHandle2= GLES20.glGetUniformLocation(glSimpleProgram.getProgramId(),"sTexture2"); ShaderUtils.checkGlError("glGetUniformLocation sTexture2"); }
Example 12
Source File: BezierRenderer.java From Muzesto with GNU General Public License v3.0 | 4 votes |
private void drawGl() { GLES20.glClearColor(mBgColor[0], mBgColor[1], mBgColor[2], mBgColor[3]); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); GLES20.glUseProgram(programHandle); // Set program handles mvpMatrixHandle = GLES20.glGetUniformLocation(programHandle, "u_MVPMatrix"); mvMatrixHandle = GLES20.glGetUniformLocation(programHandle, "u_MVMatrix"); colorHandle = GLES20.glGetUniformLocation(programHandle, "u_Color"); ampHandle = GLES20.glGetUniformLocation(programHandle, "u_Amp"); bzDataHandle = GLES20.glGetUniformLocation(programHandle, "u_BzData"); bzCtrlDataHandle = GLES20.glGetUniformLocation(programHandle, "u_BzDataCtrl"); bgColorHandle = GLES20.glGetUniformLocation(programHandle, "u_BgColor"); tDataHandle = GLES20.glGetAttribLocation(programHandle, "a_TData"); Matrix.setIdentityM(mModelMatrix, 0); Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, 5f); // Set a matrix that contains the current rotation. Matrix.setIdentityM(mCurrentRotation, 0); Matrix.multiplyMM(mTemporaryMatrix, 0, mCurrentRotation, 0, mAccumulatedRotation, 0); System.arraycopy(mTemporaryMatrix, 0, mAccumulatedRotation, 0, 16); Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); // Pass in the modelview matrix. GLES20.glUniformMatrix4fv(mvMatrixHandle, 1, false, mMVPMatrix, 0); Matrix.multiplyMM(mTemporaryMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); System.arraycopy(mTemporaryMatrix, 0, mMVPMatrix, 0, 16); // Pass in the combined matrix. GLES20.glUniformMatrix4fv(mvpMatrixHandle, 1, false, mMVPMatrix, 0); GLES20.glEnable(GLES20.GL_BLEND); GLES20.glBlendFuncSeparate( GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_COLOR, GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA ); // Screen blend mode GLES20.glBlendEquationSeparate(GLES20.GL_FUNC_ADD, GLES20.GL_FUNC_ADD); GLES20.glUniform4fv(bgColorHandle, 1, mBgColor, 0); if (mBezierCurves != null) { for (int i = 0, len = mBezierCurves.length; i < len; i++) { com.yalantis.waves.gl.CubicBezier bezierCurve = mBezierCurves[i]; GLES20.glUniform1f(ampHandle, mAmps[i / 2]); // each amplitude is reused two times bezierCurve.render(false); bezierCurve.render(true); } } }
Example 13
Source File: VideoRenderThread.java From ParsingPlayer with GNU Lesser General Public License v2.1 | 4 votes |
@WorkerThread private void performRenderPoster(Bitmap bitmap, boolean recycled) { int texture = createTexture(bitmap, recycled, GLES20.GL_TEXTURE_2D); int program = GLES20.glCreateProgram(); if (program == 0) { checkGLESError("create program"); } int vertexShader = createShader(GLES20.GL_VERTEX_SHADER, VERTEX_SHADER); int fragmentShader = createShader(GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER); GLES20.glAttachShader(program, vertexShader); checkGLESError("attach shader " + vertexShader); GLES20.glAttachShader(program, fragmentShader); checkGLESError("attach shader " + fragmentShader); GLES20.glLinkProgram(program); int[] linked = new int[1]; GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linked, 0); if (linked[0] == 0) { checkGLESError("link program " + GLES20.glGetProgramInfoLog(program)); } GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); GLES20.glUseProgram(program); checkGLESError("use program"); int positionIndex = GLES20.glGetAttribLocation(program, "aPosition"); int texcoordIndex = GLES20.glGetAttribLocation(program, "aTexCoord"); GLES20.glVertexAttribPointer(positionIndex, 3, GLES20.GL_FLOAT, false, 0, vertexByteBuffer); GLES20.glVertexAttribPointer(texcoordIndex, 2, GLES20.GL_FLOAT, false, 0, textureByteBuffer); GLES20.glEnableVertexAttribArray(positionIndex); GLES20.glEnableVertexAttribArray(texcoordIndex); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture); int tex = GLES20.glGetUniformLocation(program, "sTexture"); GLES20.glUniform1i(tex, 0); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); egl10.eglSwapBuffers(eglDisplay, eglSurface); Log.d(TAG, "performRenderPoster"); GLES20.glDisableVertexAttribArray(positionIndex); GLES20.glDisableVertexAttribArray(texcoordIndex); }
Example 14
Source File: TexturePool.java From ZGDanmaku with Apache License 2.0 | 4 votes |
public static int getOffsetXHandle() { if (mOffsetXHandle == -1) { mOffsetXHandle = GLES20.glGetUniformLocation(mProgram, "offsetX"); } return mOffsetXHandle; }
Example 15
Source File: TextureRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void surfaceCreated() { mProgram = createProgram(VERTEX_SHADER, FRAGMENT_SHADER); if (mProgram == 0) { throw new RuntimeException("failed creating program"); } maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition"); checkGlError("glGetAttribLocation aPosition"); if (maPositionHandle == -1) { throw new RuntimeException("Could not get attrib location for aPosition"); } maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord"); checkGlError("glGetAttribLocation aTextureCoord"); if (maTextureHandle == -1) { throw new RuntimeException("Could not get attrib location for aTextureCoord"); } muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix"); checkGlError("glGetUniformLocation uMVPMatrix"); if (muMVPMatrixHandle == -1) { throw new RuntimeException("Could not get attrib location for uMVPMatrix"); } muSTMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uSTMatrix"); checkGlError("glGetUniformLocation uSTMatrix"); if (muSTMatrixHandle == -1) { throw new RuntimeException("Could not get attrib location for uSTMatrix"); } int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); mTextureID = textures[0]; GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID); checkGlError("glBindTexture mTextureID"); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); checkGlError("glTexParameter"); Matrix.setIdentityM(mMVPMatrix, 0); if (rotationAngle != 0) { Matrix.rotateM(mMVPMatrix, 0, rotationAngle, 0, 0, 1); } }
Example 16
Source File: MyGLRenderer.java From myMediaCodecPlayer-for-FPV with MIT License | 4 votes |
@Override public void onSurfaceCreated(GL10 glUnused, EGLConfig config) { GLES20.glClearColor(0.0f, 0.0f, 0.07f, 0.0f); // mProgram = OpenGLHelper.createProgram(MyGLRendererHelper.getVertexShader(), MyGLRendererHelper.getFragmentShader()); maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition"); OpenGLHelper.checkGlError("glGetAttribLocation aPosition"); maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord"); OpenGLHelper.checkGlError("glGetAttribLocation aTextureCoord"); maMVPMatrixHandle=GLES20.glGetUniformLocation(mProgram,"uMVPMatrix"); OpenGLHelper.checkGlError("glGetAttribLocation uMVPMatrix"); //we have to create the texture for the overdraw,too GLES20.glGenTextures(2, textures, 0); mTextureID = textures[0]; //I don't know why,but it seems like when you use both external and normal textures,you have to use normal textures for the first, //and the external texture for the second unit; bug ? GLES20.glActiveTexture(GLES20.GL_TEXTURE1); GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID); OpenGLHelper.checkGlError("glBindTexture mTextureID"); GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); //mSurfaceTexture = new SurfaceTexture(mTextureID); //Enable double buffering,because MediaCodec and OpenGL don't have any synchronisation ? //For me,it seems like db hasn't really implemented or has no effect mSurfaceTexture = new SurfaceTexture(mTextureID,false); mDecoderSurface=new Surface(mSurfaceTexture); mDecoder=new UdpReceiverDecoderThread(mDecoderSurface,5000, mContext); mDecoder.startDecoding(); mOSD=new MyOSDReceiverRenderer(mContext,textures,mLeftEyeViewM,mRightEyeViewM,mProjM,videoFormat, modelDistance, videoDistance); mOSD.startReceiving(); mHeadTracker=HeadTracker.createFromContext(mContext); mHeadTracker.setNeckModelEnabled(true); final Phone.PhoneParams phoneParams = PhoneParams.readFromExternalStorage(); if (phoneParams != null) { this.mHeadTracker.setGyroBias(phoneParams.gyroBias); } if (headTracking) { mHeadTracker.startTracking(); } if(swapIntervallZero){ EGL14.eglSwapInterval(EGL14.eglGetCurrentDisplay(), 0); } }
Example 17
Source File: ColorFilterShaderProgram.java From Spectaculum with Apache License 2.0 | 4 votes |
public ColorFilterShaderProgram() { super("fs_colorfilter.glsl"); mColorHandle = GLES20.glGetUniformLocation(mProgramHandle, "color"); GLUtils.checkError("glGetUniformLocation color"); }
Example 18
Source File: DirectionalNonMaximumSuppressionFilter.java From UltimateAndroid with Apache License 2.0 | votes |
@Override protected void initShaderHandles() { super.initShaderHandles(); upperThresholdHandle = GLES20.glGetUniformLocation(programHandle, UNIFORM_UPPER_THRESHOLD); lowerThresholdHandle = GLES20.glGetUniformLocation(programHandle, UNIFORM_LOWER_THRESHOLD); }
Example 19
Source File: ContrastFilter.java From UltimateAndroid with Apache License 2.0 | votes |
@Override protected void initShaderHandles() { super.initShaderHandles(); contrastHandle = GLES20.glGetUniformLocation(programHandle, UNIFORM_CONTRAST); }
Example 20
Source File: ToonFilter.java From UltimateAndroid with Apache License 2.0 | votes |
@Override protected void initShaderHandles() { super.initShaderHandles(); thresholdHandle = GLES20.glGetUniformLocation(programHandle, UNIFORM_THRESHOLD); quantizationLevelsHandle = GLES20.glGetUniformLocation(programHandle, UNIFORM_QUANTIZATION); }