Project

General

Profile

« Previous | Next » 

Revision 5eb95531

Added by Leszek Koltunski over 7 years ago

Fix the 'PlainMonaLisa' to be able to run in the Emulator as well (before ELG Context creation would fail)

View differences:

src/main/java/org/distorted/examples/plainmonalisa/EglCore.java
26 26
import android.opengl.EGLDisplay;
27 27
import android.opengl.EGLExt;
28 28
import android.opengl.EGLSurface;
29
import android.os.Build;
29 30
import android.util.Log;
30 31
import android.view.Surface;
31 32

  
......
142 143
    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
143 144
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
144 145
    // when reading into a GL_RGBA buffer.
145
    int[] attribList =
146

  
147
    int [] normalAttribList =
146 148
                {
147 149
                EGL14.EGL_RED_SIZE, 8,
148 150
                EGL14.EGL_GREEN_SIZE, 8,
149 151
                EGL14.EGL_BLUE_SIZE, 8,
150 152
                EGL14.EGL_ALPHA_SIZE, 8,
151
                //EGL14.EGL_DEPTH_SIZE, 16,
152
                //EGL14.EGL_STENCIL_SIZE, 8,
153 153
                EGL14.EGL_RENDERABLE_TYPE, renderableType,
154 154
                EGL14.EGL_NONE, 0,      // placeholder for recordable [@-3]
155 155
                EGL14.EGL_NONE
......
157 157

  
158 158
    if ((flags & FLAG_RECORDABLE) != 0)
159 159
      {
160
      attribList[attribList.length - 3] = EGL_RECORDABLE_ANDROID;
161
      attribList[attribList.length - 2] = 1;
160
      normalAttribList[normalAttribList.length - 3] = EGL_RECORDABLE_ANDROID;
161
      normalAttribList[normalAttribList.length - 2] = 1;
162
      }
163

  
164
    int [] emulatorAttribList =
165
                {
166
                EGL14.EGL_RED_SIZE, 8,
167
                EGL14.EGL_GREEN_SIZE, 8,
168
                EGL14.EGL_BLUE_SIZE, 8,
169
                EGL14.EGL_ALPHA_SIZE, 8,
170
                EGL14.EGL_DEPTH_SIZE, 16,
171
                EGL14.EGL_STENCIL_SIZE, 0,
172
                EGL14.EGL_NONE
173
                };
174

  
175
    boolean isEmulator=
176
               Build.FINGERPRINT.startsWith("generic")
177
            || Build.FINGERPRINT.startsWith("unknown")
178
            || Build.MODEL.contains("google_sdk")
179
            || Build.MODEL.contains("Emulator")
180
            || Build.MODEL.contains("Android SDK built for x86")
181
            || Build.MANUFACTURER.contains("Genymotion")
182
            || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
183
            || "google_sdk".equals(Build.PRODUCT);
184

  
185
    int [] attribList = (isEmulator ? emulatorAttribList:normalAttribList);
186

  
187
    if( isEmulator )
188
      {
189
      Log.w(TAG, "Using emulator config!" );
162 190
      }
163 191

  
164 192
    EGLConfig[] configs = new EGLConfig[1];

Also available in: Unified diff