Advertisement
Guest User

Untitled

a guest
Nov 26th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package com.example.dipl_stickman_dirt_jumping;
  2.  
  3. import javax.microedition.khronos.egl.EGLConfig;
  4. import javax.microedition.khronos.opengles.GL10;
  5.  
  6. import android.opengl.GLU;
  7. import android.opengl.GLSurfaceView.Renderer;
  8.  
  9. public class OpenGLRenderer implements Renderer{
  10.        
  11.     private Mesh root;
  12.    
  13.     public OpenGLRenderer()
  14.     {  
  15.         Group group = new Group();
  16.         Stickman stickman = new Stickman(0.1f,0.1f,0);
  17.         Stickman stickman2 = new Stickman(0.2f,0.3f,0);
  18.        
  19.         stickman.x = 0.3f;
  20.         stickman.y = -0.3f;
  21.         stickman2.x = -0.3f;
  22.         stickman2.y = 0.3f;
  23.        
  24.         group.add(stickman);
  25.         group.add(stickman2);
  26.         root = group;
  27.     }
  28.  
  29.     public void onDrawFrame(GL10 gl) {
  30.         gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  31.         gl.glLoadIdentity();
  32.        
  33.         gl.glTranslatef(0, 0, -4);
  34.         root.draw(gl);
  35.     }
  36.  
  37.     public void onSurfaceChanged(GL10 gl, int width, int height) {
  38.         gl.glViewport(0, 0, width, height);
  39.         gl.glMatrixMode(GL10.GL_PROJECTION);
  40.         gl.glLoadIdentity();
  41.         GLU.gluPerspective(gl, 45.0f, (float)width/(float)height, 0.1f, 100.0f);
  42.         gl.glMatrixMode(GL10.GL_MODELVIEW);
  43.         gl.glLoadIdentity();
  44.     }
  45.  
  46.     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  47.         gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
  48.         gl.glShadeModel(GL10.GL_SMOOTH);
  49.         gl.glClearDepthf(1.0f);
  50.         gl.glEnable(GL10.GL_DEPTH_TEST);
  51.     }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement