Hi there.
I have a simple example and complicated(for me) question
Lets glimpse at example
glBegin(GL_TRIANGLES);
glColor3f(1.0,0.0,0.0);
glVertex3f( 0.0, 1.0, 0.0);
glColor3f(0.0,1.0,0.0);
glVertex3f(1.0, 1.0, 0.0);
glColor3f(0.0,0.0,1.0);
glVertex3f( 2.0, 1.0, 0.0);
glEnd();
Trivial, isnâ€™t it?
In result i got triangle, which is filled with smooth color  Red, Green, Blue, all those colors mix together in the middle of the center
And now the questions. What is the formula, who describe colorâ€™s mixing behaviour?
Thanks in advance for any response!
Regards!
Del.
Thanks for your response MMMovania !
U see, i am writing research work about the OpenGL and i have to describe algorithms about various OpenGL processes. i have to find out whats going on in glColor3f function and how he makes that smooth colors transformation.
Can u throw me, please, any links of documentation about this?
Maybe u also know any site, where is explained various opengl functions algorithms?
Thanks MMMovania,
Regards!
Del.
Maybe anyone else can helpâ€¦ ?
given 3 vertices v1, v2, v3 of a tria with function values f1, f2, f3. to calculate the function value at a point p:

connect p with each of the three vertices, thereby dividing the tria into three subtrias: T1 = (p, v2, v3), T2 = (p, v1, v3), T3 = (p, v1, v2)

calculate the area A1, A2, A3 for the subtrias T1, T2, T3 and the area A of the original tria.

the interpolated function value at p is fÂ§ = A1/Af1 + A2/Af2 + A3/A*f3
â€¦iâ€™m not absolutely sure, but i think this works only if point p lies within the original triaâ€¦
â€¦trying to insert an image â€¦
Hei, thanks for your reply RigidBody!
This helps alot, but have still question.
How OpenGL choose that P points locality? As i understand, P point is located in that place, where all colours come together and colours from one subtrias wont cross the border to nearest subtrias area.
And P point is not in vertex bisectors point of intersection.
glBegin(GL_TRIANGLES);
glColor3f(1.0,1.0,1.0);
glVertex3f( 0.0, 1.0, 0.0);
glColor3f(1.0,1.0,1.0f);
glVertex3f(1.0, 1.0, 0.0);
glColor3f(0.8f,0.3f,0.5f);
glVertex3f( 1.0, 1.0, 0.0);
glEnd();
The pink colour is almost filled whole triangle.
What do you think RigidBody?
Thanks and Regards!
Del.
ok, look at this:
[img]http://www.troesener.de/scr/TriaOnScreen.gif[/img]
you tell OpenGL what kind of view you want (glOrtho or gluPerspective, for example) and where you look at (with gluLookAt).
then you define the triangle vertices in 3d space using glVertex3f (â€¦). OpenGL maps the vertices to pixel coordinates on the screen. in this example, we have a 1024x768 screen.
when the pixel coordinates of the 3 corner vertices have been calculated ((500,0) for vertex 1, for example). OpenGL uses an algorithm to determine which of all the screen pixels lie within the triangle.
and finally, for EACH pixel p which lies within the triangle on the screen, the color value is interpolated using the formula which i wrote down above.
Roger RigidBody!
Thanks for your assistance!
youâ€™re welcome although i hope that i didnâ€™t just do your home work for you, did i?
Wellâ€¦ not reallyâ€¦ i am writing bachelor about OpenGL. And i have to explain various OpenGL algorithms
your reply saved hours for me and those hours are invaluable becouse of all other for me unexplored mathematical OpenGL solutions.
So probably soon i will return with another mathematical questionâ€¦
Thanks RigidBody!
Ragards!
Del.