Android Open Source - splott Render






From Project

Back to project page splott.

License

The source code is released under:

MIT License

If you think the Android project splott 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.wordsaretoys.splott.plotter;
/*w w w .  j a v  a 2 s. c o m*/
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.opengl.GLES20;
import android.opengl.GLSurfaceView;

import com.wordsaretoys.rise.geometry.Camera;
import com.wordsaretoys.rise.geometry.Vector;
import com.wordsaretoys.rise.utility.Interval;

/**
 * rendering object for gl surface
 * provides timer, gl & worker thread, and camera/motion state 
 */
public class Render implements GLSurfaceView.Renderer {

  // surface model object
  // made static for cheap access from activity
  public static Surface surface;
  
  // player eye-line camera
  public Camera camera;
  
  // looking state
  Vector looking = new Vector();

  // timer interval
  Interval interval = new Interval();
  
  // movement handling vectors
  Vector direction = new Vector();
  Vector velocity = new Vector();

  // gl view parent
  GlView parent;

  /**
   * ctor
   */
  public Render(GlView p) {
    camera = new Camera(30, 0.01f, 100);
    parent = p;
  }
  
  @Override
  public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glClearDepthf(1.0f);
    GLES20.glDepthFunc(GLES20.GL_LEQUAL);
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glClearColor(1f, 0.8f, 0.8f, 1);
    GLES20.glDisable(GLES20.GL_BLEND);
    GLES20.glDisable(GLES20.GL_CULL_FACE);
    
    surface = new Surface(parent);
  }

  @Override
  public void onSurfaceChanged(GL10 gl, int width, int height) {
    camera.size(width, height);
  }

  @Override
  public void onDrawFrame(GL10 gl) {
    updateCamera();
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    surface.draw(camera);
  }
  
  public void setLook(float dx, float dy) {
    looking.set(-0.5f * dy, -0.5f * dx, 0);
  }
  
  public void updateCamera() {
    float dt = interval.next();
    // rotate camera
    camera.turn(0.25f * looking.x * dt, 0.25f * looking.y * dt, 0);
    looking.mul(0.9f);
  }
}




Java Source Code List

com.wordsaretoys.rise.geometry.Camera.java
com.wordsaretoys.rise.geometry.Geom.java
com.wordsaretoys.rise.geometry.Mote.java
com.wordsaretoys.rise.geometry.Ortho.java
com.wordsaretoys.rise.geometry.Quaternion.java
com.wordsaretoys.rise.geometry.Vector.java
com.wordsaretoys.rise.glwrapper.Mesh.java
com.wordsaretoys.rise.glwrapper.Shader.java
com.wordsaretoys.rise.glwrapper.Texture.java
com.wordsaretoys.rise.meshutil.HeightMapper.java
com.wordsaretoys.rise.meshutil.IndexBuffer.java
com.wordsaretoys.rise.meshutil.SurfaceMapper.java
com.wordsaretoys.rise.meshutil.VertexBuffer.java
com.wordsaretoys.rise.meshutil.Vindexer.java
com.wordsaretoys.rise.pattern.Bitmap.java
com.wordsaretoys.rise.pattern.F2FSumMap.java
com.wordsaretoys.rise.pattern.I2FCutMap.java
com.wordsaretoys.rise.pattern.I2FMap.java
com.wordsaretoys.rise.pattern.I2IMap.java
com.wordsaretoys.rise.pattern.Pattern.java
com.wordsaretoys.rise.pattern.Ring.java
com.wordsaretoys.rise.utility.Asset.java
com.wordsaretoys.rise.utility.Board.java
com.wordsaretoys.rise.utility.Dbg.java
com.wordsaretoys.rise.utility.Interval.java
com.wordsaretoys.rise.utility.Misc.java
com.wordsaretoys.rise.utility.Needle.java
com.wordsaretoys.splott.MainActivity.java
com.wordsaretoys.splott.parser.Compiler.java
com.wordsaretoys.splott.parser.SurfaceBaseListener.java
com.wordsaretoys.splott.parser.SurfaceLexer.java
com.wordsaretoys.splott.parser.SurfaceListener.java
com.wordsaretoys.splott.parser.SurfaceParser.java
com.wordsaretoys.splott.parser.SyntaxChecker.java
com.wordsaretoys.splott.parser.Vm.java
com.wordsaretoys.splott.plotter.GlView.java
com.wordsaretoys.splott.plotter.Render.java
com.wordsaretoys.splott.plotter.Surface.java