hsencan

03-03-2012, 01:18 PM

Let's say I have a triangle. Each vertex of that triangle has a color value, inside of that triangle the colors were interpolated.

a well known example:

http://www.packtpub.com/sites/default/files/Article-Images/4767OS_01_04.png

I wanna a draw a circle or ellipse outside of this triangle and paint the unpainted portion of this ellipse by interpolating the colors of the triangle.

What I mean is FROM the borders of the circle TO the borders of triangle there needs to be an interpolation logic. We can assume the borders of the ellipse has a color value equal to the blue.

To Be more clear, at the lower left corner of the circle I have a blue value. And inside of the circle is colorless until I meet the lower left corner of the triangle which is red. From that blue to red there needs to be an interpolation. This process needs to be done for every pixel of the circle.

Here is the code for how I draw the circle and triangle:

glBegin(GL_TRIANGLES);

glColor3f(1.0, 0.0, 0.0);

glVertex3f( 0.0f, 1.0f, 0.0f);

glColor3f(0.0, 1.0, 0.0);

glVertex3f(-1.0f,-1.0f, 0.0f);

glColor3f(0.0, 0.0, 1.0);

glVertex3f( 1.0f,-1.0f, 0.0f);

glEnd();

const float DEG2RAD = 3.14159/180;

glBegin(GL_LINE_LOOP);

for (int i=0; i < 360; i++)

{

float degInRad = i*DEG2RAD;

glVertex2f(cos(degInRad)*2.0f,sin(degInRad)*2.0f);

}

glEnd();

Any ideas?

a well known example:

http://www.packtpub.com/sites/default/files/Article-Images/4767OS_01_04.png

I wanna a draw a circle or ellipse outside of this triangle and paint the unpainted portion of this ellipse by interpolating the colors of the triangle.

What I mean is FROM the borders of the circle TO the borders of triangle there needs to be an interpolation logic. We can assume the borders of the ellipse has a color value equal to the blue.

To Be more clear, at the lower left corner of the circle I have a blue value. And inside of the circle is colorless until I meet the lower left corner of the triangle which is red. From that blue to red there needs to be an interpolation. This process needs to be done for every pixel of the circle.

Here is the code for how I draw the circle and triangle:

glBegin(GL_TRIANGLES);

glColor3f(1.0, 0.0, 0.0);

glVertex3f( 0.0f, 1.0f, 0.0f);

glColor3f(0.0, 1.0, 0.0);

glVertex3f(-1.0f,-1.0f, 0.0f);

glColor3f(0.0, 0.0, 1.0);

glVertex3f( 1.0f,-1.0f, 0.0f);

glEnd();

const float DEG2RAD = 3.14159/180;

glBegin(GL_LINE_LOOP);

for (int i=0; i < 360; i++)

{

float degInRad = i*DEG2RAD;

glVertex2f(cos(degInRad)*2.0f,sin(degInRad)*2.0f);

}

glEnd();

Any ideas?