Java Code Examples for android.opengl.Matrix#frustumM()
The following examples show how to use
android.opengl.Matrix#frustumM() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LessonOneRenderer.java From opengl with Apache License 2.0 | 6 votes |
@Override public void onSurfaceChanged(GL10 glUnused, int width, int height) { // Set the OpenGL viewport to the same size as the surface. GLES30.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); }
Example 2
Source File: ModelRenderer.java From react-native-3d-model-view with MIT License | 6 votes |
@Override public void onSurfaceChanged(GL10 unused, int width, int height) { this.width = width; this.height = height; // Adjust the viewport based on geometry changes, such as screen rotation GLES20.glViewport(0, 0, width, height); // INFO: Set the camera position (View matrix) // The camera has 3 vectors (the position, the vector where we are looking at, and the up position (sky) Matrix.setLookAtM(modelViewMatrix, 0, camera.xPos, camera.yPos, camera.zPos, camera.xView, camera.yView, camera.zView, camera.xUp, camera.yUp, camera.zUp); // the projection matrix is the 3D virtual space (cube) that we want to project float ratio = (float) width / height; Log.d(TAG, "projection: [" + -ratio + "," + ratio + ",-1,1]-near/far[1,10]"); Matrix.frustumM(modelProjectionMatrix, 0, -ratio, ratio, -1, 1, getNear(), getFar()); // Calculate the projection and view transformation Matrix.multiplyMM(mvpMatrix, 0, modelProjectionMatrix, 0, modelViewMatrix, 0); }
Example 3
Source File: LessonOneRenderer.java From opengl with Apache License 2.0 | 6 votes |
@Override public void onSurfaceChanged(GL10 glUnused, int width, int height) { // Set the OpenGL viewport to the same size as the surface. GLES30.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); }
Example 4
Source File: EPlayerRenderer.java From SimpleVideoEdit with Apache License 2.0 | 6 votes |
@Override public void onSurfaceChanged(final int width, final int height) { Log.d(TAG, "onSurfaceChanged width = " + width + " height = " + height); filterFramebufferObject.setup(width, height); previewFilter.setFrameSize(width, height); if (glFilter != null) { glFilter.setFrameSize(width, height); } /* * Projection and camera view in OpenGL ES 2.0: Second Step: * First Step is in GlPreviewFilter.java where we declare the vertex shader with uMVPMatrix * create a projection matrix from device screen geometry * */ aspectRatio = (float) width / height; Matrix.frustumM(ProjMatrix, 0, -aspectRatio, aspectRatio, -1, 1, 5, 7); Matrix.setIdentityM(MMatrix, 0); }
Example 5
Source File: MD360Director.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 5 votes |
protected void updateProjection(){ final float left = -mCamera.getRatio()/2; final float right = mCamera.getRatio()/2; final float bottom = -0.5f; final float top = 0.5f; final float far = 500; Matrix.frustumM(getProjectionMatrix(), 0, left, right, bottom, top, getNear(), far); }
Example 6
Source File: OpenglActivity.java From MegviiFacepp-Android-SDK with Apache License 2.0 | 5 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { // 设置画面的大小 GLES20.glViewport(0, 0, width, height); float ratio = (float) width / height; ratio = 1; // 这样OpenGL就可以按照屏幕框来画了,不是一个正方形了 // this projection matrix is applied to object coordinates // in the onDrawFrame() method Matrix.frustumM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7); // Matrix.perspectiveM(mProjMatrix, 0, 0.382f, ratio, 3, 700); }
Example 7
Source File: MyGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
@Override public void onSurfaceChanged(GL10 unused, int width, int height) { // Adjust the viewport based on geometry changes, // such as screen rotation GLES31.glViewport(0, 0, width, height); float ratio = (float) width / height; // this projection matrix is applied to object coordinates // in the onDrawFrame() method Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7); }
Example 8
Source File: GLDrawer.java From Building-Android-UIs-with-Custom-Views with MIT License | 5 votes |
@Override public void onSurfaceChanged(GL10 unused, int width, int height) { GLES20.glViewport(0, 0, width, height); float ratio = (float) width / height; Matrix.frustumM(mProjectionMatrix, 0, -ratio * 2, ratio * 2, -2, 2, 2, 7); }
Example 9
Source File: GLDrawer.java From Building-Android-UIs-with-Custom-Views with MIT License | 5 votes |
@Override public void onSurfaceChanged(GL10 unused, int width, int height) { GLES20.glViewport(0, 0, width, height); float ratio = (float) width / height; Matrix.frustumM(mProjectionMatrix, 0, -ratio * 2, ratio * 2, -2, 2, 2, 7); }
Example 10
Source File: MyGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
@Override public void onSurfaceChanged(GL10 unused, int width, int height) { // Adjust the viewport based on geometry changes, // such as screen rotation GLES32.glViewport(0, 0, width, height); float ratio = (float) width / height; // this projection matrix is applied to object coordinates // in the onDrawFrame() method Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7); }
Example 11
Source File: ParticleSystemRenderer.java From StarWars.Android with MIT License | 5 votes |
/** * */ @Override public void onSurfaceChanged(GL10 unused, int width, int height) { // Set the OpenGL viewport to the same size as the surface. GLES20.glViewport(0, 0, width, height); mWidth = width; mHeight = 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; @SuppressWarnings("UnnecessaryLocalVariable") final float right = ratio; final float bottom = -1.0f; final float top = 1.0f; final float near = 1.0f; final float far = 10.0f; this.ratio = ratio; Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far); mStartTime = System.currentTimeMillis(); mExecutor.execute(new ParticlesGenerator(this)); }
Example 12
Source File: CubeRenderer.java From PTVGlass with MIT License | 5 votes |
@Override public void onSurfaceChanged(int width, int height) { float ratio = (float) width / height; GLES20.glViewport(0, 0, width, height); // This projection matrix is applied to object coordinates in the onDrawFrame() method. Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1.0f, 1.0f, 3.0f, 7.0f); // modelView = projection x view Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0); }
Example 13
Source File: MyGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
@Override public void onSurfaceChanged(GL10 unused, int width, int height) { // Adjust the viewport based on geometry changes, // such as screen rotation GLES30.glViewport(0, 0, width, height); float ratio = (float) width / height; // this projection matrix is applied to object coordinates // in the onDrawFrame() method Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7); }
Example 14
Source File: MyGLRenderer.java From opengl with Apache License 2.0 | 5 votes |
@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); float ratio = (float) width / height; // this projection matrix is applied to object coordinates // in the onDrawFrame() method Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7); }
Example 15
Source File: MainActivity.java From Android-9-Development-Cookbook with MIT License | 5 votes |
public void onSurfaceChanged(GL10 unused, int width, int height) { GLES20.glViewport(0, 0, width, height); float ratio = (float) width / height; Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7); mCenterX=width/2; mCenterY=height/2; }
Example 16
Source File: GLES20TriangleRenderer.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void onSurfaceChanged(GL10 glUnused, int width, int height) { // Ignore the passed-in GL10 interface, and use the GLES20 // class's static methods instead. GLES20.glViewport(0, 0, width, height); float ratio = (float) width / height; Matrix.frustumM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7); }
Example 17
Source File: ShaderProgram.java From Animer with Apache License 2.0 | 5 votes |
public void setOnChange(int width, int height){ 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); }
Example 18
Source File: GameRenderer.java From media-for-mobile with Apache License 2.0 | 5 votes |
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { GLES20.glViewport(0, 0, width, height); final float ratioDisplay = (float) width / height; Matrix.frustumM(projectionMatrix, 0, -ratioDisplay, ratioDisplay, -1.0f, 1.0f, 1.0f, 10.0f); this.width = width; this.height = height; frameBuffer.setResolution(new Resolution(this.width, this.height)); videoViewport = new Rect(); videoViewport.left = 0; videoViewport.top = 0; // Landscape if (ratioDisplay > 1.0f) { videoViewport.right = videoCapture.getFrameWidth(); videoViewport.bottom = (int) (videoCapture.getFrameWidth() / ratioDisplay); } else { videoViewport.bottom = videoCapture.getFrameHeight(); videoViewport.right = (int) (videoCapture.getFrameHeight() * ratioDisplay); } videoViewport.offsetTo((videoCapture.getFrameWidth() - videoViewport.right) / 2, (videoCapture.getFrameHeight() - videoViewport.bottom) / 2); }
Example 19
Source File: GLDrawer.java From Building-Android-UIs-with-Custom-Views with MIT License | 4 votes |
private static void perspectiveFrustrum(float[] matrix, float fov, float aspect, float zNear, float zFar) { float fH = (float) (Math.tan( fov / 360.0 * Math.PI ) * zNear); float fW = fH * aspect; Matrix.frustumM(matrix, 0, -fW, fW, -fH, fH, zNear, zFar); }
Example 20
Source File: MatrixStack.java From panoramagl with Apache License 2.0 | 4 votes |
public void glFrustumf(float left, float right, float bottom, float top, float near, float far) { Matrix.frustumM(mMatrix, mTop, left, right, bottom, top, near, far); }