本文整理匯總了Java中android.opengl.GLES20.glViewport方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glViewport方法的具體用法?Java GLES20.glViewport怎麽用?Java GLES20.glViewport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glViewport方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
GLES20.glViewport(0, 0, width, height);
try {
mCamera.setPreviewTexture(mSurfaceTexture);
Camera.Parameters param = mCamera.getParameters();
param.setPreviewSize(1920, 1080);//TODO
if (param.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
param.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
mCamera.setParameters(param);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: onDraw
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void onDraw() {
//todo change blend and viewport
super.onDraw();
if(markTextureId!=-1){
GLES20.glGetIntegerv(GLES20.GL_VIEWPORT,viewPort,0);
GLES20.glViewport(markPort[0],mHeight-markPort[3]-markPort[1],markPort[2],markPort[3]);
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA,GLES20.GL_ONE_MINUS_SRC_ALPHA);
GLES20.glBlendEquation(GLES20.GL_FUNC_ADD);
mark.draw(markTextureId);
GLES20.glDisable(GLES20.GL_BLEND);
GLES20.glViewport(viewPort[0],viewPort[1],viewPort[2],viewPort[3]);
}
//todo reset blend and view port
}
示例3: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* 在surface被創建後,每次surface尺寸變化時,這個方法都會被GLSurfaceView調用到。eg.橫豎屏切換
* @param gl
* @param width
* @param height
*/
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
//設置視口大小,告訴OpenGL可以用來渲染的surface的大小
GLES20.glViewport(0,0,width,height);
//得到一個正交投影矩陣
float ratio;
if (width>height) {
ratio =(float)width / (float)height;
Matrix.orthoM(projectionMatrix, 0, -ratio, ratio, -1, 1, -1, 1);
}else {
ratio = (float)height/(float)width;
Matrix.orthoM(projectionMatrix, 0, -1, 1, -ratio, ratio, -1, 1);
}
}
示例4: drawFrame
import android.opengl.GLES20; //導入方法依賴的package包/類
protected void drawFrame() {
if (mTextureIn == 0) {
return;
}
if (mWidth != 0 && mHeight != 0) {
GLES20.glViewport(0, 0, mWidth, mHeight);
}
GLES20.glUseProgram(mProgramHandle);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glClearColor(0, 0, 0, 0);
bindShaderValues();
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
示例5: initProjectionMatrix
import android.opengl.GLES20; //導入方法依賴的package包/類
public void initProjectionMatrix(int width, int height) {
// Set the OpenGL viewport to the same size as the surface.
GLES20.glViewport(0, 0, width, height);
// Create a new perspective projection matrix.
// The height will stay the same.
// while the width will vary as per aspect ratio.
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 1.0f;
final float far = 10.0f;
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
示例6: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height)
{
// Set the OpenGL viewport to the same size as the surface.
GLES20.glViewport(0, 0, width, height);
// Create a new perspective projection matrix. The height will stay the same
// while the width will vary as per aspect ratio.
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 1.0f;
final float far = 10.0f;
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
示例7: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
GLES20.glViewport(0, 0, width, height);
mSurfaceWidth = width;
mSurfaceHeight = height;
onFilterChanged();
}
示例8: run
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void run() {
if (!initied) {
return;
}
if (!eglContext.equals(egl10.eglGetCurrentContext()) || !eglSurface.equals(egl10.eglGetCurrentSurface(EGL10.EGL_DRAW))) {
if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
FileLog.e("tmessages", "eglMakeCurrent failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
return;
}
}
GLES20.glViewport(0, 0, renderBufferWidth, renderBufferHeight);
drawEnhancePass();
drawSharpenPass();
drawCustomParamsPass();
blured = drawBlurPass();
//onscreen draw
GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
GLES20.glClear(0);
GLES20.glUseProgram(simpleShaderProgram);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[blured ? 0 : 1]);
GLES20.glUniform1i(simpleSourceImageHandle, 0);
GLES20.glEnableVertexAttribArray(simpleInputTexCoordHandle);
GLES20.glVertexAttribPointer(simpleInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(simplePositionHandle);
GLES20.glVertexAttribPointer(simplePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
egl10.eglSwapBuffers(eglDisplay, eglSurface);
}
示例9: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
public void onSurfaceChanged(GL10 gl, int width, int height) {
//設置視窗大小及位置
GLES20.glViewport(0, 0, width, height);
//計算GLSurfaceView的寬高比
Constant.ratio = (float) width / height;
// 調用此方法計算產生透視投影矩陣
MatrixState.setProjectFrustum(-Constant.ratio, Constant.ratio, -1, 1, 8, 100);
// 調用此方法產生攝像機9參數位置矩陣
MatrixState.setCamera(0, 8f, 30, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
//初始化變換矩陣
MatrixState.setInitStack();
}
示例10: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 unused, int width, int height) {
// Adjust the viewport based on geometry changes,
// such as screen rotation
GLES20.glViewport(0, 0, width, height);
_ratio = (float) width / height;
//Log.v(TAG,"SETTING RATIO "+_ratio);
// this projection matrix is applied to object coordinates
// in the onDrawFrame() method
//Matrix.frustumM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7);
Matrix.orthoM(mProjMatrix,0,-1,1,-1/_ratio,1/_ratio,-1,1);
//printMat(mProjMatrix,"ORTHO");
}
示例11: onDrawFrame
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onDrawFrame(int textureId) {
onPreDrawElements();
TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glPassThroughProgram.getTextureSamplerHandle(),0);
GLES20.glViewport(0,0,surfaceWidth,surfaceHeight);
plane.draw();
}
示例12: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
GLES20.glViewport(0, 0, width, height);
// Notify ARCore session that the view size changed so that the perspective matrix and
// the video background can be properly adjusted.
mSession.setDisplayGeometry(width, height);
}
示例13: onDrawFrame
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onDrawFrame(int textureId) {
onPreDrawElements();
setUniform1f(glSimpleProgram.getProgramId(),"texelWidthOffset",texelWidthOffset/surfaceWidth);
setUniform1f(glSimpleProgram.getProgramId(),"texelHeightOffset",texelHeightOffset/surfaceHeight);
TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0);
GLES20.glViewport(0,0,surfaceWidth,surfaceHeight);
plane.draw();
}
示例14: drawFrame
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* Draws a frame onto the SurfaceView and the encoder surface.
* <p>
* This will be called whenever we get a new preview frame from the camera. This runs
* on the UI thread, which ordinarily isn't a great idea -- you really want heavy work
* to be on a different thread -- but we're really just throwing a few things at the GPU.
* The upside is that we don't have to worry about managing state changes between threads.
* <p>
* If there was a pending frame available notification when we shut down, we might get
* here after onPause().
*/
private void drawFrame() {
//Log.d(TAG, "drawFrame");
if (mEglCore == null) {
Log.d(TAG, "Skipping drawFrame after shutdown");
return;
}
// Latch the next frame from the camera.
mDisplaySurface.makeCurrent();
mCameraTexture.updateTexImage();
mCameraTexture.getTransformMatrix(mTmpMatrix);
// Fill the SurfaceView with it.
SurfaceView sv = (SurfaceView) findViewById(R.id.continuousCapture_surfaceView);
int viewWidth = sv.getWidth();
int viewHeight = sv.getHeight();
GLES20.glViewport(0, 0, viewWidth, viewHeight);
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
drawExtra(mFrameNum, viewWidth, viewHeight);
mDisplaySurface.swapBuffers();
// Send it to the video encoder.
if (!mFileSaveInProgress) {
mEncoderSurface.makeCurrent();
GLES20.glViewport(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
drawExtra(mFrameNum, VIDEO_WIDTH, VIDEO_HEIGHT);
mCircEncoder.frameAvailableSoon();
mEncoderSurface.setPresentationTime(mCameraTexture.getTimestamp());
mEncoderSurface.swapBuffers();
}
mFrameNum++;
}
示例15: onSurfaceChanged
import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
GLES20.glViewport(0 , 0 , width , height);
Constant.ratio = (float)width / height;
//透視投影矩陣
MatrixState.setProjectFrustum(-Constant.ratio * 0.8f , Constant.ratio * 1.2f , -1 , 1 , 7 , 100);
//設置攝像機位置矩陣
MatrixState.setCamera(-16f , 8f , 45 , 0f , 0f , 0f , 0f , 1.0f , 0.0f );
//初始化矩陣堆棧
MatrixState.setInitStack();
}