本文整理汇总了Java中android.opengl.GLES20.glGetUniformLocation方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glGetUniformLocation方法的具体用法?Java GLES20.glGetUniformLocation怎么用?Java GLES20.glGetUniformLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glGetUniformLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGl
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Initializes GL state. Call this after the EGL surface has been created and made current.
*/
public void initGl() {
GlUtil.checkGlError("initGl start");
String vertexShader = GlUtil.getStringFromRaw(context, R.raw.watermark_vertex);
String fragmentShader = GlUtil.getStringFromRaw(context, R.raw.watermark_fragment);
program = GlUtil.createProgram(vertexShader, fragmentShader);
aPositionHandle = GLES20.glGetAttribLocation(program, "aPosition");
aTextureCameraHandle = GLES20.glGetAttribLocation(program, "aTextureCameraCoord");
aTextureWatermarkHandle = GLES20.glGetAttribLocation(program, "aTextureWatermarkCoord");
uMVPMatrixHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix");
uSTMatrixHandle = GLES20.glGetUniformLocation(program, "uSTMatrix");
uAlphaHandle = GLES20.glGetUniformLocation(program, "uAlpha");
sWaterMarkHandle = GLES20.glGetUniformLocation(program, "sWatermark");
//camera texture
GlUtil.createExternalTextures(1, texturesID, 0);
textureID = texturesID[0];
surfaceTexture = new SurfaceTexture(textureID);
surface = new Surface(surfaceTexture);
GlUtil.checkGlError("initGl end");
}
示例2: getGLSLValues
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
protected void getGLSLValues() {
super.getGLSLValues();
muTexelWidthOffset = GLES20.glGetUniformLocation(mProgramHandle, "uTexelWidthOffset");
muTexelHeightOffset = GLES20.glGetUniformLocation(mProgramHandle, "uTexelHeightOffset");
}
示例3: initShader
import android.opengl.GLES20; //导入方法依赖的package包/类
private void initShader(Context context) {
mVertexShader = ShaderUtil.loadFromAssetsFile("vertex_angle.sh" , context.getResources());
mFragShader = ShaderUtil.loadFromAssetsFile("frag_angle.sh" , context.getResources());
mProgram = ShaderUtil.createProgram(mVertexShader , mFragShader);
maPositionHandle = GLES20.glGetAttribLocation(mProgram , "aPosition");
maTexCoorHandle = GLES20.glGetAttribLocation(mProgram , "aTexCoor");
muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram , "uMVPMatrix");
}
示例4: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
final public void draw(int cameraTexId, int canvasWidth, int canvasHeight) {
// TODO move?
// Create camera render buffer
if (CAMERA_RENDER_BUF == null ||
CAMERA_RENDER_BUF.getWidth() != canvasWidth ||
CAMERA_RENDER_BUF.getHeight() != canvasHeight) {
CAMERA_RENDER_BUF = new RenderBuffer(canvasWidth, canvasHeight, BUF_ACTIVE_TEX_UNIT);
}
// Use shaders
GLES20.glUseProgram(PROGRAM);
int iChannel0Location = GLES20.glGetUniformLocation(PROGRAM, "iChannel0");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTexId);
GLES20.glUniform1i(iChannel0Location, 0);
int vPositionLocation = GLES20.glGetAttribLocation(PROGRAM, "vPosition");
GLES20.glEnableVertexAttribArray(vPositionLocation);
GLES20.glVertexAttribPointer(vPositionLocation, 2, GLES20.GL_FLOAT, false, 4 * 2, VERTEX_BUF);
int vTexCoordLocation = GLES20.glGetAttribLocation(PROGRAM, "vTexCoord");
GLES20.glEnableVertexAttribArray(vTexCoordLocation);
GLES20.glVertexAttribPointer(vTexCoordLocation, 2, GLES20.GL_FLOAT, false, 4 * 2, ROATED_TEXTURE_COORD_BUF);
// Render to texture
CAMERA_RENDER_BUF.bind();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
CAMERA_RENDER_BUF.unbind();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
onDraw(CAMERA_RENDER_BUF.getTexId(), canvasWidth, canvasHeight);
iFrame++;
}
示例5: getUniformLocation
import android.opengl.GLES20; //导入方法依赖的package包/类
public int getUniformLocation(String label) {
if (program == -1) {
throw new RuntimeException("The program has been released");
}
int location = GLES20.glGetUniformLocation(program, label);
if (location < 0) {
throw new RuntimeException("Could not locate uniform '" + label + "' in program");
}
return location;
}
示例6: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onInit() {
super.onInit();
mSharpnessLocation = GLES20.glGetUniformLocation(getProgram(), "sharpness");
mImageWidthFactorLocation = GLES20.glGetUniformLocation(getProgram(), "imageWidthFactor");
mImageHeightFactorLocation = GLES20.glGetUniformLocation(getProgram(), "imageHeightFactor");
setSharpness(mSharpness);
}
示例7: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
protected void onInit(){
super.onInit();
inputTextureUniformLocations[0] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture2");
mTexelWidthUniformLocation = GLES20.glGetUniformLocation(getProgram(), "inputImageTextureWidth");
mTexelHeightUniformLocation = GLES20.glGetUniformLocation(getProgram(), "inputImageTextureHeight");
}
示例8: createOnGlThread
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Allocates and initializes OpenGL resources needed by the plane renderer. Must be
* called on the OpenGL thread, typically in
* {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}.
*
* @param context Needed to access shader source.
*/
public void createOnGlThread(Context context) {
ShaderUtil.checkGLError(TAG, "before create");
int buffers[] = new int[1];
GLES20.glGenBuffers(1, buffers, 0);
mVbo = buffers[0];
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
mVboSize = INITIAL_BUFFER_POINTS * BYTES_PER_POINT;
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mVboSize, null, GLES20.GL_DYNAMIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "buffer alloc");
int vertexShader = ShaderUtil.loadGLShader(TAG, context,
GLES20.GL_VERTEX_SHADER, R.raw.point_cloud_vertex);
int passthroughShader = ShaderUtil.loadGLShader(TAG, context,
GLES20.GL_FRAGMENT_SHADER, R.raw.passthrough_fragment);
mProgramName = GLES20.glCreateProgram();
GLES20.glAttachShader(mProgramName, vertexShader);
GLES20.glAttachShader(mProgramName, passthroughShader);
GLES20.glLinkProgram(mProgramName);
GLES20.glUseProgram(mProgramName);
ShaderUtil.checkGLError(TAG, "program");
mPositionAttribute = GLES20.glGetAttribLocation(mProgramName, "a_Position");
mColorUniform = GLES20.glGetUniformLocation(mProgramName, "u_Color");
mModelViewProjectionUniform = GLES20.glGetUniformLocation(
mProgramName, "u_ModelViewProjection");
mPointSizeUniform = GLES20.glGetUniformLocation(mProgramName, "u_PointSize");
ShaderUtil.checkGLError(TAG, "program params");
}
示例9: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
public void onInit(){
super.onInit();
mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(mGLProgId, "curve");
mMaskGrey1UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey1Frame");
mMaskGrey2UniformLocation = GLES20.glGetUniformLocation(getProgram(), "grey2Frame");
}
示例10: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onInit() {
super.onInit();
mBrightnessLocation = GLES20.glGetUniformLocation(getProgram(), "brightness");
}
示例11: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
public void onInit(){
super.onInit();
for(int i=0; i < inputTextureUniformLocations.length; i++){
inputTextureUniformLocations[i] = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture"+(2+i));
}
}
示例12: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
protected void onInit(){
super.onInit();
mLookupTextureUniform = GLES20.glGetUniformLocation(getProgram(), "inputImageTexture2");
}
示例13: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
protected void onInit() {
super.onInit();
mSingleStepOffsetLocation = GLES20.glGetUniformLocation(getProgram(), "singleStepOffset");
mStrength = GLES20.glGetUniformLocation(getProgram(), "strength");
setFloat(mStrength, 0.5f);
}
示例14: onInit
import android.opengl.GLES20; //导入方法依赖的package包/类
protected void onInit(){
super.onInit();
mToneCurveTextureUniformLocation = GLES20.glGetUniformLocation(mGLProgId, "curve");
}
示例15: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw() {
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Do a compile rotation every 10 seconds.
long time = SystemClock.uptimeMillis() % 10000L;
float angleInDegrees = (360.0f / 10000.0f) * ((int) time);
// Set our pre-vertex lighting program.
GLES20.glUseProgram(mPerVertexProgramHandle);
// Set program handle for cube drawing.
mMVPMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVPMatrix");
mMVMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVMatrix");
mLightPosHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_LightPos");
mPositionHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Position");
mColorHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Color");
mNormalHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Normal");
// Calculate position of the light.
// Rotate and then push into the distance.
Matrix.setIdentityM(mLightModelMatrix, 0);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -5.0f);
Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0F, 0.0f);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f);
Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0);
Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0);
// right
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 4.0f, 0.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f);
drawCube();
// left
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, -4.0f, 0.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
drawCube();
// top
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 4.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
drawCube();
// bottom
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, -4.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
drawCube();
// center
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 1.0f);
drawCube();
// Draw a point to indicate the light.
GLES20.glUseProgram(mPointProgramHandle);
drawLight();
}