Revision edea9cf3
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/Distorted.java | ||
---|---|---|
23 | 23 |
import android.content.Context; |
24 | 24 |
import android.content.pm.ConfigurationInfo; |
25 | 25 |
import android.content.res.Resources; |
26 |
import android.opengl.GLES31; |
|
26 | 27 |
|
27 | 28 |
import org.distorted.library.effect.Effect; |
28 | 29 |
import org.distorted.library.effect.FragmentEffect; |
... | ... | |
98 | 99 |
|
99 | 100 |
} |
100 | 101 |
|
102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
103 |
// ARM Mali driver r12 has problems when we keep swapping many FBOs (fixed in r22) |
|
104 |
// PowerVR GE8100 compiler fails to compile OIT programs. |
|
105 |
|
|
106 |
static void detectBuggyDrivers() |
|
107 |
{ |
|
108 |
String vendor = GLES31.glGetString(GLES31.GL_VENDOR); |
|
109 |
String version = GLES31.glGetString(GLES31.GL_VERSION); |
|
110 |
String renderer= GLES31.glGetString(GLES31.GL_RENDERER); |
|
111 |
|
|
112 |
/* |
|
113 |
android.util.Log.e("DISTORTED", "GLSL Version "+GLES31.glGetString(GLES31.GL_SHADING_LANGUAGE_VERSION)); |
|
114 |
android.util.Log.e("DISTORTED", "GL Version " +GLES31.glGetString(GLES31.GL_VERSION)); |
|
115 |
android.util.Log.e("DISTORTED", "GL Vendor " +GLES31.glGetString(GLES31.GL_VENDOR)); |
|
116 |
android.util.Log.e("DISTORTED", "GL Renderer " +GLES31.glGetString(GLES31.GL_RENDERER)); |
|
117 |
*/ |
|
118 |
|
|
119 |
if( vendor.contains("ARM") ) |
|
120 |
{ |
|
121 |
if( version.contains("r12") ) |
|
122 |
{ |
|
123 |
android.util.Log.e("DISTORTED", "You are running this on a ARM Mali driver r12. This is a buggy driver, please update to r22. Problems with flashing expected."); |
|
124 |
} |
|
125 |
} |
|
126 |
else if( vendor.contains("Imagination") ) |
|
127 |
{ |
|
128 |
if( renderer.contains("GE8") ) |
|
129 |
{ |
|
130 |
android.util.Log.e("DISTORTED", "You are running this on a PowerVR GE8XXX. Due to a buggy compiler OIT rendering will not work"); |
|
131 |
} |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
101 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
102 | 136 |
/** |
103 | 137 |
* Have we called onCreate yet, ie have we initialized the library? |
... | ... | |
117 | 151 |
* |
118 | 152 |
* @param context Context of the App using the library - used to open up Resources and read Shader code. |
119 | 153 |
*/ |
120 |
public static void onCreate(final Context context) |
|
154 |
public static void onCreate(final Context context) throws Exception
|
|
121 | 155 |
{ |
122 | 156 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
123 | 157 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
124 | 158 |
android.util.Log.e("DISTORTED", "Using OpenGL ES "+configurationInfo.getGlEsVersion()); |
125 |
/* |
|
126 |
android.util.Log.e("DISTORTED", "GLSL Version "+GLES31.glGetString(GLES31.GL_SHADING_LANGUAGE_VERSION)); |
|
127 |
android.util.Log.e("DISTORTED", "GL Version " +GLES31.glGetString(GLES31.GL_VERSION)); |
|
128 |
android.util.Log.e("DISTORTED", "GL Vendor " +GLES31.glGetString(GLES31.GL_VENDOR)); |
|
129 |
android.util.Log.e("DISTORTED", "GL Renderer " +GLES31.glGetString(GLES31.GL_RENDERER)); |
|
130 |
*/ |
|
159 |
|
|
160 |
mInitialized = true; |
|
161 |
|
|
162 |
detectBuggyDrivers(); |
|
163 |
|
|
131 | 164 |
EffectMessageSender.startSending(); |
132 | 165 |
|
133 | 166 |
final Resources resources = context.getResources(); |
134 |
DistortedEffects.createPrograms(resources); |
|
135 |
DistortedEffects.createProgramsOIT(resources); |
|
136 |
PostprocessEffect.createPrograms(); |
|
137 | 167 |
|
138 |
mInitialized = true; |
|
168 |
Exception exception=null; |
|
169 |
|
|
170 |
try |
|
171 |
{ |
|
172 |
DistortedEffects.createPrograms(resources); |
|
173 |
} |
|
174 |
catch(Exception ex) |
|
175 |
{ |
|
176 |
exception = ex; |
|
177 |
} |
|
178 |
|
|
179 |
try |
|
180 |
{ |
|
181 |
DistortedEffects.createProgramsOIT(resources); |
|
182 |
} |
|
183 |
catch(Exception ex) |
|
184 |
{ |
|
185 |
exception = ex; |
|
186 |
} |
|
187 |
|
|
188 |
try |
|
189 |
{ |
|
190 |
PostprocessEffect.createPrograms(); |
|
191 |
} |
|
192 |
catch(Exception ex) |
|
193 |
{ |
|
194 |
exception = ex; |
|
195 |
} |
|
196 |
|
|
197 |
if( exception!=null) |
|
198 |
{ |
|
199 |
throw exception; |
|
200 |
} |
|
139 | 201 |
} |
140 | 202 |
|
141 | 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
170 | 232 |
|
171 | 233 |
mInitialized = false; |
172 | 234 |
} |
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
/** |
|
176 |
* Return 2 or 3 depending if we have OpenGL Es 2.0 or 3.x context created. |
|
177 |
*/ |
|
178 |
public static int getGlVersion() |
|
179 |
{ |
|
180 |
return GLSL == 300 ? 3:2; |
|
181 |
} |
|
182 | 235 |
} |
Also available in: Unified diff
In Distorted.onCreate(), catch and re-throw exceptions, so that even is some Program fails to compile, others will still compile.