当前位置: 首页>>代码示例>>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;未经允许,请勿转载。