CODE_TOLD_FAST

GLSL/Error_Pixel

Jun 30th, 2020
334
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     //:ES2_AA2_MAC_DEB: My debug macro, true if positive.
  2.     //:        pix_err: PIXel ERRor    ( Stores Hex Error Code )
  3.     //:        pix_fra: PIXel FRAgment ( fragment color        )
  4.  
  5.     #if( ES2_AA2_MAC_DEB > 0 ) //:///////////////////////////://
  6.  
  7.         //:ASSIGN_TO_ZERO_AT_TOP_OF_FUNCTION!!!!!!!!!!!!!!!!!!!!
  8.         uint pix_err =( 0x00000000 );
  9.  
  10.     #endif //:///////////////////////////////////////////////://
  11.  
  12.  
  13.     //: ...Later when you want to error check....
  14.  
  15.  
  16.     #if( ES2_AA2_MAC_DEB > 0 ) //:///////////////////////////://
  17.    
  18.         if( Ax1-Ax0+uint(1) != ES2_zoo_wid ||
  19.             Ay1-Ay0+uint(1) != ES2_zoo_hig ){
  20.  
  21.             //: The first error encountered puts program     ://
  22.             //: into invalid state, so we want to make sure  ://
  23.             //: we never override the first error tripped.   ://
  24.             //: So always guard with comparison to           ://
  25.             //: 0x00000000 before setting to the error color.://
  26.             if( uint(0x00000000) == pix_err ){
  27.                 pix_err=( uint(0xFF9000FF) );
  28.             };;
  29.         };;
  30.    
  31.     #endif //:///////////////////////////////////////////////://
  32.  
  33.  
  34.     ... Do more code.......................................
  35.     ... DONT TRY TO EXIT EARLY if error is tripped ........
  36.     ... that will just turn your code into spaghetti ......
  37.  
  38.  
  39.     #if( ES2_AA2_MAC_DEB > 0 )  //://////////////////////////://
  40.  
  41.         if( uint(0x000000) != pix_err ){
  42.  
  43.             #define F_F uint(0xFF)" //://////////////////////://
  44.             pix_fra=( vec4(  //://///////////////////////////://
  45.                                                          
  46.              float( ( pix_err >> 24  ) & F_F ) / 255.0    
  47.             ,float( ( pix_err >> 16  ) & F_F ) / 255.0    
  48.             ,float( ( pix_err >>  8  ) & F_F ) / 255.0    
  49.             ,float( ( pix_err >>  0  ) & F_F ) / 255.0    
  50.                                                          
  51.             ));; //://///////////////////////////////////////://
  52.             #undef F_F  //://////////////////////////////////://        
  53.  
  54.         };;
  55.  
  56.     #endif //:///////////////////////////////////////////////://
  57.  
  58.  
  59.     //: Now in debug mode, you can color sample the pixel    ://
  60.     //: and type in the hex code to find the exact error.    ://
  61.     //: Might not be helpful for minor edge cases, but       ://
  62.     //: should be very helpful for gross mistakes in         ://
  63.     //: your programming logic.                              ://
  64.     return( pix_fra );
RAW Paste Data