当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.setLookAtM方法代码示例

本文整理汇总了Java中android.opengl.Matrix.setLookAtM方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.setLookAtM方法的具体用法?Java Matrix.setLookAtM怎么用?Java Matrix.setLookAtM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.opengl.Matrix的用法示例。


在下文中一共展示了Matrix.setLookAtM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDrawFrame

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
    angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
    GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    if (scene != null) {
        Matrix.setLookAtM(mViewMatrix, 0,
                0, 0, -4,
                0f, 0f, 0f,
                0f, 1.0f, 0.0f);

        Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
        Matrix.rotateM(mMVPMatrix, 0, angle, 0.8f, 2.f, 1.f);

        GLES20.glUseProgram(shaderProgram);

        int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");
        GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);

        scene.render(shaderProgram, "vPosition", "aColor");
    }
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:24,代码来源:GLDrawer.java

示例2: gluLookAt

import android.opengl.Matrix; //导入方法依赖的package包/类
public static void gluLookAt(float[] m,
                             float eyeX,float eyeY,float eyeZ,
                             float focusX,float focusY,float focusZ,
                             float upX,float upY,float upZ) {
    float[] lookAtM=new float[16];
    float[] resultM=new float[16];
    Matrix.setLookAtM(lookAtM,0,
            eyeX,eyeY,eyeZ,focusX,focusY,focusZ,upX,upY,upZ);
    Matrix.multiplyMM(resultM,0,m,0,lookAtM,0);
    System.arraycopy(resultM,0,m,0,16);
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:12,代码来源:GLES.java

示例3: initViewMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
private void initViewMatrix() {
    // Position the eye in front of the origin
    final float eyeX = 0.0f;
    final float eyeY = 0.0f;
    final float eyeZ = 0f;

    // We are looking toward the distance.
    final float lookX = 0.0f;
    final float lookY = 0.0f;
    final float lookZ = -5.0f;

    // Set our up vector.
    // This is where our head would be pointing
    // were we holding the camera.
    final float upX = 0.0f;
    final float upY = 1.0f;
    final float upZ = 0.0f;

    // Set the view matrix.
    // This matrix can be said to represent the camera position,
    Matrix.setLookAtM(mViewMatrix, 0,
            eyeX, eyeY, eyeZ,
            lookX, lookY, lookZ,
            upX, upY, upZ);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:26,代码来源:Cube.java

示例4: setupLeftEye

import android.opengl.Matrix; //导入方法依赖的package包/类
private void setupLeftEye() {
    Matrix.setLookAtM(mCamera, 0, mLeftEyePos[0], mLeftEyePos[1], mLeftEyePos[2], 0.0f, 0.0f, -SCREEN_FAR, 0.0f, 1.0f, 0.0f);
    if (HEAD_TRACKING) Matrix.rotateM(mCamera, 0, (float)mOrientation*90.0f, 0.0f, 0.0f, -1.0f);
    Matrix.multiplyMM(mMVP, 0, mCamera, 0, mHeadTransform, 0);
    Matrix.multiplyMM(mMVP, 0, mPersp, 0, mMVP, 0);

    GLES20.glDisable(GLES20.GL_BLEND);
    
    if (getEffectMode() == VideoEffect.ANAGLYPH_MODE) {
        mColorFilter = CYAN_COLOR_FILTER;
    }

    GLES20.glScissor(0, 0, mViewWidth / 2, mViewHeight);
    GLES20.glViewport(0, 0, mViewWidth / 2, mViewHeight);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");

    GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
            false, 0, mVideoTextureCoordLeft);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:21,代码来源:StereoDiveEffect.java

示例5: 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

示例6: onDrawFrame

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 glUnused) {
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
    // Set the camera position (View matrix)
    Matrix.setLookAtM(viewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
    for(int i = 0 ; i < views.size(); i++){
        views.get(i).bindData(graphProgram, projectionMatrix, viewMatrix);
        views.get(i).draw(graphProgram);
    }
}
 
开发者ID:khoatd92,项目名称:sensor-graph-opengl-es-android,代码行数:11,代码来源:GraphRenderer.java

示例7: onDrawFrame

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
    float[] scratch = new float[16];

    // Draw background color
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    // Set the camera position (View matrix)
    Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

    // Calculate the projection and view transformation
    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);

    // Draw square
    mSquare.draw(mMVPMatrix);

    // Create a rotation for the triangle

    // Use the following code to generate constant rotation.
    // Leave this code out when using TouchEvents.
    // long time = SystemClock.uptimeMillis() % 4000L;
    // float angle = 0.090f * ((int) time);

    Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, 1.0f);

    // Combine the rotation matrix with the projection and camera view
    // Note that the mMVPMatrix factor *must be first* in order
    // for the matrix multiplication product to be correct.
    Matrix.multiplyMM(scratch, 0, mMVPMatrix, 0, mRotationMatrix, 0);

    // Draw triangle
    mTriangle.draw(scratch);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:34,代码来源:MyGLRenderer.java

示例8: onSurfaceCreated

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    heightMap = new HeightMap();

    // Set the background clear color to black.
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // Enable depth testing
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    // Position the eye in front of the origin.
    final float eyeX = 0.0f;
    final float eyeY = 0.0f;
    final float eyeZ = -0.5f;

    // We are looking toward the distance
    final float lookX = 0.0f;
    final float lookY = 0.0f;
    final float lookZ = -5.0f;

    // Set our up vector. This is where our head would be pointing were we
    // holding the camera.
    final float upX = 0.0f;
    final float upY = 1.0f;
    final float upZ = 0.0f;

    // Set the view matrix. This matrix can be said to represent the camera
    // position.
    // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination
    // of a model and view matrix. In OpenGL 2, we can keep track of these
    // matrices separately if we choose.
    Matrix.setLookAtM(viewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);

    final String vertexShader = RawResourceReader.readTextFileFromRawResource(lessonEightActivity,
            R.raw.per_pixel_vertex_shader_no_tex);
    final String fragmentShader = RawResourceReader.readTextFileFromRawResource(lessonEightActivity,
            R.raw.per_pixel_fragment_shader_no_tex);

    final int vertexShaderHandle = Utils.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    final int fragmentShaderHandle = Utils.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);

    program = Utils.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, new String[]{
            POSITION_ATTRIBUTE, NORMAL_ATTRIBUTE, COLOR_ATTRIBUTE});

    // Initialize the accumulated rotation matrix
    Matrix.setIdentityM(accumulatedRotation, 0);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:48,代码来源:LessonEightRenderer.java

示例9: onDrawFrame

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
    public void onDrawFrame(GL10 gl) {

        float[] scratch = new float[16];

        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

        Matrix.setLookAtM(viewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

        Matrix.multiplyMM(mVPMatrix, 0, projectionMatrix, 0, viewMatrix, 0);

//        long time = SystemClock.uptimeMillis() % 4000L;
//        float angle = 0.090f * ((int) time);
//        Log.e("angle", "angle=" + angle);
        Matrix.setRotateM(RotationMatrix, 0, angle, 0, 0, -1.0f);

        Matrix.multiplyMM(scratch, 0, mVPMatrix, 0, RotationMatrix, 0);

        triangle.draw(scratch);
    }
 
开发者ID:FreeSunny,项目名称:Amazing,代码行数:21,代码来源:MyRender.java

示例10: onSurfaceCreated

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
{
	// Set the background clear color to black.
	GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	
	// Use culling to remove back faces.
	GLES20.glEnable(GLES20.GL_CULL_FACE);
	
	// Enable depth testing
	GLES20.glEnable(GLES20.GL_DEPTH_TEST);
	
	// The below glEnable() call is a holdover from OpenGL ES 1, and is not needed in OpenGL ES 2.
	// Enable texture mapping
	// GLES20.glEnable(GLES20.GL_TEXTURE_2D);
		
	// Position the eye in front of the origin.
	final float eyeX = 0.0f;
	final float eyeY = 0.0f;
	final float eyeZ = -0.5f;

	// We are looking toward the distance
	final float lookX = 0.0f;
	final float lookY = 0.0f;
	final float lookZ = -5.0f;

	// Set our up vector. This is where our head would be pointing were we holding the camera.
	final float upX = 0.0f;
	final float upY = 1.0f;
	final float upZ = 0.0f;

	// Set the view matrix. This matrix can be said to represent the camera position.
	// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
	// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
	Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);		

	final String vertexShader = getVertexShader();   		
		final String fragmentShader = getFragmentShader();			
	
	final int vertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);		
	final int fragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);		
	
	mProgramHandle = ShaderHelper.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, 
			new String[] {"a_Position",  "a_Color", "a_Normal", "a_TexCoordinate"});								                                							       
       
       // Define a simple shader program for our point.
       final String pointVertexShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.point_vertex_shader);        	       
       final String pointFragmentShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.point_fragment_shader);
       
       final int pointVertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader);
       final int pointFragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader);
       mPointProgramHandle = ShaderHelper.createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle, 
       		new String[] {"a_Position"}); 
       
       // Load the texture
       mTextureDataHandle = TextureHelper.loadTexture(mActivityContext, R.drawable.bumpy_bricks_public_domain);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:58,代码来源:LessonFourRenderer.java

示例11: onDrawFrame

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
    angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
    GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    Matrix.setLookAtM(mViewMatrix, 0,
            0, 0, -4,
            0f, 0f, 0f,
            0f, 1.0f, 0.0f);

    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
    Matrix.rotateM(mMVPMatrix, 0, angle, 1.f, 1.f, 1.f);

    GLES20.glUseProgram(shaderProgram);

    int positionHandle = GLES20.glGetAttribLocation(shaderProgram, "vPosition");

    GLES20.glVertexAttribPointer(positionHandle, 3,
            GLES20.GL_FLOAT, false,
            3 * 4, vertexBuffer);

    int colorHandle = GLES20.glGetAttribLocation(shaderProgram, "aColor");
    GLES20.glVertexAttribPointer(colorHandle, 4,
            GLES20.GL_FLOAT, false,
            4 * 4, colorBuffer);

    int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");

    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);

    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glEnableVertexAttribArray(colorHandle);
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glDrawElements(
            GLES20.GL_TRIANGLES, index.length,
            GLES20.GL_UNSIGNED_SHORT, indexBuffer);

    GLES20.glDisableVertexAttribArray(positionHandle);
    GLES20.glDisableVertexAttribArray(colorHandle);
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:43,代码来源:GLDrawer.java

示例12: onDrawFrame

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
    angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
    GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    Matrix.setLookAtM(mViewMatrix, 0,
            0, 0, -4,
            0f, 0f, 0f,
            0f, 1.0f, 0.0f);

    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
    Matrix.rotateM(mMVPMatrix, 0, angle, 1.f, 1.f, 1.f);

    GLES20.glUseProgram(shaderProgram);

    int positionHandle = GLES20.glGetAttribLocation(shaderProgram, "vPosition");

    GLES20.glVertexAttribPointer(positionHandle, 3,
            GLES20.GL_FLOAT, false,
            0, vertexBuffer);

    int texCoordHandle = GLES20.glGetAttribLocation(shaderProgram, "aTex");
    GLES20.glVertexAttribPointer(texCoordHandle, 2,
            GLES20.GL_FLOAT, false,
            0, texBuffer);

    int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");

    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);

    int texHandle = GLES20.glGetUniformLocation(shaderProgram, "sTex");
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
    GLES20.glUniform1i(texHandle, 0);

    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glEnableVertexAttribArray(texHandle);
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glDrawElements(
            GLES20.GL_TRIANGLES, index.length,
            GLES20.GL_UNSIGNED_SHORT, indexBuffer);

    GLES20.glDisableVertexAttribArray(positionHandle);
    GLES20.glDisableVertexAttribArray(texHandle);
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:48,代码来源:GLDrawer.java

示例13: onSurfaceCreated

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    // Set the background clear color to black
    GLES20.glClearColor(0.0f, 0f, 0f, 0f);

    // Use culling to remove back faces
    GLES20.glEnable(GLES20.GL_CULL_FACE);

    // Enable depth testing
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    // Position the eye in front of the origin.
    final float eyeX = 0.0f;
    final float eyeY = 0.0f;
    final float eyeZ = -0.5f;

    // We are looking toward the distance
    final float lookX = 0.0f;
    final float lookY = 0.0f;
    final float lookZ = -5.0f;

    // Set our up vector. This is where our head would be pointing were we holding the camera.
    final float upX = 0.0f;
    final float upY = 1.0f;
    final float upZ = 0.0f;

    // Set the view matrix. This matrix can be said to represent the camera position.
    // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
    // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
    Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);

    final String vertexShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.per_pixel_vertex_shader_tex_and_light);
    final String fragmentShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.per_pixel_fragment_shader_tex_and_light);

    final int vertexShaderHandle = Utils.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    final int fragmentShaderHandle = Utils.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);

    mProgramHandle = Utils.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle,
            new String[]{"a_Position", "a_Normal", "a_TexCoordinate"});

    // Define a simple shader program for our point.
    final String pointVertexShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.point_vertex_shader);
    final String pointFragmentShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.point_fragment_shader);

    final int pointVertexShaderHandle = Utils.compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader);
    final int pointFragmentShaderHandle = Utils.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader);
    mPointProgramHandle = Utils.createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle,
            new String[]{"a_Position"});

    // Load the texture
    mBrickDataHandle = Utils.loadTexture(mActivity, R.drawable.stone_wall_public_domain);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    mGrassDataHandle = Utils.loadTexture(mActivity, R.drawable.noisy_grass_public_domain);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    if (mQueuedMinFilter != 0) {
        setMinFilter(mQueuedMinFilter);
    }

    if (mQueuedMagFilter != 0) {
        setMagFilter(mQueuedMagFilter);
    }

    // Initialize the accumulated rotation matrix
    Matrix.setIdentityM(mAccumulatedRotation, 0);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:68,代码来源:LessonSixRenderer.java

示例14: onSurfaceCreated

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
	// Set the background clear color to black.
	GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	// Use culling to remove back faces.
	GLES20.glEnable(GLES20.GL_CULL_FACE);

	// Enable depth testing
	GLES20.glEnable(GLES20.GL_DEPTH_TEST);

	// The below glEnable() call is a holdover from OpenGL ES 1, and is not
	// needed in OpenGL ES 2.
	// Enable texture mapping
	// GLES20.glEnable(GLES20.GL_TEXTURE_2D);

	// Position the eye in front of the origin.
	final float eyeX = 0.0f;
	final float eyeY = 0.0f;
	final float eyeZ = -0.5f;

	// We are looking toward the distance
	final float lookX = 0.0f;
	final float lookY = 0.0f;
	final float lookZ = -5.0f;

	// Set our up vector. This is where our head would be pointing were we
	// holding the camera.
	final float upX = 0.0f;
	final float upY = 1.0f;
	final float upZ = 0.0f;

	// Set the view matrix. This matrix can be said to represent the camera
	// position.
	// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination
	// of a model and
	// view matrix. In OpenGL 2, we can keep track of these matrices
	// separately if we choose.
	Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY,
			lookZ, upX, upY, upZ);
	
	// Load the texture
	mTextureDataHandle0 = TextureHelper.loadTexture(mActivityContext,
			R.drawable.starry);

}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:47,代码来源:GLLayer.java

示例15: onSurfaceCreated

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
{
	// Set the background clear color to black.
	GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	// Use culling to remove back faces.
	GLES20.glEnable(GLES20.GL_CULL_FACE);

	// Enable depth testing
	GLES20.glEnable(GLES20.GL_DEPTH_TEST);

	// Position the eye in front of the origin.
	final float eyeX = 0.0f;
	final float eyeY = 0.0f;
	final float eyeZ = -0.5f;

	// We are looking toward the distance
	final float lookX = 0.0f;
	final float lookY = 0.0f;
	final float lookZ = -5.0f;

	// Set our up vector. This is where our head would be pointing were we holding the camera.
	final float upX = 0.0f;
	final float upY = 1.0f;
	final float upZ = 0.0f;

	// Set the view matrix. This matrix can be said to represent the camera position.
	// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
	// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
	Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);

	final String vertexShader = getVertexShader();
		final String fragmentShader = getFragmentShader();

	final int vertexShaderHandle = compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
	final int fragmentShaderHandle = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);

	mPerVertexProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle,
			new String[] {"a_Position",  "a_Color", "a_Normal"});

       // Define a simple shader program for our point.
       final String pointVertexShader =
       	"uniform mat4 u_MVPMatrix;      \n"
         +	"attribute vec4 a_Position;     \n"
         + "void main()                    \n"
         + "{                              \n"
         + "   gl_Position = u_MVPMatrix   \n"
         + "               * a_Position;   \n"
         + "   gl_PointSize = 5.0;         \n"
         + "}                              \n";

       final String pointFragmentShader =
       	"precision mediump float;       \n"
         + "void main()                    \n"
         + "{                              \n"
         + "   gl_FragColor = vec4(1.0,    \n"
         + "   1.0, 1.0, 1.0);             \n"
         + "}                              \n";

       final int pointVertexShaderHandle = compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader);
       final int pointFragmentShaderHandle = compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader);
       mPointProgramHandle = createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle,
       		new String[] {"a_Position"});
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:66,代码来源:LessonTwoRenderer.java


注:本文中的android.opengl.Matrix.setLookAtM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。