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


Java Matrix.orthoM方法代碼示例

本文整理匯總了Java中android.opengl.Matrix.orthoM方法的典型用法代碼示例。如果您正苦於以下問題:Java Matrix.orthoM方法的具體用法?Java Matrix.orthoM怎麽用?Java Matrix.orthoM使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.opengl.Matrix的用法示例。


在下文中一共展示了Matrix.orthoM方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSurfaceChanged

import android.opengl.Matrix; //導入方法依賴的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

示例2: setSize

import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void setSize(int width, int height) {
    GLES20.glViewport(0, 0, width, height);
    checkError();
    Matrix.setIdentityM(mMatrices, mCurrentMatrixIndex);
    Matrix.orthoM(mProjectionMatrix, 0, 0, width, 0, height, -1, 1);
    Matrix.translateM(mMatrices, mCurrentMatrixIndex, 0, height, 0);
    Matrix.scaleM(mMatrices, mCurrentMatrixIndex, 1, -1, 1);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:10,代碼來源:GLES20Canvas.java

示例3: onSurfaceChanged

import android.opengl.Matrix; //導入方法依賴的package包/類
public void onSurfaceChanged (GL10 gl, int width, int height) {
    // We need to know the current width and height
    mScreenWidth = width;
    mScreenHeight = height;

    // Redo the Viewport, making it fullscreen
    GLES20.glViewport(0, 0, (int)mScreenWidth, (int)mScreenHeight);

    // Clear our matrices
    for(int i=0;i<16;i++)
    {
        mtrxProjection[i] = 0.0f;
        mtrxView[i] = 0.0f;
        mtrxProjectionAndView[i] = 0.0f;
    }

    // Setup our screen width and height for normal sprite translation.
    Matrix.orthoM(mtrxProjection, 0, 0f, mScreenWidth, 0.0f, mScreenHeight, 0, 50);

    // Set the camera position (View matrix)
    Matrix.setLookAtM(mtrxView, 0, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

    // Calculate the projection and view transformation
    Matrix.multiplyMM(mtrxProjectionAndView, 0, mtrxProjection, 0, mtrxView, 0);

    // Without this line of code, nothing appear on the screen TODO: Why?
    // The only part of this that seems to be necessary is the instatiation of a new GameObject
    BaseObject.renderSystem.generateTextures(mContext);
}
 
開發者ID:kaidenho,項目名稱:spellcaster,代碼行數:30,代碼來源:GameRenderer.java

示例4: onSurfaceChanged

import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    mScreenWidth = width;
    mScreenHeight = height;
    spriteKit.setBoardRatio(width, height);
    GLES20.glViewport(0, 0, (int) mScreenWidth, (int) mScreenHeight);
    for (int i = 0; i < 16; i++) {
        mtrxProjection[i] = 0.0f;
        mtrxView[i] = 0.0f;
        mtrxProjectionAndView[i] = 0.0f;
    }
    Matrix.orthoM(mtrxProjection, 0, 0f, mScreenWidth, 0.0f, mScreenHeight, 0, 50);
    Matrix.setLookAtM(mtrxView, 0, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
    Matrix.multiplyMM(mtrxProjectionAndView, 0, mtrxProjection, 0, mtrxView, 0);
}
 
開發者ID:sakkeerhussain,項目名稱:SpriteKit-Android,代碼行數:16,代碼來源:SpriteKitRenderer.java

示例5: updateProjectionFit

import android.opengl.Matrix; //導入方法依賴的package包/類
public static void updateProjectionFit(int imageWidth, int imageHeight, int surfaceWidth, int surfaceHeight, float[] projectionMatrix) {
    float screenRatio=(float)surfaceWidth/surfaceHeight;
    float videoRatio=(float) imageWidth / imageHeight;
    if (videoRatio>screenRatio){
        Matrix.orthoM(projectionMatrix,0,-1f,1f,-videoRatio/screenRatio,videoRatio/screenRatio,-1f,1f);
    }else Matrix.orthoM(projectionMatrix,0,-screenRatio/videoRatio,screenRatio/videoRatio,-1f,1f,-1f,1f);
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:8,代碼來源:MatrixUtils.java

示例6: updateProjectionCrop

import android.opengl.Matrix; //導入方法依賴的package包/類
public static void updateProjectionCrop(int imageWidth, int imageHeight,int surfaceWidth,int surfaceHeight,float[] projectionMatrix) {
    float screenRatio=(float)surfaceWidth/surfaceHeight;
    float videoRatio=(float) imageWidth / imageHeight;
    //crop is just making the screen fit the image.
    //only one difference
    if (videoRatio<screenRatio){
        Matrix.orthoM(projectionMatrix,0,-1f,1f,-videoRatio/screenRatio,videoRatio/screenRatio,-1f,1f);
    }else Matrix.orthoM(projectionMatrix,0,-screenRatio/videoRatio,screenRatio/videoRatio,-1f,1f,-1f,1f);
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:10,代碼來源:MatrixUtils.java

示例7: finishSurfaceSetup

import android.opengl.Matrix; //導入方法依賴的package包/類
/**
 * Sets up anything that depends on the window size.
 * <p>
 * Open the camera (to set mCameraAspectRatio) before calling here.
 */
private void finishSurfaceSetup() {
    int width = mWindowSurfaceWidth;
    int height = mWindowSurfaceHeight;
    Log.d(TAG, "finishSurfaceSetup size=" + width + "x" + height +
            " camera=" + mCameraPreviewWidth + "x" + mCameraPreviewHeight);

    // Use full window.
    GLES20.glViewport(0, 0, width, height);

    // Simple orthographic projection, with (0,0) in lower-left corner.
    Matrix.orthoM(mDisplayProjectionMatrix, 0, 0, width, 0, height, -1, 1);

    // Default position is center of screen.
    mPosX = width / 2.0f;
    mPosY = height / 2.0f;

    updateGeometry();

    // Ready to go, start the camera.
    Log.d(TAG, "starting camera preview");
    try {
        mCamera.setPreviewTexture(mCameraTexture);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    mCamera.startPreview();
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:33,代碼來源:TextureFromCameraActivity.java

示例8: onSurfaceChanged

import android.opengl.Matrix; //導入方法依賴的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

示例9: surfaceChanged

import android.opengl.Matrix; //導入方法依賴的package包/類
/**
 * Handles changes to the size of the underlying surface.  Adjusts viewport as needed.
 * Must be called before we start drawing.
 * (Called from RenderHandler.)
 */
private void surfaceChanged(int width, int height) {
    // This method is called when the surface is first created, and shortly after the
    // call to setFixedSize().  The tricky part is that this is called when the
    // drawing surface is *about* to change size, not when it has *already* changed
    // size.  A query on the EGL surface will confirm that the surface dimensions
    // haven't yet changed.  If you re-query after the next swapBuffers() call,
    // you will see the new dimensions.
    //
    // To have a smooth transition, we should continue to draw at the old size until the
    // surface query tells us that the size of the underlying buffers has actually
    // changed.  I don't really expect a "normal" app will want to call setFixedSize()
    // dynamically though, so in practice this situation shouldn't arise, and it's
    // just not worth the hassle of doing it right.

    Log.d(TAG, "surfaceChanged " + width + "x" + height);

    // Use full window.
    GLES20.glViewport(0, 0, width, height);

    // Simple orthographic projection, with (0,0) in lower-left corner.
    Matrix.orthoM(mDisplayProjectionMatrix, 0, 0, width, 0, height, -1, 1);

    int smallDim = Math.min(width, height);

    // Set initial shape size / position / velocity based on window size.  Movement
    // has the same "feel" on all devices, but the actual path will vary depending
    // on the screen proportions.  We do it here, rather than defining fixed values
    // and tweaking the projection matrix, so that our squares are square.
    mTri.setColor(0.1f, 0.9f, 0.1f);
    mTri.setTexture(mFineTexture);
    mTri.setScale(smallDim / 3.0f, smallDim / 3.0f);
    mTri.setPosition(width / 2.0f, height / 2.0f);
    mRect.setColor(0.9f, 0.1f, 0.1f);
    mRect.setTexture(mCoarseTexture);
    mRect.setScale(smallDim / 5.0f, smallDim / 5.0f);
    mRect.setPosition(width / 2.0f, height / 2.0f);
    mRectVelX = 1 + smallDim / 4.0f;
    mRectVelY = 1 + smallDim / 5.0f;

    // left edge
    float edgeWidth = 1 + width / 64.0f;
    mEdges[0].setColor(0.5f, 0.5f, 0.5f);
    mEdges[0].setScale(edgeWidth, height);
    mEdges[0].setPosition(edgeWidth / 2.0f, height / 2.0f);
    // right edge
    mEdges[1].setColor(0.5f, 0.5f, 0.5f);
    mEdges[1].setScale(edgeWidth, height);
    mEdges[1].setPosition(width - edgeWidth / 2.0f, height / 2.0f);
    // top edge
    mEdges[2].setColor(0.5f, 0.5f, 0.5f);
    mEdges[2].setScale(width, edgeWidth);
    mEdges[2].setPosition(width / 2.0f, height - edgeWidth / 2.0f);
    // bottom edge
    mEdges[3].setColor(0.5f, 0.5f, 0.5f);
    mEdges[3].setScale(width, edgeWidth);
    mEdges[3].setPosition(width / 2.0f, edgeWidth / 2.0f);

    // Inner bounding rect, used to bounce objects off the walls.
    mInnerLeft = mInnerBottom = edgeWidth;
    mInnerRight = width - 1 - edgeWidth;
    mInnerTop = height - 1 - edgeWidth;

    Log.d(TAG, "mTri: " + mTri);
    Log.d(TAG, "mRect: " + mRect);
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:71,代碼來源:HardwareScalerActivity.java

示例10: surfaceChanged

import android.opengl.Matrix; //導入方法依賴的package包/類
/**
 * Handles changes to the size of the underlying surface.  Adjusts viewport as needed.
 * Must be called before we start drawing.
 * (Called from RenderHandler.)
 */
private void surfaceChanged(int width, int height) {
    Log.d(TAG, "surfaceChanged " + width + "x" + height);

    prepareFramebuffer(width, height);

    // Use full window.
    GLES20.glViewport(0, 0, width, height);

    // Simple orthographic projection, with (0,0) in lower-left corner.
    Matrix.orthoM(mDisplayProjectionMatrix, 0, 0, width, 0, height, -1, 1);

    int smallDim = Math.min(width, height);

    // Set initial shape size / position / velocity based on window size.  Movement
    // has the same "feel" on all devices, but the actual path will vary depending
    // on the screen proportions.  We do it here, rather than defining fixed values
    // and tweaking the projection matrix, so that our squares are square.
    mTri.setColor(0.1f, 0.9f, 0.1f);
    mTri.setScale(smallDim / 4.0f, smallDim / 4.0f);
    mTri.setPosition(width / 2.0f, height / 2.0f);
    mRect.setColor(0.9f, 0.1f, 0.1f);
    mRect.setScale(smallDim / 8.0f, smallDim / 8.0f);
    mRect.setPosition(width / 2.0f, height / 2.0f);
    mRectVelX = 1 + smallDim / 4.0f;
    mRectVelY = 1 + smallDim / 5.0f;

    // left edge
    float edgeWidth = 1 + width / 64.0f;
    mEdges[0].setScale(edgeWidth, height);
    mEdges[0].setPosition(edgeWidth / 2.0f, height / 2.0f);
    // right edge
    mEdges[1].setScale(edgeWidth, height);
    mEdges[1].setPosition(width - edgeWidth / 2.0f, height / 2.0f);
    // top edge
    mEdges[2].setScale(width, edgeWidth);
    mEdges[2].setPosition(width / 2.0f, height - edgeWidth / 2.0f);
    // bottom edge
    mEdges[3].setScale(width, edgeWidth);
    mEdges[3].setPosition(width / 2.0f, edgeWidth / 2.0f);

    mRecordRect.setColor(1.0f, 1.0f, 1.0f);
    mRecordRect.setScale(edgeWidth * 2f, edgeWidth * 2f);
    mRecordRect.setPosition(edgeWidth / 2.0f, edgeWidth / 2.0f);

    // Inner bounding rect, used to bounce objects off the walls.
    mInnerLeft = mInnerBottom = edgeWidth;
    mInnerRight = width - 1 - edgeWidth;
    mInnerTop = height - 1 - edgeWidth;

    Log.d(TAG, "mTri: " + mTri);
    Log.d(TAG, "mRect: " + mRect);
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:58,代碼來源:RecordFBOActivity.java

示例11: glOrthof

import android.opengl.Matrix; //導入方法依賴的package包/類
public void glOrthof(float left, float right, float bottom, float top,
		float near, float far) {
	Matrix.orthoM(mMatrix, mTop, left, right, bottom, top, near, far);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:5,代碼來源:MatrixStack.java

示例12: setProjectionOrtho

import android.opengl.Matrix; //導入方法依賴的package包/類
/**
 * 設置正交投影
 * @param left near麵的left
 * @param right near麵的right
 * @param bottom near麵的bottom
 * @param top   near麵的top
 * @param near near麵與視點的距離
 * @param far   far麵與視點的距離
 */
public static void setProjectionOrtho(float left , float right , float bottom , float top , float near , float far){
    Matrix.orthoM(mProjMatrix , 0 ,//起始偏移量
                  left , right , bottom , top , near , far);
}
 
開發者ID:ynztlxdeai,項目名稱:GLproject,代碼行數:14,代碼來源:MatrixState.java


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