tisa
November 9th, 2006, 07:13 AM
Im getting segmentation fault when im running the code given below:
Can anyone tell me why it happens and how can i solve it?
void floodfill(float pointx,float pointy,float f[3],float o[3])
{
float intensity,*pixels;
glReadPixels(pointx,pointy,1.0,1.0,GL_RGB,GL_FLOAT,pixels);
if(*pixels==o[0] && *(pixels+1)==o[1] && *(pixels+2)==o[2])
{
glFlush();
glBegin(GL_POINTS);
glColor3fv(f);
glVertex2i(pointx,pointy);
glEnd();
glFlush();
floodfill(pointx+1,pointy,f,o);
floodfill(pointx,pointy+1,f,o);
floodfill(pointx-1,pointy,f,o);
floodfill(pointx,pointy-1,f,o);
}
}
Can anyone tell me why it happens and how can i solve it?
void floodfill(float pointx,float pointy,float f[3],float o[3])
{
float intensity,*pixels;
glReadPixels(pointx,pointy,1.0,1.0,GL_RGB,GL_FLOAT,pixels);
if(*pixels==o[0] && *(pixels+1)==o[1] && *(pixels+2)==o[2])
{
glFlush();
glBegin(GL_POINTS);
glColor3fv(f);
glVertex2i(pointx,pointy);
glEnd();
glFlush();
floodfill(pointx+1,pointy,f,o);
floodfill(pointx,pointy+1,f,o);
floodfill(pointx-1,pointy,f,o);
floodfill(pointx,pointy-1,f,o);
}
}