SHARE
TWEET

Untitled

a guest Jun 25th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void LINE_PlotPoint(SDL_Surface * surface,int x,int y, double alpha)
  2. {
  3.     Uint32 *pixels = (Uint32 *)surface->pixels;
  4.     Uint32 pixel=SYS_GetForegroundColor();
  5.  
  6.     Uint8 a= alpha*255;
  7.  
  8.     pixel&=~amask;
  9.     pixel |= a;
  10.  
  11.     pixels[ ( y * surface->w ) + x ] =pixel;
  12. }
  13.      
  14. if(event.type==SDL_MOUSEMOTION)
  15. {
  16.     SDL_GetMouseState(&i,&j);
  17.     i-=grect.x;
  18.     j-=grect.y;
  19.     TOOL_DrawLine(tempSurface,x,y,i,j,1);//Xiaolin Wu's line algorithm
  20.  
  21.     if(tempTexture)
  22.     {
  23.         SDL_DestroyTexture(tempTexture);
  24.     }
  25.  
  26.     tempTexture=TOOL_CreateLineTexture(tempSurface,&srect,&drect);//create texture from surface and calculating rect(src & dest)
  27.     if(tempTexture==NULL)
  28.     {
  29.         puts("error");
  30.     }
  31.     SDL_SetTextureBlendMode(tempTexture,SDL_BLENDMODE_BLEND);
  32.  
  33.  
  34.     SDL_FillRect(tempSurface,NULL,NULL);//delete pixel from surface (no need for it)
  35.  
  36.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top