Project

General

Profile

« Previous | Next » 

Revision 9814e53c

Added by Leszek Koltunski over 5 years ago

Progress with the 'Earth' app.

View differences:

src/main/java/org/distorted/examples/earth/EarthRenderer.java
19 19

  
20 20
package org.distorted.examples.earth;
21 21

  
22
import android.graphics.Bitmap;
23
import android.graphics.BitmapFactory;
22 24
import android.opengl.GLSurfaceView;
23 25

  
26
import org.distorted.examples.R;
24 27
import org.distorted.library.effect.MatrixEffectMove;
25 28
import org.distorted.library.effect.MatrixEffectQuaternion;
26 29
import org.distorted.library.effect.MatrixEffectScale;
......
33 36
import org.distorted.library.type.Static3D;
34 37
import org.distorted.library.type.Static4D;
35 38

  
39
import java.io.IOException;
40
import java.io.InputStream;
41

  
36 42
import javax.microedition.khronos.egl.EGLConfig;
37 43
import javax.microedition.khronos.opengles.GL10;
38 44

  
......
64 70
      mScale= new Static3D(1,1,1);
65 71
      mCenter=new Static3D(0,0,0);
66 72

  
67
      EarthActivity2 act = (EarthActivity2)v.getContext();
73
      EarthActivity act = (EarthActivity)v.getContext();
68 74

  
69 75
      mTexture = act.getTexture();
70 76
      mMesh    = act.getMesh();
......
89 95
      mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) );
90 96

  
91 97
      mScreen = new DistortedScreen();
92
      mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f);
93 98
      mScreen.setProjection(FOV, NEAR);
94 99
      }
95 100

  
......
116 121

  
117 122
///////////////////////////////////////////////////////////////////////////////////////////////////
118 123

  
119
    float setLevel(int level)
124
    void setLevel(int level)
120 125
      {
121 126
      float inflateLevel = (level-50)/50.0f;
122 127
      mMesh.setInflate(inflateLevel);
123

  
124
      return inflateLevel;
125 128
      }
126 129

  
127 130
///////////////////////////////////////////////////////////////////////////////////////////////////
128 131
    
129 132
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
130 133
      {
131
      EarthActivity2 act = (EarthActivity2)mView.getContext();
134
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.world);
135
      Bitmap bitmap;
136

  
137
      try
138
        {
139
        bitmap = BitmapFactory.decodeStream(is);
140
        }
141
      finally
142
        {
143
        try
144
          {
145
          is.close();
146
          }
147
        catch(IOException e) { }
148
        }
132 149

  
133
      mTexture.setTexture( act.getBitmap() );
150
      mTexture.setTexture(bitmap);
134 151

  
135 152
      mScreen.detachAll();
136 153
      mScreen.attach(mTexture,mEffects,mMesh);

Also available in: Unified diff