@Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // 设置为全屏
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
   // 获得系统的宽度以及高度
   DisplayMetrics dm = new DisplayMetrics();
   getWindowManager().getDefaultDisplay().getMetrics(dm);
   if (dm.widthPixels > dm.heightPixels) {
     WIDTH = dm.widthPixels;
     HEIGHT = dm.heightPixels;
   } else {
     WIDTH = dm.heightPixels;
     HEIGHT = dm.widthPixels;
   }
   // 设置为横屏模式
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
   mview = new MySurfaceView(this);
   mview.requestFocus(); // 获取焦点
   mview.setFocusableInTouchMode(true); // 设置为可触控
   setContentView(mview);
 }
 public void initShader(MySurfaceView mv) {
   // 加载顶点着色器的脚本内容
   mVertexShader = ShaderUtil.loadFromAssetsFile("vertex_tex.sh", mv.getResources());
   // 加载片元着色器的脚本内容
   mFragmentShader = ShaderUtil.loadFromAssetsFile("frag_tex.sh", mv.getResources());
   // 基于顶点着色器与片元着色器创建程序
   mProgram = ShaderUtil.createProgram(mVertexShader, mFragmentShader);
   // 获取程序中顶点位置属性引用
   maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
   // 获取程序中顶点纹理坐标属性引用
   maTexCoorHandle = GLES20.glGetAttribLocation(mProgram, "aTexCoor");
   // 获取程序中总变换矩阵id
   muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
 }
Exemple #3
0
  // ------------------ surface relative-------------------
  void initSurfaceView() {
    mSurfaceView = (MySurfaceView) this.findViewById(R.id.surface_view);
    mSurfaceView
        .getHolder()
        .addCallback(
            new SurfaceHolder.Callback() {
              @Override
              public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
                Logger.LOGD(TAG, "Surface Change:::");
              }

              @Override
              public void surfaceCreated(SurfaceHolder holder) {
                Logger.LOGD(TAG, "surfaceCreated");
                mSurfaceView.setY(0);
                // mHolder.setFixedSize(mDm.widthPixels, mDm.heightPixels);
                mSurfaceView.getHolder().setFixedSize(mDm.widthPixels, mDm.heightPixels);
                mSurfaceView.mIsFullScreen = false;
                if (mPlayer != null) mPlayer.setDisplay(/*mHolder*/ mSurfaceView.getHolder());
              }

              @Override
              public void surfaceDestroyed(SurfaceHolder holder) {
                Logger.LOGD("Surface Destory:::", "surfaceDestroyed called");
              }
            });
  }
 public void intShader(MySurfaceView mv) { // 初始化着色器
   // 加载顶点着色器的脚本内容
   mVertexShader = ShaderUtil.loadFromAssetsFile("vertex_xk.sh", mv.getResources());
   ShaderUtil.checkGlError("==ss==");
   // 加载片元着色器的脚本内容
   mFragmentShader = ShaderUtil.loadFromAssetsFile("frag_xk.sh", mv.getResources());
   // 基于顶点着色器与片元着色器创建程序
   ShaderUtil.checkGlError("==ss==");
   mProgram = createProgram(mVertexShader, mFragmentShader);
   // 获取程序中顶点位置属性引用id
   maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
   // 获取程序中总变换矩阵引用id
   muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
   // 获取顶点尺寸参数引用
   uPointSizeHandle = GLES20.glGetUniformLocation(mProgram, "uPointSize");
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 设置为全屏
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // 设置为横屏模式
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    // 初始化GLSurfaceView
    mGLSurfaceView = new MySurfaceView(this);
    setContentView(mGLSurfaceView);
    mGLSurfaceView.requestFocus(); // 获取焦点
    mGLSurfaceView.setFocusableInTouchMode(true); // 设置为可触控
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    MV = new MySurfaceView(this);

    setContentView(MV);
    MV.requestFocus();
    MV.setFocusableInTouchMode(true);

    cameraView = new CameraView(this);
    addContentView(
        cameraView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  }
Exemple #7
0
  private void initPlayer() {
    Logger.LOGD(TAG, "begint to new InitPlayer");
    if (mPlayer != null) {
      mPlayer.release();
      mSurfaceView.setVisibility(View.INVISIBLE);
    }

    mPlayer = new MediaPlayer();
    mSurfaceView.setVisibility(View.VISIBLE);
    //		if (mHolder != null)
    //			mPlayer.setDisplay(mHolder);
    mPlayer.setOnPreparedListener(mPrepareListener);
    mPlayer.setOnCompletionListener(mCompleteListener);
    mPlayer.setOnErrorListener(mErrorListener);
    mPlayer.setOnInfoListener(mInfoListener);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mPlayer.reset();

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  }
Exemple #8
0
 // 初始化shader
 public void intShader(MySurfaceView mv) {
   // 加载顶点着色器的脚本内容
   mVertexShader = ShaderUtil.loadFromAssetsFile("vertex_color.sh", mv.getResources());
   ShaderUtil.checkGlError("==ss==");
   // 加载片元着色器的脚本内容
   mFragmentShader = ShaderUtil.loadFromAssetsFile("frag_color.sh", mv.getResources());
   // 基于顶点着色器与片元着色器创建程序
   ShaderUtil.checkGlError("==ss==");
   mProgram = ShaderUtil.createProgram(mVertexShader, mFragmentShader);
   // 获取程序中顶点位置属性引用id
   maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
   // 获取程序中总变换矩阵引用id
   muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
   muMMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMMatrix");
   // 获取程序中顶点法向量属性引用
   maNormalHandle = GLES20.glGetAttribLocation(mProgram, "aNormal");
   // 获取程序中光源位置引用
   maLightLocationHandle = GLES20.glGetUniformLocation(mProgram, "uLightLocation");
   // 获取程序中摄像机位置引用
   maCameraHandle = GLES20.glGetUniformLocation(mProgram, "uCamera");
 }
Exemple #9
0
 // 初始化着色器
 public void initShader(MySurfaceView mv) {
   // 加载顶点着色器的脚本内容
   mVertexShader = ShaderUtil.loadFromAssetsFile("vertex.sh", mv.getResources());
   // 加载片元着色器的脚本内容
   mFragmentShader = ShaderUtil.loadFromAssetsFile("frag.sh", mv.getResources());
   // 基于顶点着色器与片元着色器创建程序
   mProgram = ShaderUtil.createProgram(mVertexShader, mFragmentShader);
   // 获取程序中顶点位置属性引用
   maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
   // 获取程序中总变换矩阵引用
   muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
   // 获取程序中顶点经纬度属性引用
   maLongLatHandle = GLES20.glGetAttribLocation(mProgram, "aLongLat");
   // 获取位置、旋转变换矩阵引用
   muMMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMMatrix");
   // 获取程序中球半径引用
   muRHandle = GLES20.glGetUniformLocation(mProgram, "uR");
   // 获取程序中顶点法向量属性引用
   maNormalHandle = GLES20.glGetAttribLocation(mProgram, "aNormal");
   // 获取程序中光源位置引用
   maLightLocationHandle = GLES20.glGetUniformLocation(mProgram, "uLightLocation");
   // 获取程序中摄像机位置引用
   maCameraHandle = GLES20.glGetUniformLocation(mProgram, "uCamera");
 }
 @Override
 protected void onPause() {
   super.onPause();
   mview.onPause();
 }
 @Override
 protected void onResume() {
   super.onResume();
   mview.onResume();
 }
 @Override
 protected void onPause() {
   super.onPause();
   mGLSurfaceView.onPause();
 }
 @Override
 protected void onResume() {
   super.onResume();
   mGLSurfaceView.onResume();
 }
 @Override
 protected void onResume() {
   super.onResume();
   MV.onResume();
 }
 @Override
 protected void onPause() {
   super.onPause();
   MV.onPause();
 }