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/save/SaveRenderer.java
44 44
import org.distorted.library.type.Static3D;
45 45
import org.distorted.library.type.Static4D;
46 46

  
47
import android.app.ActivityManager;
48
import android.content.Context;
49
import android.content.pm.ConfigurationInfo;
50
import android.content.res.Resources;
47 51
import android.graphics.Bitmap;
48 52
import android.graphics.BitmapFactory;
49 53
import android.opengl.GLES31;
......
52 56

  
53 57
///////////////////////////////////////////////////////////////////////////////////////////////////
54 58

  
55
class SaveRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
59
class SaveRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
56 60
  {
57
  private GLSurfaceView mView;
58
  private DistortedEffects mEffects;
61
  private final GLSurfaceView mView;
62
  private final DistortedEffects mEffects;
63
  private final DistortedScreen mScreen;
64
  private final Static1D s0;
65
  private final Static3D mScaleFactor, mScaleMain, mScaleVertex;
66
  private final Resources mResources;
67

  
59 68
  private DistortedFramebuffer mOffscreen;
60 69
  private DistortedTexture mTexture;
61 70
  private MeshSquare mMesh;
62
  private DistortedScreen mScreen;
63
  private Static1D s0;
64
  private Static3D mScaleFactor, mScaleMain, mScaleVertex;
65

  
66 71
  private float mScale;
67 72
  private int bmpHeight, bmpWidth;
68 73
  private int scrHeight, scrWidth;
......
75 80
  SaveRenderer(GLSurfaceView v)
76 81
    {
77 82
    mView = v;
78
      
83
    mResources = v.getResources();
84

  
79 85
    boobsSink  = 1.0f;
80 86

  
81 87
    Static3D pLeft = new Static3D(-68, 36, 0);
......
249 255
    VertexEffectScale.enable();
250 256
    VertexEffectSink.enable();
251 257

  
252
    DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
258
    DistortedLibrary.onSurfaceCreated(this);
253 259
    }
254 260

  
255 261
///////////////////////////////////////////////////////////////////////////////////////////////////
......
258 264
    {
259 265
    android.util.Log.e("Save", ex.getMessage() );
260 266
    }
267

  
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269

  
270
  public int openGlVersion()
271
     {
272
     Context context = mView.getContext();
273
     final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
274
     final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
275
     int glESversion = configurationInfo.reqGlEsVersion;
276
     int major = glESversion >> 16;
277
     int minor = glESversion & 0xff;
278

  
279
     return 100*major + 10*minor;
280
     }
281

  
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

  
284
  public InputStream localFile(int fileID)
285
     {
286
     return mResources.openRawResource(fileID);
287
     }
288

  
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

  
291
  public void logMessage(String message)
292
     {
293
     android.util.Log.e("Save", message );
294
     }
261 295
  }

Also available in: Unified diff