Project

General

Profile

« Previous | Next » 

Revision dc10a48d

Added by Leszek Koltunski about 1 year ago

Decouple (to a large degree) the OpenGL Library from Android.

View differences:

src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java
46 46
import org.distorted.library.type.Static3D;
47 47
import org.distorted.library.type.Static4D;
48 48

  
49
import android.app.ActivityManager;
50
import android.content.Context;
51
import android.content.pm.ConfigurationInfo;
49 52
import android.content.res.Resources;
50 53
import android.graphics.Bitmap;
51 54
import android.graphics.BitmapFactory;
......
54 57

  
55 58
///////////////////////////////////////////////////////////////////////////////////////////////////
56 59

  
57
class ObjectTreeRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
60
class ObjectTreeRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
58 61
{
59 62
   private static final int NODE_FBO_SIZE = 300;
60 63
   private static final int GRID = 10;
61 64

  
62 65
   private final GLSurfaceView mView;
66
   private final Resources mResources;
63 67
   private final DistortedEffects mEffectsNode,mEffectsGrid;
64 68
   private final DistortedScreen mScreen;
65 69
   private final Static3D mScale;
......
75 79

  
76 80
   ObjectTreeRenderer(GLSurfaceView v)
77 81
      {
78
      mView   = v;
82
      mView = v;
83
      mResources = v.getResources();
84

  
79 85
      mDepth  = true;
80 86
      mScale  = new Static3D(1,1,1);
81 87
      Dynamic1D chromaDyn = new Dynamic1D(5000,0.0f);
......
202 208
      VertexEffectSink.enable();
203 209
      FragmentEffectChroma.enable();
204 210

  
205
      DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
211
      DistortedLibrary.onSurfaceCreated(this);
206 212
      }
207 213

  
208 214
///////////////////////////////////////////////////////////////////////////////////////////////////
......
211 217
      {
212 218
      android.util.Log.e("ObjectTree", ex.getMessage() );
213 219
      }
220

  
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

  
223
    public int openGlVersion()
224
      {
225
      Context context = mView.getContext();
226
      final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
227
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
228
      int glESversion = configurationInfo.reqGlEsVersion;
229
      int major = glESversion >> 16;
230
      int minor = glESversion & 0xff;
231

  
232
      return 100*major + 10*minor;
233
      }
234

  
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

  
237
    public InputStream localFile(int fileID)
238
      {
239
      return mResources.openRawResource(fileID);
240
      }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
    public void logMessage(String message)
245
      {
246
      android.util.Log.e("ObjectTree", message );
247
      }
214 248
}

Also available in: Unified diff