Advertisement

can you help me?

Started by January 09, 2001 07:59 PM
1 comment, last by oink 23 years, 10 months ago
hello sir, sorry to bother you. i don''t know how to do the task that i''ve been assigned. can you help me with it? i was asked to draw two polygons.one polygon is inside another big one. then,i have to color one of the polygon(according to the pixel coordinate that''s been entered by the user). this where the problem comes. i''ve got to write codes where: 1)a user will state from where(which pixel) he wants to start and then the program got to fill(color)each pixel until it hits a pixel that''s been filled/colored(this means,the program has to continue until it hits the polygon lines). when it has hit a pixel that''s been colored,it will stop coloring. as a result,one of the polygons will be colored and the other will have the same color as the background. 2)then, i have to rotate either both of the polygons or one of them. i also have to provide an interface where the users could enter the coordinate from where he/she wants to start coloring. Can you provide me with the coding to do this program? I am really in need of your help. I really apprecite it. Please reply as soon as possible. Thank you a million.
This sounds like a CS class project... hehehe

Anyway, you want to color 1 pixel? Use glWritePixel(). You want to check the color? Use glReadPixel().

To rotate, use glRotatef().

I think your better off thinking it out, this is a fairly simple program to write, and besides, how else would you earn a "A"?



Advertisement
Pseudocode for a recursive aproach:

Fill( int X, int Y, CColor *Color )
{
if( GetColor( X+1, Y ) == Color )
Fill( X+1, Y, Color );
if( GetColor( X-1, Y ) == Color )
Fill( X-1, Y, Color );
if( GetColor( X, Y-1 ) == Color )
Fill( X, Y-1, Color );
if( GetColor( X, Y+1 ) == Color)
Fill( X, Y+1, Color );
}

This topic is closed to new replies.

Advertisement