Android Open Source - android-per-pixel-lighting-demo Main Activity






From Project

Back to project page android-per-pixel-lighting-demo.

License

The source code is released under:

Apache License

If you think the Android project android-per-pixel-lighting-demo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.pedroedrasousa.perpixellightingdemo;
//from ww w . j ava  2 s .  c  om
import com.pedroedrasousa.engine.EngineGLSurfaceView;
import com.pedroedrasousa.engine.Renderer;
import com.pedroedrasousa.perpixellightingdemo.R;

import android.util.DisplayMetrics;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Bundle;

public class MainActivity extends Activity {

  private EngineGLSurfaceView  mGLSurfaceView;
  private PerPixelLighting  mEngineRenderer;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mGLSurfaceView = (EngineGLSurfaceView)findViewById(R.id.gl_surface_view);
      
      // Check if the system supports OpenGL ES 2.0
      final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
      final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
   
      if (supportsEs2) {
      final DisplayMetrics displayMetrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
      
      mEngineRenderer = new PerPixelLighting(this, displayMetrics.density);
      
          // Request an OpenGL ES 2.0 compatible context and set the renderer
          mGLSurfaceView.setEGLContextClientVersion(2);
          mGLSurfaceView.setRenderer((Renderer)mEngineRenderer);
          mGLSurfaceView.setTouchEventHandler(mEngineRenderer);
      }
  }
  
  @Override
  public void onStart() {
    super.onStart();
  }
    
  @Override
  public void onStop() {
    super.onStop();
  }

  @Override
  protected void onResume() {

    if (mGLSurfaceView != null) {
      mGLSurfaceView.onResume();
    }
    
    if (mEngineRenderer!= null) {
      mEngineRenderer.onResume();
    }

    super.onResume();
  }

  @Override
  protected void onPause() {
    
    if (mGLSurfaceView != null) {
      mGLSurfaceView.onPause();
    }

    if (mEngineRenderer!= null) {
      mEngineRenderer.onPause();
    }
    
    super.onPause();
  }
  
  @Override
  public void onBackPressed() {
      finish();
  }
}




Java Source Code List

com.pedroedrasousa.engine.EngineGLSurfaceView.java
com.pedroedrasousa.engine.Renderer.java
com.pedroedrasousa.engine.ShaderProgram.java
com.pedroedrasousa.engine.Texture.java
com.pedroedrasousa.engine.Vec2.java
com.pedroedrasousa.engine.Vec3.java
com.pedroedrasousa.object3d.Mesh.java
com.pedroedrasousa.object3d.Model.java
com.pedroedrasousa.object3d.ObjLoader.java
com.pedroedrasousa.object3d.Triangle.java
com.pedroedrasousa.object3d.Vertex.java
com.pedroedrasousa.perpixellightingdemo.MainActivity.java
com.pedroedrasousa.perpixellightingdemo.PerPixelLighting.java