當前位置: 首頁>>代碼示例>>Java>>正文


Java GLES20.glViewport方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:17,代碼來源:CameraRenderer.java

示例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
}
 
開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:19,代碼來源:WaterMarkFilter.java

示例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);
    }

}
 
開發者ID:YanJingW,項目名稱:OpenGL_Note,代碼行數:23,代碼來源:DemoRenderer.java

示例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);
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:17,代碼來源:AbstractRender.java

示例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);
}
 
開發者ID:biezhihua,項目名稱:Android_OpenGL_Demo,代碼行數:18,代碼來源:Cube.java

示例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);
}
 
開發者ID:biezhihua,項目名稱:Android_OpenGL_Demo,代碼行數:19,代碼來源:LessonTwoRenderer.java

示例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();
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:8,代碼來源:MagicCameraDisplay.java

示例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);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:36,代碼來源:PhotoFilterView.java

示例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();
}
 
開發者ID:ynztlxdeai,項目名稱:GLproject,代碼行數:14,代碼來源:BeltCircleSurfaceView.java

示例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");
}
 
開發者ID:efroemling,項目名稱:bombsquad-remote-android,代碼行數:15,代碼來源:GLRenderer.java

示例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();
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:8,代碼來源:OrthoFilter.java

示例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);
}
 
開發者ID:googlevr,項目名稱:poly-sample-android,代碼行數:8,代碼來源:HelloArActivity.java

示例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();
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:11,代碼來源:GaussianBlurFilter.java

示例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++;
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:46,代碼來源:ContinuousCaptureActivity.java

示例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();
}
 
開發者ID:ynztlxdeai,項目名稱:GLproject,代碼行數:12,代碼來源:ScaleSurfaceView.java


注:本文中的android.opengl.GLES20.glViewport方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。