本文整理匯總了Java中android.opengl.GLES20.glUniform1f方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glUniform1f方法的具體用法?Java GLES20.glUniform1f怎麽用?Java GLES20.glUniform1f使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glUniform1f方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareTexture
import android.opengl.GLES20; //導入方法依賴的package包/類
private void prepareTexture(BasicTexture texture, int program, ShaderParameter[] params) {
deleteRecycledResources();
GLES20.glUseProgram(program);
checkError();
GLES20.glDisable(GLES20.GL_BLEND);
checkError();
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
checkError();
texture.onBind(this);
GLES20.glBindTexture(GL_TARGET, texture.getId());
checkError();
GLES20.glUniform1i(params[INDEX_TEXTURE_SAMPLER].handle, 0);
checkError();
GLES20.glUniform1f(params[INDEX_ALPHA].handle, 1);
checkError();
}
示例2: 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;
}
}
示例3: drawSharpenPass
import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawSharpenPass() {
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(sharpenShaderProgram);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
GLES20.glUniform1i(sharpenSourceImageHandle, 0);
if (showOriginal) {
GLES20.glUniform1f(sharpenHandle, 0);
} else {
GLES20.glUniform1f(sharpenHandle, getSharpenValue());
}
GLES20.glUniform1f(sharpenWidthHandle, renderBufferWidth);
GLES20.glUniform1f(sharpenHeightHandle, renderBufferHeight);
GLES20.glEnableVertexAttribArray(sharpenInputTexCoordHandle);
GLES20.glVertexAttribPointer(sharpenInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(sharpenPositionHandle);
GLES20.glVertexAttribPointer(sharpenPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
示例4: 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);
}
示例5: setMaterial
import android.opengl.GLES20; //導入方法依賴的package包/類
private void setMaterial(float r,float g,float b,float a) {
//マテリアルの環境光色の指定
GLES20.glUniform4f(GLES.materialAmbientHandle,r,g,b,a);
//マテリアルの拡散光色の指定
GLES20.glUniform4f(GLES.materialDiffuseHandle,r,g,b,a);
//マテリアルの鏡麵光色と鏡麵指數の指定
GLES20.glUniform4f(GLES.materialSpecularHandle,r,g,b,a);
GLES20.glUniform1f(GLES.materialShininessHandle,0.6f);
}
示例6: bindGLSLValues
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void bindGLSLValues(float[] mvpMatrix, FloatBuffer vertexBuffer, int coordsPerVertex,
int vertexStride, float[] texMatrix, FloatBuffer texBuffer, int texStride) {
super.bindGLSLValues(mvpMatrix, vertexBuffer, coordsPerVertex, vertexStride, texMatrix,
texBuffer, texStride);
if (mWidthOrHeight) {
GLES20.glUniform1f(muTexelWidthOffset,
mIncomingWidth == 0 ? 0f : mBlurRatio / mIncomingWidth);
} else {
GLES20.glUniform1f(muTexelHeightOffset,
mIncomingHeight == 0 ? 0f : mBlurRatio / mIncomingHeight);
}
}
示例7: draw
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* Renders the point cloud.
*
* @param pose the current point cloud pose, from {@link Frame#getPointCloudPose()}.
* @param cameraView the camera view matrix for this frame, typically from
* {@link Frame#getViewMatrix(float[], int)}.
* @param cameraPerspective the camera projection matrix for this frame, typically from
* {@link Session#getProjectionMatrix(float[], int, float, float)}.
*/
public void draw(Pose pose, float[] cameraView, float[] cameraPerspective) {
float[] modelMatrix = new float[16];
pose.toMatrix(modelMatrix, 0);
float[] modelView = new float[16];
float[] modelViewProjection = new float[16];
Matrix.multiplyMM(modelView, 0, cameraView, 0, modelMatrix, 0);
Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, modelView, 0);
ShaderUtil.checkGLError(TAG, "Before draw");
GLES20.glUseProgram(mProgramName);
GLES20.glEnableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
GLES20.glVertexAttribPointer(
mPositionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0);
GLES20.glUniform4f(mColorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f);
GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, modelViewProjection, 0);
GLES20.glUniform1f(mPointSizeUniform, 5.0f);
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, mNumPoints);
GLES20.glDisableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "Draw");
}
示例8: glUniform1f
import android.opengl.GLES20; //導入方法依賴的package包/類
public static void glUniform1f(final int aUniformHandle, final float aValue)
{
//.if DESKTOP
//|gl.glUniform1f(aUniformHandle, aValue);
//.elseif ANDROID
GLES20.glUniform1f(aUniformHandle, aValue);
//.endif
}
示例9: 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(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 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);
}
示例10: onSetExpandData
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void onSetExpandData() {
super.onSetExpandData();
GLES20.glUniform1f(mGLWidth,this.mWidth);
GLES20.glUniform1f(mGLHeight,this.mHeight);
}
示例11: onSetExpandData
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void onSetExpandData() {
super.onSetExpandData();
GLES20.glUniform1f(mGLWidth,mWidth);
GLES20.glUniform1f(mGLHeight,mHeight);
}
示例12: value1f
import android.opengl.GLES20; //導入方法依賴的package包/類
public void value1f(float value) {
GLES20.glUniform1f(location, value);
}
示例13: bindShaderValues
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void bindShaderValues() {
super.bindShaderValues();
GLES20.glUniform1f(mMixHandle, mMix);
}
示例14: render
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* draws Quad shape object.
* @param aMVPMatrix
* @param texture
*/
public void render(float[] aMVPMatrix, final int texture) {
// // Use culling to remove back faces.
GLES20.glDisable(GLES20.GL_CULL_FACE);
// Set our per-vertex lighting program.
GLES20.glUseProgram(aQuadProgramHandle);
// Set program handles for cube drawing.
aMVPMatrixHandle = GLES20.glGetUniformLocation(aQuadProgramHandle, "u_MVPMatrix");
aPositionHandle = GLES20.glGetAttribLocation(aQuadProgramHandle, "a_Position");
aColorHandle = GLES20.glGetAttribLocation(aQuadProgramHandle, "a_Color");
aTextureCoordinateHandle = GLES20.glGetAttribLocation(aQuadProgramHandle, "a_TexCoordinate");
aTextureUniformHandle = GLES20.glGetUniformLocation(aQuadProgramHandle, "u_Texture");
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(aMVPMatrixHandle, 1, false, aMVPMatrix, 0);
if (qvbo[0] > 0 && qibo[0] > 0) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, qvbo[0]);
// Bind Attributes
GLES20.glVertexAttribPointer(aPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, 0);
GLES20.glEnableVertexAttribArray(aPositionHandle);
GLES20.glVertexAttribPointer(aColorHandle, COLOR_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, (POSITION_DATA_SIZE) * BYTES_PER_FLOAT);
GLES20.glEnableVertexAttribArray(aColorHandle);
GLES20.glVertexAttribPointer(aTextureCoordinateHandle, UV_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, (POSITION_DATA_SIZE + COLOR_DATA_SIZE) * BYTES_PER_FLOAT);
GLES20.glEnableVertexAttribArray(aTextureCoordinateHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);
GLES20.glUniform1f(aTextureUniformHandle, 0);
// Draw
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, qibo[0]);
GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, indexCount, GLES20.GL_UNSIGNED_SHORT, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
}
// // Use culling to remove back faces.
// GLES20.glEnable(GLES20.GL_CULL_FACE);
}
示例15: draw
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* Issues the draw call. Does the full setup on every call.
*
* @param mvpMatrix The 4x4 projection matrix.
* @param vertexBuffer Buffer with vertex position data.
* @param firstVertex Index of first vertex to use in vertexBuffer.
* @param vertexCount Number of vertices in vertexBuffer.
* @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
* @param vertexStride Width, in bytes, of the position data for each vertex (often
* vertexCount * sizeof(float)).
* @param texMatrix A 4x4 transformation matrix for texture coords. (Primarily intended
* for use with SurfaceTexture.)
* @param texBuffer Buffer with vertex texture data.
* @param texStride Width, in bytes, of the texture data for each vertex.
*/
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
int vertexCount, int coordsPerVertex, int vertexStride,
float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
GlUtil.checkGlError("draw start");
// Select the program.
GLES20.glUseProgram(mProgramHandle);
GlUtil.checkGlError("glUseProgram");
// Set the texture.
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(mTextureTarget, textureId);
// Copy the model / view / projection matrix over.
GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
GlUtil.checkGlError("glUniformMatrix4fv");
// Copy the texture transformation matrix over.
GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
GlUtil.checkGlError("glUniformMatrix4fv");
// Enable the "aPosition" vertex attribute.
GLES20.glEnableVertexAttribArray(maPositionLoc);
GlUtil.checkGlError("glEnableVertexAttribArray");
// Connect vertexBuffer to "aPosition".
GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
GlUtil.checkGlError("glVertexAttribPointer");
// Enable the "aTextureCoord" vertex attribute.
GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
GlUtil.checkGlError("glEnableVertexAttribArray");
// Connect texBuffer to "aTextureCoord".
GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
GLES20.GL_FLOAT, false, texStride, texBuffer);
GlUtil.checkGlError("glVertexAttribPointer");
// Populate the convolution kernel, if present.
if (muKernelLoc >= 0) {
GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
}
// Draw the rect.
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
GlUtil.checkGlError("glDrawArrays");
// Done -- disable vertex array, texture, and program.
GLES20.glDisableVertexAttribArray(maPositionLoc);
GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
GLES20.glBindTexture(mTextureTarget, 0);
GLES20.glUseProgram(0);
}