@@ -470,27 +470,30 @@ public void onCreate(Bundle savedInstanceState) {
470
470
//get renderer name anc class
471
471
String renderer_name = sketchRenderer ();
472
472
Class <?> renderer_class = null ;
473
- try {
474
- renderer_class = Class .forName ( renderer_name );}
475
- catch ( ClassNotFoundException exception ){
473
+ try {
474
+ renderer_class = Class .forName (renderer_name );
475
+ } catch ( ClassNotFoundException exception ) {
476
476
//what to throw here?
477
- throw new RuntimeException (
478
- String . format (
479
- "Error: Could not resolve renderer class name: %s" , renderer_name ),
480
- exception ); }
477
+ String message = String . format (
478
+ "Error: Could not resolve renderer class name: %s" , renderer_name );
479
+ throw new RuntimeException ( message , exception );
480
+ }
481
481
482
482
//java2d renderer
483
- if ( renderer_name .equals ( JAVA2D ))
484
- surfaceView = new SketchSurfaceView ( this , sw , sh );
483
+ if (renderer_name .equals (JAVA2D )) {
484
+ surfaceView = new SketchSurfaceView (this , sw , sh );
485
+ }
485
486
//P2D, P3D, and any other PGraphicsOpenGL-based renderer
486
- else if ( PGraphicsOpenGL .class .isAssignableFrom ( renderer_class ))
487
- surfaceView = new SketchSurfaceViewGL ( this , sw , sh ,
487
+ else if ( PGraphicsOpenGL .class .isAssignableFrom (renderer_class )){
488
+ surfaceView = new SketchSurfaceViewGL (this , sw , sh ,
488
489
(Class <? extends PGraphicsOpenGL >) renderer_class );
490
+ }
489
491
//anything else
490
- else throw new RuntimeException (
491
- String .format (
492
- "Error: Unsupported renderer class: %s" ,
493
- renderer_name ));
492
+ else {
493
+ String message = String .format (
494
+ "Error: Unsupported renderer class: %s" , renderer_name )
495
+ throw new RuntimeException (message );
496
+ }
494
497
495
498
// g = ((SketchSurfaceView) surfaceView).getGraphics();
496
499
@@ -829,22 +832,26 @@ public SketchSurfaceViewGL(
829
832
// before surfaceChanged() is ever called.
830
833
831
834
//P2D
832
- if ( renderer_class .equals ( PGraphics2D .class ))
835
+ if ( renderer_class .equals ( PGraphics2D .class )) {
833
836
g3 = new PGraphics2D ();
837
+ }
834
838
//P3D
835
- else if ( renderer_class .equals ( PGraphics3D .class ))
839
+ else if ( renderer_class .equals ( PGraphics3D .class )) {
836
840
g3 = new PGraphics3D ();
837
- //something that extends P2D or P3D
838
- else
839
- try {
841
+ }
842
+ //something that extends P2D, P3D, or PGraphicsOpenGL
843
+ else {
844
+ try {
840
845
//dang java generics
841
846
Constructor <? extends PGraphicsOpenGL > constructor =
842
847
renderer_class .getConstructor ();
843
- g3 = constructor .newInstance ();}
844
- catch ( Exception exception ){
848
+ g3 = constructor .newInstance ();
849
+ } catch ( Exception exception ) {
845
850
throw new RuntimeException (
846
851
"Error: Failed to initialize custom OpenGL renderer" ,
847
- exception );}
852
+ exception );
853
+ }
854
+ }
848
855
849
856
850
857
//set it up
0 commit comments