本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}