PDA

View Full Version : coloring object using Flood fill algorithm.



e_zoo_din
04-12-2006, 03:53 AM
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? :(


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 ();

Zengar
04-12-2006, 03:59 AM
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.

e_zoo_din
04-12-2006, 04:31 AM
Actually this is part of my assignment... i just need the idea to use the algo.


thanks..

Overmind
04-12-2006, 04:36 AM
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...

e_zoo_din
04-12-2006, 04:58 AM
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...

RigidBody
04-12-2006, 07:10 AM
glColor3f (0.0,1.0,0.0);
glBegin (GL_TRIANGLES);
glVertex2i (70,150);
glVertex2i (105,215);
glVertex2i (140,150);
glEnd ();

e_zoo_din
04-12-2006, 08:02 AM
any other idea?

04-12-2006, 08:11 AM
have u enable dithering?

04-12-2006, 08:21 AM
maybe a dithered stipple?

04-12-2006, 08:30 AM
better still, try hitting it with a matrix fragment, THEN slap it with a few good dithered stipples.

-- sammy