Project

General

Profile

« Previous | Next » 

Revision 806ca386

Added by Leszek Koltunski over 7 years ago

Simplify setting up DistortedScreen.

View differences:

src/main/java/org/distorted/library/DistortedRenderState.java
245 245
        }
246 246
      }
247 247

  
248
//  android.util.Log.d("State", "mFunc="+mStencilFuncFunc+" sFunc="+sStencilFuncFunc);
249
//  android.util.Log.d("State", "GL_ALWAYS="+GLES30.GL_ALWAYS+" GL_EQUAL="+GLES30.GL_EQUAL);
250

  
251 248
    /////////////////////////////////////////////////////
252 249
    // 8. Adjust Stencil function?
253 250
    if( mStencilFuncFunc!=sStencilFuncFunc || mStencilFuncRef!=sStencilFuncRef || mStencilFuncMask!=sStencilFuncMask )
src/main/java/org/distorted/library/DistortedScreen.java
20 20
package org.distorted.library;
21 21

  
22 22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
24
import android.app.ActivityManager;
25
import android.content.Context;
26
import android.content.pm.ConfigurationInfo;
27
import android.opengl.GLSurfaceView;
28
import android.view.SurfaceView;
29

  
23 30
/**
24 31
 * Class which represents the Screen.
25 32
 * <p>
......
43 50
 * <p>
44 51
 * Has to be followed by a 'resize()' to set the size.
45 52
 */
46
  public DistortedScreen()
53
  public DistortedScreen(GLSurfaceView view)
47 54
    {
48 55
    // set color to 'DONT_CREATE' so that Screens will not get added to the Surface lists
49 56
    // set depth to 'CREATED' so that depth will be, by default, on.
50 57
    super(0,0,DONT_CREATE,CREATED,0,TYPE_USER);
58

  
59
    if( view!=null )
60
      {
61
      Context context = view.getContext();
62
      final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
63
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
64
      view.setEGLContextClientVersion((configurationInfo.reqGlEsVersion >> 16) >= 3 ? 3 : 2);
65
      }
51 66
    }
52 67
  }

Also available in: Unified diff