coloring object using Flood fill algorithm.

Hey all,

I’m new to opengl, need ur guys help… how to color object using flood fill algorithm… for example… I’ve draw a triangle using GL_LINE consist of 3 lines… but how to color it using the algorithm? :frowning:

glColor3f (0.0,1.0,0.0);
glBegin (GL_LINES);
glVertex2i (70,150);
glVertex2i (105,215);
glEnd ();

glColor3f (0.0,1.0,0.0);
glBegin (GL_LINES);
glVertex2i (105,215);
glVertex2i (140,150);
glEnd ();

glColor3f (0.0,1.0,0.0);
glBegin (GL_LINES);
glVertex2i (70,150);
glVertex2i (140,150);
glEnd ();

Why can’t you just render the triangle filled? You could determine the polygon that needs to be filled and then render it using GL_POLYGON or GL_TRIANGLES mode.

Actually this is part of my assignment… i just need the idea to use the algo.

thanks…

You can’t use flood fill with OpenGL, because you can’t work with individual pixels. I’m sure you misunderstood something in your assignment…

hmm… so can you’ll give me idea on how to color the triangle… before this i’ve search google n found the flood fill algo., it seemed that the idea wont solve my prob.

Actually i can only draw object using GL_LINES() and after that need to do s/thing with the object. I’ve solved that part but I don’t know on how to color the object…

glColor3f (0.0,1.0,0.0);
glBegin (GL_TRIANGLES);
glVertex2i (70,150);
glVertex2i (105,215);
glVertex2i (140,150);
glEnd ();

any other idea?

have u enable dithering?

maybe a dithered stipple?

better still, try hitting it with a matrix fragment, THEN slap it with a few good dithered stipples.

– sammy