本文整理汇总了Java中android.opengl.Matrix.scaleM方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.scaleM方法的具体用法?Java Matrix.scaleM怎么用?Java Matrix.scaleM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.Matrix
的用法示例。
在下文中一共展示了Matrix.scaleM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recomputeMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
/**
* Re-computes mModelViewMatrix, based on the current values for rotation, scale, and
* translation.
*/
private void recomputeMatrix() {
float[] modelView = mModelViewMatrix;
Matrix.setIdentityM(modelView, 0);
Matrix.translateM(modelView, 0, mPosX, mPosY, 0.0f);
if (mAngle != 0.0f) {
Matrix.rotateM(modelView, 0, mAngle, 0.0f, 0.0f, 1.0f);
}
Matrix.scaleM(modelView, 0, mScaleX, mScaleY, 1.0f);
mMatrixReady = true;
}
示例2: getLayoutMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
/**
* Returns layout transformation matrix that applies an optional mirror effect and compensates
* for video vs display aspect ratio.
*/
public static float[] getLayoutMatrix(
boolean mirror, float videoAspectRatio, float displayAspectRatio) {
float scaleX = 1;
float scaleY = 1;
// Scale X or Y dimension so that video and display size have same aspect ratio.
if (displayAspectRatio > videoAspectRatio) {
scaleY = videoAspectRatio / displayAspectRatio;
} else {
scaleX = displayAspectRatio / videoAspectRatio;
}
// Apply optional horizontal flip.
if (mirror) {
scaleX *= -1;
}
final float matrix[] = new float[16];
Matrix.setIdentityM(matrix, 0);
Matrix.scaleM(matrix, 0, scaleX, scaleY, 1);
adjustOrigin(matrix);
return matrix;
}
示例3: _drawBox
import android.opengl.Matrix; //导入方法依赖的package包/类
private void _drawBox(float x, float y, float sx, float sy, float r, float g, float b, float a, int tex){
// scale and translate
float[] m = new float[16];
Matrix.setIdentityM(m, 0);
Matrix.scaleM(m, 0, 2.0f*sx, 2.0f*sy, 1.0f);
m[3] += (1.0-2.0*x);
m[7] += (1.0/_ratio-2.0*y);
//Log.v(TAG,"RATIO IS "+_ratio);
float[] m2 = new float[16];
Matrix.multiplyMM(m2, 0, m, 0, mMVPMatrix, 0);
if (tex == -1)
mSquare.draw(m2, r, g, b, a);
else
mSquareTex.draw(m2,r,g,b,a,tex);
checkGlError("draw");
}
示例4: getLayoutMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
/**
* Returns layout transformation matrix that applies an optional mirror effect and compensates
* for video vs display aspect ratio.
*/
public static void getLayoutMatrix(
final float matrix[], boolean mirror, float videoAspectRatio, float displayAspectRatio) {
float scaleX = 1;
float scaleY = 1;
// Scale X or Y dimension so that video and display size have same aspect ratio.
if (displayAspectRatio > videoAspectRatio) {
scaleY = videoAspectRatio / displayAspectRatio;
} else {
scaleX = displayAspectRatio / videoAspectRatio;
}
// Apply optional horizontal flip.
if (mirror) {
scaleX *= -1;
}
Matrix.setIdentityM(matrix, 0);
Matrix.scaleM(matrix, 0, scaleX, scaleY, 1);
adjustOrigin(matrix);
}
示例5: 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);
}
示例6: setMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
private void setMatrix(ShaderParameter[] params, float x, float y, float width, float height) {
Matrix.translateM(mTempMatrix, 0, mMatrices, mCurrentMatrixIndex, x, y, 0f);
Matrix.scaleM(mTempMatrix, 0, width, height, 1f);
Matrix.multiplyMM(mTempMatrix, MATRIX_SIZE, mProjectionMatrix, 0, mTempMatrix, 0);
GLES20.glUniformMatrix4fv(params[INDEX_MATRIX].handle, 1, false, mTempMatrix, MATRIX_SIZE);
checkError();
}
示例7: updateViewPort
import android.opengl.Matrix; //导入方法依赖的package包/类
public void updateViewPort() {
final CameraView cameraView = mCameraViewRef.get();
if (cameraView != null) {
final int viewWidth = cameraView.getWidth();
final int viewHeight = cameraView.getHeight();
final int previewWidth = cameraView.mPreviewWidth;
final int previewHeight = cameraView.mPreviewHeight;
//CenterCrop
float scaleX = 1.0f;
float scaleY = 1.0f;
final double previewRatio = previewWidth * 1.0f / previewHeight;
final double viewRatio = viewWidth * 1.0f / viewHeight;
if (previewRatio < viewRatio) {
scaleY = (float) (previewHeight * 1.0f / (previewWidth / viewRatio));
} else {
scaleX = (float) (previewWidth * 1.0f / (previewHeight * viewRatio));
}
Log.d(TAG, "scaleX:" + scaleX + ",scaleY:" + scaleY + ",previewRatio:" + previewRatio + ",viewRatio:" + viewRatio);
Matrix.setIdentityM(mMvpMatrix, 0);
Matrix.scaleM(mMvpMatrix, 0, scaleX, scaleY, 1.0f);
if (cameraView.mGLSurfaceFilter != null) {
cameraView.mGLSurfaceFilter.setMvpMatrix(mMvpMatrix);
}
}
}
示例8: _drawBG
import android.opengl.Matrix; //导入方法依赖的package包/类
private void _drawBG(float r, float g, float b, float a, int tex){
float[] m = new float[16];
Matrix.setIdentityM(m, 0);
Matrix.scaleM(m, 0, -2.0f, 2.0f, 1.0f);
//float[] m2 = new float[16];
//Matrix.multiplyMM(m, 0, m, 0, mMVPMatrix, 0);
if (tex == -1)
mSquare.draw(m, r, g, b, a);
else
mSquareTex.draw(m,r,g,b,a,_bgTex);
checkGlError("draw");
}
示例9: getScaleMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
/**
* Gets the matrix that will be used to scale this 3DString
* @return float[] object
*/
public float[] getScaleMatrix() {
Matrix.setIdentityM(this.scaleMatrix, 0);
Matrix.scaleM(this.scaleMatrix, 0, this.getScaleX(), this.getScaleY(), this.getScaleZ());
return this.scaleMatrix;
}
示例10: getScaleMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
/**
* Gets the matrix that will be used to scale this 3D char
* @return float[] object
*/
public float[] getScaleMatrix() {
Matrix.setIdentityM(scaleMatrix, 0);
Matrix.scaleM(
scaleMatrix,
0,
(this.bitmapChar.getWidth() * this.getScaleX()),
(this.bitmapChar.getHeight() * this.getScaleY()),
this.getScaleZ()
);
return this.scaleMatrix;
}
示例11: draw
import android.opengl.Matrix; //导入方法依赖的package包/类
void draw() {
EGLDisplay mSavedEglDisplay = EGL14.eglGetCurrentDisplay();
EGLSurface mSavedEglDrawSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
EGLSurface mSavedEglReadSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_READ);
EGLContext mSavedEglContext = EGL14.eglGetCurrentContext();
{
AndroidUntil.checkGlError("draw_S");
if (mRecorderImpl.isFirstSetup()) {
mRecorderImpl.startSwapAsync();
mRecorderImpl.makeCurrent();
AndroidUntil.checkGlError("initGL_S");
mProgram = AndroidUntil.createProgram();
maPositionHandle = GLES20.glGetAttribLocation(mProgram, "position");
maTextCodeHandle = GLES20.glGetAttribLocation(mProgram, "inputTextureCoordinate");
muSamplerHandle = GLES20.glGetUniformLocation(mProgram, "uSampler");
muPosMtxHandle = GLES20.glGetUniformLocation(mProgram, "uPosMtx");
Matrix.scaleM(mSymmetryMtx, 0, -1, 1, 1);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glDisable(GLES20.GL_CULL_FACE);
GLES20.glDisable(GLES20.GL_BLEND);
AndroidUntil.checkGlError("initGL_E");
} else {
mRecorderImpl.makeCurrent();
}
GLES20.glViewport(0, 0, mVideoWidth, mVideoHeight);
GLES20.glClearColor(0f, 0f, 0f, 1f);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glUseProgram(mProgram);
mNormalVtxBuf.position(0);
GLES20.glVertexAttribPointer(maPositionHandle,
3, GLES20.GL_FLOAT, false, 4 * 3, mNormalVtxBuf);
GLES20.glEnableVertexAttribArray(maPositionHandle);
mCameraVertexCoordinatesBuffer.position(0);
GLES20.glVertexAttribPointer(maTextCodeHandle,
2, GLES20.GL_FLOAT, false, 4 * 2, mCameraVertexCoordinatesBuffer);
GLES20.glEnableVertexAttribArray(maTextCodeHandle);
GLES20.glUniform1i(muSamplerHandle, 0);
GLES20.glUniformMatrix4fv(muPosMtxHandle, 1, false, mNormalMtx, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFboTexId);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
mRecorderImpl.swapBuffers();
AndroidUntil.checkGlError("draw_E");
}
if (!EGL14.eglMakeCurrent(
mSavedEglDisplay,
mSavedEglDrawSurface,
mSavedEglReadSurface,
mSavedEglContext)) {
throw new RuntimeException("eglMakeCurrent failed");
}
}
示例12: flip
import android.opengl.Matrix; //导入方法依赖的package包/类
/**
* image mirror
* @param x horizontal flip
* @param y vertical flip
*/
public void flip(boolean x, boolean y) {
if (x || y) {
Matrix.scaleM(mMVPMatrix, 0, x ? -1 : 1, y ? -1 : 1, 1);
}
}
示例13: handleMessage
import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case WINDOW_MSG_CALCULATE_MVP_MATRIX:
Matrix.setIdentityM(mMVPMatrix, 0);
//平铺
float scaleX = 1.0f;
float scaleY = 1.0f;
final double previewRatio = mPreviewWidth * 1.0f / mPreviewHeight;
final double viewRatio = mWidth * 1.0f / mHeight;
if (previewRatio < viewRatio) {
scaleY = (float) (mPreviewHeight * 1.0f / (mPreviewWidth / viewRatio));
} else {
scaleX = (float) (mPreviewWidth * 1.0f / (mPreviewHeight * viewRatio));
}
Matrix.scaleM(mMVPMatrix, 0, scaleX, scaleY, 1.0f);
break;
case WINDOW_MSG_ATTACH_SURFACE:
Log.d(TAG, "WINDOW_MSG_ATTACH_SURFACE");
Surface surface = (Surface) msg.obj;
mGLSurface.createSurface(surface);
mGLSurface.makeCurrent();
break;
case WINDOW_MSG_DETACH_SURFACE:
Log.d(TAG, "WINDOW_MSG_DETACH_SURFACE");
releaseGLSurface();
break;
case WINDOW_MSG_UPDATE:
Log.d(TAG, "WINDOW_MSG_UPDATE");
if (mGLSurface == null) {
return false;
}
SurfaceTexture surfaceTexture = (SurfaceTexture) msg.obj;
int textureIndex = msg.arg1;
long presentationTime = msg.getData().getLong(UPDATE_PRESENTATION_TIME_KEY);
surfaceTexture.getTransformMatrix(mTextureTransformMatrix);
mGLSurface.makeCurrent();
mGLSurfaceFilter.draw(textureIndex, mMVPMatrix, mTextureTransformMatrix);
mGLSurface.setPresentationTime(presentationTime);
mGLSurface.swapBuffers();
final CallBack callBack = mCallBack;
if (callBack != null) {
callBack.onOffScreenWindowUpdate();
}
break;
}
return true;
}
示例14: scaleMVPMatrix
import android.opengl.Matrix; //导入方法依赖的package包/类
public void scaleMVPMatrix(float x, float y) {
Matrix.setIdentityM(IDENTITY_MATRIX, 0);
Matrix.scaleM(IDENTITY_MATRIX, 0, x, y, 1f);
}
示例15: scaleM
import android.opengl.Matrix; //导入方法依赖的package包/类
static void scaleM(float[] matrixData, float x, float y, float z) {
Matrix.scaleM(matrixData, 0, x, y, z);
}