[SDL] I don't know use a algorit for line

Alex Volkov avcp-sdlmail at usa.net
Sun Nov 20 15:10:24 PST 2005


Gustavo wrote:
> I have a source code with an algorit for a line, but when
> a try use it the program say: Fatal signal: Segmentation Fault
> (SDL Parachute Deployed) always

Your code that draws the line states
   diblinea(0,0,screen->w,screen->h,...)
However, the diblinea() algorithm draws a line to (x1,y1) inclusively, so it
tries to draw a pixel at (640,480) which is invalid. The actual screen
coordinates in your program range 0..639 for X and 0..479 for Y.
Thus you get a segfault when trying to access non-existent screen address
(beyond allocated range).

-Alex.






More information about the SDL mailing list