@ -12,6 +12,7 @@  
			
		 
		
	
		
			
			 
			 
			
			 
			
			* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			# include  "raylib.h"  
			
		 
		
	
		
			
			 
			 
			
			 
			
			# include  "raymath.h"  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
			
		 
		
	
		
			
			 
			 
			
			 
			
			/ /  Program  main  entry  point  
			
		 
		
	
	
		
			
				
				
				
				
					
						 
					 
				
				 
			
			 
			
			@ -33,11 +34,28 @@ int main(void)  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    camera . fovy  =  45.0f ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    camera . projection  =  CAMERA_PERSPECTIVE ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Texture2D  bill  =  LoadTexture ( " resources/billboard.png " ) ;      / /  Our  texture  billboard   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Vector3  billPosition  =  {  0.0f ,  2.0f ,  0.0f  } ;                  / /  Position  where  draw  billboard   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Texture2D  bill  =  LoadTexture ( " resources/billboard.png " ) ;      / /  Our  billboard  texture   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Vector3  billPositionStatic  =  {  0.0f ,  2.0f ,  0.0f  } ;                  / /  Position  of  billboard   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Vector3  billPositionRotating  =  {  1.0f ,  2.0f ,  1.0f  } ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  Entire  billboard  texture ,  source  is  used  to  take  a  segment  from  a  larger  texture .   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Rectangle  source  =  {  0.0f ,  0.0f ,  ( float ) bill . width ,  ( float ) bill . height  } ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  NOTE :  Billboard  locked  on  axis - Y   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Vector3  billUp  =  {  0.0f ,  1.0f ,  0.0f  } ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  Rotate  around  origin   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  Here  we  choose  to  rotate  around  the  image  center   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  NOTE :  ( - 1 ,  1 )  is  the  range  where  origin . x ,  origin . y  is  inside  the  texture   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    Vector2  rotateOrigin  =  {  0.0f  } ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    SetCameraMode ( camera ,  CAMERA_ORBITAL ) ;   / /  Set  an  orbital  camera  mode   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  Distance  is  needed  for  the  correct  billboard  draw  order   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / /  Larger  distance  ( further  away  from  the  camera )  should  be  drawn  prior  to  smaller  distance .   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    float  distanceStatic ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    float  distanceRotating ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			    float  rotation  =  0.0f ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    SetTargetFPS ( 60 ) ;                        / /  Set  our  game  to  run  at  60  frames - per - second   
			
		 
		
	
		
			
			 
			 
			
			 
			
			    / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
	
		
			
				
				
				
				
					
						 
					 
				
				 
			
			 
			
			@ -47,6 +65,9 @@ int main(void)  
			
		 
		
	
		
			
			 
			 
			
			 
			
			        / /  Update   
			
		 
		
	
		
			
			 
			 
			
			 
			
			        / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
			
		 
		
	
		
			
			 
			 
			
			 
			
			        UpdateCamera ( & camera ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			        rotation  + =  0.4f ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			        distanceStatic  =  Vector3Distance ( camera . position ,  billPositionStatic ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			        distanceRotating  =  Vector3Distance ( camera . position ,  billPositionRotating ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			        / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			        / /  Draw   
			
		 
		
	
	
		
			
				
				
				
				
					
						 
					 
				
				 
			
			 
			
			@ -59,8 +80,18 @@ int main(void)  
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			                DrawGrid ( 10 ,  1.0f ) ;         / /  Draw  a  grid   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			                DrawBillboard ( camera ,  bill ,  billPosition ,  2.0f ,  WHITE ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			                / /  Draw  order  matters !   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                if  ( distanceStatic  >  distanceRotating )    
			
		 
		
	
		
			
			 
			 
			
			 
			
			                {   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                    DrawBillboard ( camera ,  bill ,  billPositionStatic ,  2.0f ,  WHITE ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                    DrawBillboardPro ( camera ,  bill ,  source ,  billPositionRotating ,  billUp ,  ( Vector2 )  { 1.0f ,  1.0f } ,  rotateOrigin ,  rotation ,  WHITE ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                }    
			
		 
		
	
		
			
			 
			 
			
			 
			
			                else   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                {   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                    DrawBillboardPro ( camera ,  bill ,  source ,  billPositionRotating ,  billUp ,  ( Vector2 )  { 1.0f ,  1.0f } ,  rotateOrigin ,  rotation ,  WHITE ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                    DrawBillboard ( camera ,  bill ,  billPositionStatic ,  2.0f ,  WHITE ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                }   
			
		 
		
	
		
			
			 
			 
			
			 
			
			                  
			
		 
		
	
		
			
			 
			 
			
			 
			
			            EndMode3D ( ) ;   
			
		 
		
	
		
			
			 
			 
			
			 
			
			
  
			
		 
		
	
		
			
			 
			 
			
			 
			
			            DrawFPS ( 10 ,  10 ) ;