Revision 8c57d77b
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/library/main/DistortedLibrary.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
package org.distorted.library.main; |
22 | 22 |
|
23 |
import android.app.ActivityManager; |
|
24 |
import android.content.Context; |
|
25 |
import android.content.pm.ConfigurationInfo; |
|
26 |
import android.content.res.Resources; |
|
27 | 23 |
import android.opengl.GLES30; |
28 | 24 |
import android.opengl.GLES31; |
29 |
import android.util.Log; |
|
25 |
|
|
26 |
import java.io.InputStream; |
|
27 |
import java.nio.ByteBuffer; |
|
28 |
import java.nio.ByteOrder; |
|
29 |
import java.nio.FloatBuffer; |
|
30 |
import java.nio.IntBuffer; |
|
31 |
import java.util.regex.Matcher; |
|
32 |
import java.util.regex.Pattern; |
|
30 | 33 |
|
31 | 34 |
import org.distorted.library.R; |
32 | 35 |
import org.distorted.library.effect.Effect; |
... | ... | |
44 | 47 |
import org.distorted.library.program.VertexCompilationException; |
45 | 48 |
import org.distorted.library.type.Dynamic; |
46 | 49 |
|
47 |
import java.io.InputStream; |
|
48 |
import java.nio.ByteBuffer; |
|
49 |
import java.nio.ByteOrder; |
|
50 |
import java.nio.FloatBuffer; |
|
51 |
import java.nio.IntBuffer; |
|
52 |
import java.util.regex.Matcher; |
|
53 |
import java.util.regex.Pattern; |
|
54 |
|
|
55 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 51 |
/** |
57 | 52 |
* A singleton class used to control various global dialog_settings. |
... | ... | |
219 | 214 |
* compile its OIT problem only on the first attempt to use the OIT |
220 | 215 |
* Those will mainly be hardware-related: shaders do not compile on particular hardware, the required |
221 | 216 |
* OpenGL ES 3.0 is not supported, etc. |
217 |
* |
|
218 |
* Additionally, the User must be able to provide version of the OpenGL supported by the underlying |
|
219 |
* hardware and InputStreams to given local files. |
|
222 | 220 |
*/ |
223 |
public interface ExceptionListener
|
|
221 |
public interface LibraryUser
|
|
224 | 222 |
{ |
225 | 223 |
void distortedException(Exception ex); |
224 |
int openGlVersion(); |
|
225 |
InputStream localFile(int fileID); |
|
226 |
void logMessage(String message); |
|
226 | 227 |
} |
227 | 228 |
|
228 |
private static ExceptionListener mListener; |
|
229 |
private static Resources mResources; |
|
229 |
private static LibraryUser mUser; |
|
230 | 230 |
|
231 | 231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
232 | 232 |
// private: hide this from Javadoc |
... | ... | |
241 | 241 |
private static void createMainProgram() |
242 | 242 |
{ |
243 | 243 |
// MAIN PROGRAM //////////////////////////////////// |
244 |
final InputStream mainVertStream = mResources.openRawResource(R.raw.main_vertex_shader);
|
|
245 |
final InputStream mainFragStream = mResources.openRawResource(R.raw.main_fragment_shader);
|
|
244 |
final InputStream mainVertStream = mUser.localFile(R.raw.main_vertex_shader);
|
|
245 |
final InputStream mainFragStream = mUser.localFile(R.raw.main_fragment_shader);
|
|
246 | 246 |
|
247 | 247 |
int numF = FragmentEffect.getNumEnabled(); |
248 | 248 |
int numV = VertexEffect.getNumEnabled(); |
... | ... | |
267 | 267 |
} |
268 | 268 |
catch(Exception e) |
269 | 269 |
{ |
270 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile MAIN program: "+e.getMessage());
|
|
270 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile MAIN program: "+e.getMessage());
|
|
271 | 271 |
throw new RuntimeException(e.getMessage()); |
272 | 272 |
} |
273 | 273 |
|
... | ... | |
278 | 278 |
mTransformFeedbackH= GLES30.glGetUniformLocation( mMainProgramH, "u_TransformFeedback"); |
279 | 279 |
|
280 | 280 |
// BLIT PROGRAM //////////////////////////////////// |
281 |
final InputStream blitVertStream = mResources.openRawResource(R.raw.blit_vertex_shader);
|
|
282 |
final InputStream blitFragStream = mResources.openRawResource(R.raw.blit_fragment_shader);
|
|
281 |
final InputStream blitVertStream = mUser.localFile(R.raw.blit_vertex_shader);
|
|
282 |
final InputStream blitFragStream = mUser.localFile(R.raw.blit_fragment_shader);
|
|
283 | 283 |
|
284 | 284 |
try |
285 | 285 |
{ |
... | ... | |
287 | 287 |
} |
288 | 288 |
catch(Exception e) |
289 | 289 |
{ |
290 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile BLIT program: "+e.getMessage());
|
|
290 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile BLIT program: "+e.getMessage());
|
|
291 | 291 |
throw new RuntimeException(e.getMessage()); |
292 | 292 |
} |
293 | 293 |
|
... | ... | |
296 | 296 |
mBlitDepthH = GLES30.glGetUniformLocation( blitProgramH, "u_Depth"); |
297 | 297 |
|
298 | 298 |
// BLIT DEPTH PROGRAM //////////////////////////////////// |
299 |
final InputStream blitDepthVertStream = mResources.openRawResource(R.raw.blit_depth_vertex_shader);
|
|
300 |
final InputStream blitDepthFragStream = mResources.openRawResource(R.raw.blit_depth_fragment_shader);
|
|
299 |
final InputStream blitDepthVertStream = mUser.localFile(R.raw.blit_depth_vertex_shader);
|
|
300 |
final InputStream blitDepthFragStream = mUser.localFile(R.raw.blit_depth_fragment_shader);
|
|
301 | 301 |
|
302 | 302 |
try |
303 | 303 |
{ |
... | ... | |
305 | 305 |
} |
306 | 306 |
catch(Exception e) |
307 | 307 |
{ |
308 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile BLIT DEPTH program: "+e.getMessage());
|
|
308 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile BLIT DEPTH program: "+e.getMessage());
|
|
309 | 309 |
throw new RuntimeException(e.getMessage()); |
310 | 310 |
} |
311 | 311 |
|
... | ... | |
317 | 317 |
|
318 | 318 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
319 | 319 |
|
320 |
private static void createNormalProgram(Resources resources)
|
|
320 |
private static void createNormalProgram() |
|
321 | 321 |
{ |
322 | 322 |
// NORMAL PROGRAM ////////////////////////////////////// |
323 |
final InputStream normalVertexStream = resources.openRawResource(R.raw.normal_vertex_shader);
|
|
324 |
final InputStream normalFragmentStream = resources.openRawResource(R.raw.normal_fragment_shader);
|
|
323 |
final InputStream normalVertexStream = mUser.localFile(R.raw.normal_vertex_shader);
|
|
324 |
final InputStream normalFragmentStream = mUser.localFile(R.raw.normal_fragment_shader);
|
|
325 | 325 |
|
326 | 326 |
try |
327 | 327 |
{ |
... | ... | |
329 | 329 |
} |
330 | 330 |
catch(Exception e) |
331 | 331 |
{ |
332 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile NORMAL program: "+e.getMessage());
|
|
332 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile NORMAL program: "+e.getMessage());
|
|
333 | 333 |
throw new RuntimeException(e.getMessage()); |
334 | 334 |
} |
335 | 335 |
|
... | ... | |
339 | 339 |
|
340 | 340 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
341 | 341 |
|
342 |
private static void createFullProgram(Resources resources)
|
|
342 |
private static void createFullProgram() |
|
343 | 343 |
{ |
344 |
final InputStream fullVertStream = resources.openRawResource(R.raw.main_vertex_shader);
|
|
345 |
final InputStream fullFragStream = resources.openRawResource(R.raw.main_fragment_shader);
|
|
344 |
final InputStream fullVertStream = mUser.localFile(R.raw.main_vertex_shader);
|
|
345 |
final InputStream fullFragStream = mUser.localFile(R.raw.main_fragment_shader);
|
|
346 | 346 |
|
347 | 347 |
int numV = VertexEffect.getAllEnabled(); |
348 | 348 |
|
... | ... | |
367 | 367 |
} |
368 | 368 |
catch(Exception e) |
369 | 369 |
{ |
370 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile FULL program: "+e.getMessage());
|
|
370 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile FULL program: "+e.getMessage());
|
|
371 | 371 |
throw new RuntimeException(e.getMessage()); |
372 | 372 |
} |
373 | 373 |
|
... | ... | |
378 | 378 |
|
379 | 379 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
380 | 380 |
|
381 |
private static void createOITProgram(Resources resources)
|
|
381 |
private static void createOITProgram() |
|
382 | 382 |
{ |
383 | 383 |
// MAIN OIT PROGRAM //////////////////////////////// |
384 |
final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
|
|
385 |
final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader);
|
|
384 |
final InputStream mainVertStream = mUser.localFile(R.raw.main_vertex_shader);
|
|
385 |
final InputStream mainFragStream = mUser.localFile(R.raw.main_fragment_shader);
|
|
386 | 386 |
|
387 | 387 |
int numF = FragmentEffect.getNumEnabled(); |
388 | 388 |
int numV = VertexEffect.getNumEnabled(); |
... | ... | |
404 | 404 |
} |
405 | 405 |
catch(Exception e) |
406 | 406 |
{ |
407 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile MAIN OIT program: "+e.getMessage());
|
|
407 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile MAIN OIT program: "+e.getMessage());
|
|
408 | 408 |
throw new RuntimeException(e.getMessage()); |
409 | 409 |
} |
410 | 410 |
|
... | ... | |
416 | 416 |
mMainOITNumRecordsH = GLES30.glGetUniformLocation( mMainOITProgramH, "u_numRecords"); |
417 | 417 |
|
418 | 418 |
// OIT CLEAR PROGRAM //////////////////////////////////// |
419 |
final InputStream oitClearVertStream = resources.openRawResource(R.raw.oit_vertex_shader);
|
|
420 |
final InputStream oitClearFragStream = resources.openRawResource(R.raw.oit_clear_fragment_shader);
|
|
419 |
final InputStream oitClearVertStream = mUser.localFile(R.raw.oit_vertex_shader);
|
|
420 |
final InputStream oitClearFragStream = mUser.localFile(R.raw.oit_clear_fragment_shader);
|
|
421 | 421 |
|
422 | 422 |
try |
423 | 423 |
{ |
... | ... | |
425 | 425 |
} |
426 | 426 |
catch(Exception e) |
427 | 427 |
{ |
428 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile OIT CLEAR program: "+e.getMessage());
|
|
428 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile OIT CLEAR program: "+e.getMessage());
|
|
429 | 429 |
throw new RuntimeException(e.getMessage()); |
430 | 430 |
} |
431 | 431 |
|
... | ... | |
435 | 435 |
mOITClearSizeH = GLES30.glGetUniformLocation( oitClearProgramH, "u_Size"); |
436 | 436 |
|
437 | 437 |
// OIT BUILD PROGRAM //////////////////////////////////// |
438 |
final InputStream oitBuildVertStream = resources.openRawResource(R.raw.oit_vertex_shader);
|
|
439 |
final InputStream oitBuildFragStream = resources.openRawResource(R.raw.oit_build_fragment_shader);
|
|
438 |
final InputStream oitBuildVertStream = mUser.localFile(R.raw.oit_vertex_shader);
|
|
439 |
final InputStream oitBuildFragStream = mUser.localFile(R.raw.oit_build_fragment_shader);
|
|
440 | 440 |
|
441 | 441 |
try |
442 | 442 |
{ |
... | ... | |
444 | 444 |
} |
445 | 445 |
catch(Exception e) |
446 | 446 |
{ |
447 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile OIT BUILD program: "+e.getMessage());
|
|
447 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile OIT BUILD program: "+e.getMessage());
|
|
448 | 448 |
throw new RuntimeException(e.getMessage()); |
449 | 449 |
} |
450 | 450 |
|
... | ... | |
457 | 457 |
mOITBuildNumRecordsH = GLES30.glGetUniformLocation( oitBuildProgramH, "u_numRecords"); |
458 | 458 |
|
459 | 459 |
// OIT COLLAPSE PROGRAM /////////////////////////// |
460 |
final InputStream oitCollapseVertStream = resources.openRawResource(R.raw.oit_vertex_shader);
|
|
461 |
final InputStream oitCollapseFragStream = resources.openRawResource(R.raw.oit_collapse_fragment_shader);
|
|
460 |
final InputStream oitCollapseVertStream = mUser.localFile(R.raw.oit_vertex_shader);
|
|
461 |
final InputStream oitCollapseFragStream = mUser.localFile(R.raw.oit_collapse_fragment_shader);
|
|
462 | 462 |
|
463 | 463 |
try |
464 | 464 |
{ |
... | ... | |
466 | 466 |
} |
467 | 467 |
catch(Exception e) |
468 | 468 |
{ |
469 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile OIT COLLAPSE program: "+e.getMessage());
|
|
469 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile OIT COLLAPSE program: "+e.getMessage());
|
|
470 | 470 |
throw new RuntimeException(e.getMessage()); |
471 | 471 |
} |
472 | 472 |
|
... | ... | |
477 | 477 |
mOITCollapseSizeH = GLES30.glGetUniformLocation( oitCollapseProgramH, "u_Size"); |
478 | 478 |
|
479 | 479 |
// OIT RENDER PROGRAM /////////////////////////// |
480 |
final InputStream oitRenderVertStream = resources.openRawResource(R.raw.oit_vertex_shader);
|
|
481 |
final InputStream oitRenderFragStream = resources.openRawResource(R.raw.oit_render_fragment_shader);
|
|
480 |
final InputStream oitRenderVertStream = mUser.localFile(R.raw.oit_vertex_shader);
|
|
481 |
final InputStream oitRenderFragStream = mUser.localFile(R.raw.oit_render_fragment_shader);
|
|
482 | 482 |
|
483 | 483 |
try |
484 | 484 |
{ |
... | ... | |
486 | 486 |
} |
487 | 487 |
catch(Exception e) |
488 | 488 |
{ |
489 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile OIT RENDER program: "+e.getMessage());
|
|
489 |
mUser.logMessage(e.getClass().getSimpleName()+" trying to compile OIT RENDER program: "+e.getMessage());
|
|
490 | 490 |
throw new RuntimeException(e.getMessage()); |
491 | 491 |
} |
492 | 492 |
|
... | ... | |
504 | 504 |
{ |
505 | 505 |
try |
506 | 506 |
{ |
507 |
createNormalProgram(mResources);
|
|
507 |
createNormalProgram(); |
|
508 | 508 |
} |
509 | 509 |
catch(Exception ex) |
510 | 510 |
{ |
511 |
mListener.distortedException(ex);
|
|
511 |
mUser.distortedException(ex);
|
|
512 | 512 |
return; |
513 | 513 |
} |
514 | 514 |
} |
... | ... | |
546 | 546 |
{ |
547 | 547 |
try |
548 | 548 |
{ |
549 |
createFullProgram(mResources);
|
|
549 |
createFullProgram(); |
|
550 | 550 |
} |
551 | 551 |
catch(Exception ex) |
552 | 552 |
{ |
553 |
mListener.distortedException(ex);
|
|
553 |
mUser.distortedException(ex);
|
|
554 | 554 |
return; |
555 | 555 |
} |
556 | 556 |
} |
... | ... | |
684 | 684 |
} |
685 | 685 |
else |
686 | 686 |
{ |
687 |
Log.e("effects", "print: failed to map atomic buffer");
|
|
687 |
mUser.logMessage("printPreviousBuffer: failed to map atomic buffer");
|
|
688 | 688 |
} |
689 | 689 |
|
690 | 690 |
GLES30.glUnmapBuffer(GLES31.GL_ATOMIC_COUNTER_BUFFER); |
... | ... | |
705 | 705 |
} |
706 | 706 |
else |
707 | 707 |
{ |
708 |
Log.e("effects", "zero: failed to map atomic buffer");
|
|
708 |
mUser.logMessage("zeroBuffer: failed to map atomic buffer");
|
|
709 | 709 |
} |
710 | 710 |
|
711 | 711 |
GLES30.glUnmapBuffer(GLES31.GL_ATOMIC_COUNTER_BUFFER); |
... | ... | |
761 | 761 |
|
762 | 762 |
try |
763 | 763 |
{ |
764 |
createOITProgram(mResources);
|
|
764 |
createOITProgram(); |
|
765 | 765 |
} |
766 | 766 |
catch(Exception ex) |
767 | 767 |
{ |
768 |
mListener.distortedException(ex);
|
|
768 |
mUser.distortedException(ex);
|
|
769 | 769 |
return; |
770 | 770 |
} |
771 | 771 |
} |
... | ... | |
933 | 933 |
|
934 | 934 |
if( drvVersion<22 ) |
935 | 935 |
{ |
936 |
Log.e("DISTORTED", "You are running this on a ARM Mali driver r"+driverVersion+".\n" +
|
|
936 |
mUser.logMessage("You are running this on a ARM Mali driver r"+driverVersion+".\n" +
|
|
937 | 937 |
"This is a buggy driver, please update to r22. Inserting workaround which uses a lot of memory."); |
938 | 938 |
|
939 | 939 |
mFBOQueueSize = queueSize; |
... | ... | |
943 | 943 |
} |
944 | 944 |
catch(Exception ex) |
945 | 945 |
{ |
946 |
android.util.Log.e("library", "exception trying to pattern match version: "+ex.toString());
|
|
946 |
mUser.logMessage("DistortedLibrary: exception trying to pattern match version: "+ex.toString());
|
|
947 | 947 |
} |
948 | 948 |
} |
949 | 949 |
else if( mVendor.contains("Imagination") ) |
950 | 950 |
{ |
951 | 951 |
if( mRenderer.contains("GE8") ) |
952 | 952 |
{ |
953 |
Log.e("DISTORTED", "You are running this on a PowerVR GE8XXX.\nDue to a buggy compiler OIT rendering will not work");
|
|
954 |
Log.e("DISTORTED", "GLSL Version "+GLES30.glGetString(GLES31.GL_SHADING_LANGUAGE_VERSION));
|
|
953 |
mUser.logMessage("You are running this on a PowerVR GE8XXX.\nDue to a buggy compiler OIT rendering will not work");
|
|
954 |
mUser.logMessage("GLSL Version "+GLES30.glGetString(GLES31.GL_SHADING_LANGUAGE_VERSION));
|
|
955 | 955 |
} |
956 | 956 |
} |
957 | 957 |
else if( mVendor.contains("Qualcomm")) |
... | ... | |
960 | 960 |
|
961 | 961 |
if( mRenderer.contains("308") && (driverVersion==331 || driverVersion==415) ) |
962 | 962 |
{ |
963 |
Log.e("DISTORTED", "You are running this on an Adreno 308 driver 331 or 415.\nStrange shit might happen.");
|
|
963 |
mUser.logMessage("You are running this on an Adreno 308 driver 331 or 415.\nStrange shit might happen.");
|
|
964 | 964 |
mBuggyUBOs = true; |
965 | 965 |
} |
966 | 966 |
if( mGLSL<=300 && driverVersion<415 ) // This is only on old enough drivers, 84,95,100,104,140 and known bad, 415 is known good. |
967 | 967 |
{ |
968 |
Log.e("DISTORTED", "Slow compilation of Transform Feedback programs!");
|
|
968 |
mUser.logMessage("Slow compilation of Transform Feedback programs!");
|
|
969 | 969 |
mFastCompilationTF = false; |
970 | 970 |
} |
971 | 971 |
} |
972 | 972 |
} |
973 | 973 |
|
974 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
975 |
/** |
|
976 |
* Not an external API |
|
977 |
* |
|
978 |
* @y.exclude |
|
979 |
*/ |
|
980 |
|
|
981 |
public static void logMessage(String message) |
|
982 |
{ |
|
983 |
mUser.logMessage(message); |
|
984 |
} |
|
985 |
|
|
974 | 986 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
975 | 987 |
/** |
976 | 988 |
* Return OpenGL ES version supported by the hardware we are running on. |
... | ... | |
989 | 1001 |
* <p> |
990 | 1002 |
* Needs to be called from a thread holding the OpenGL context. |
991 | 1003 |
* |
992 |
* @param context Context of the App using the library - used to open up Resources and read Shader code. |
|
993 |
* @param listener The library will send all (asynchronous!) exceptions there. |
|
1004 |
* @param user The Code which will be using this library, which must implement the LibraryUser interface. |
|
994 | 1005 |
*/ |
995 |
public static void onSurfaceCreated(final Context context, final ExceptionListener listener)
|
|
1006 |
public static void onSurfaceCreated(final LibraryUser user)
|
|
996 | 1007 |
{ |
997 |
onSurfaceCreated(context,listener,4);
|
|
1008 |
onSurfaceCreated(user,4);
|
|
998 | 1009 |
} |
999 | 1010 |
|
1000 | 1011 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1004 | 1015 |
* <p> |
1005 | 1016 |
* Needs to be called from a thread holding the OpenGL context. |
1006 | 1017 |
* |
1007 |
* @param context Context of the App using the library - used to open up Resources and read Shader code. |
|
1008 |
* @param listener The library will send all (asynchronous!) exceptions there. |
|
1018 |
* @param user The Code which will be using this library, which must implement the LibraryUser interface. |
|
1009 | 1019 |
* @param queueSize the size of the FBO queue, a workaround for the bug on Mali drivers. Use a small integer - 1,...,4 |
1010 | 1020 |
*/ |
1011 |
public static void onSurfaceCreated(final Context context, final ExceptionListener listener, int queueSize)
|
|
1021 |
public static void onSurfaceCreated(final LibraryUser user, int queueSize)
|
|
1012 | 1022 |
{ |
1013 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
1014 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
1015 |
|
|
1016 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
1017 |
int major = glESversion >> 16; |
|
1018 |
int minor = glESversion & 0xff; |
|
1019 |
|
|
1020 |
mListener = listener; |
|
1023 |
mUser = user; |
|
1024 |
int version = mUser.openGlVersion(); |
|
1025 |
int major = version/100; |
|
1026 |
int minor = ((version/10)%10); |
|
1021 | 1027 |
|
1022 | 1028 |
if( major< 3 ) |
1023 | 1029 |
{ |
1024 | 1030 |
mGLSL = 100*major + 10*minor; |
1025 | 1031 |
VertexCompilationException ex = new VertexCompilationException("at least OpenGL ES 3.0 required, this device supports only "+major+"."+minor); |
1026 |
mListener.distortedException(ex);
|
|
1032 |
mUser.distortedException(ex);
|
|
1027 | 1033 |
} |
1028 | 1034 |
else |
1029 | 1035 |
{ |
... | ... | |
1038 | 1044 |
GLES30.glGetIntegerv(GLES30.GL_MAX_FRAGMENT_UNIFORM_VECTORS, tmp, 0); |
1039 | 1045 |
mMaxNumberOfFraUniforms = tmp[0]; |
1040 | 1046 |
|
1041 |
android.util.Log.e("DISTORTED", "Using OpenGL ES "+major+"."+minor);
|
|
1047 |
mUser.logMessage("Using OpenGL ES "+major+"."+minor);
|
|
1042 | 1048 |
/* |
1043 |
android.util.Log.e("DISTORTED", "max texture size: "+mMaxTextureSize);
|
|
1044 |
android.util.Log.e("DISTORTED", "max num vert: "+mMaxNumberOfVerUniforms);
|
|
1045 |
android.util.Log.e("DISTORTED", "max num frag: "+mMaxNumberOfFraUniforms);
|
|
1049 |
mUser.logMessage("max texture size: "+mMaxTextureSize);
|
|
1050 |
mUser.logMessage("max num vert: "+mMaxNumberOfVerUniforms);
|
|
1051 |
mUser.logMessage("max num frag: "+mMaxNumberOfFraUniforms);
|
|
1046 | 1052 |
*/ |
1047 | 1053 |
mGLSL_VERSION = "#version "+mGLSL+" es\n"; |
1048 | 1054 |
|
... | ... | |
1052 | 1058 |
detectBuggyDriversAndSetQueueSize(queueSize); |
1053 | 1059 |
EffectMessageSender.startSending(); |
1054 | 1060 |
|
1055 |
mResources = context.getResources(); |
|
1056 |
|
|
1057 | 1061 |
try |
1058 | 1062 |
{ |
1059 | 1063 |
createMainProgram(); |
1060 | 1064 |
} |
1061 | 1065 |
catch(Exception ex) |
1062 | 1066 |
{ |
1063 |
mListener.distortedException(ex);
|
|
1067 |
mUser.distortedException(ex);
|
|
1064 | 1068 |
} |
1065 | 1069 |
|
1066 | 1070 |
try |
1067 | 1071 |
{ |
1068 |
EffectQueuePostprocess.createPrograms(mResources, mGLSL); |
|
1072 |
final InputStream vertStream = mUser.localFile(R.raw.main_vertex_shader); |
|
1073 |
final InputStream fragStream = mUser.localFile(R.raw.preprocess_fragment_shader); |
|
1074 |
EffectQueuePostprocess.createPrograms(vertStream, fragStream, mGLSL); |
|
1069 | 1075 |
} |
1070 | 1076 |
catch(Exception ex) |
1071 | 1077 |
{ |
1072 |
mListener.distortedException(ex);
|
|
1078 |
mUser.distortedException(ex);
|
|
1073 | 1079 |
} |
1074 | 1080 |
|
1075 | 1081 |
try |
... | ... | |
1078 | 1084 |
} |
1079 | 1085 |
catch(Exception ex) |
1080 | 1086 |
{ |
1081 |
mListener.distortedException(ex);
|
|
1087 |
mUser.distortedException(ex);
|
|
1082 | 1088 |
} |
1083 | 1089 |
} |
1084 | 1090 |
|
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.