Math Calculation for Diffuse Light Effect

Hi,

I have a question about diffuse light. I have a triangle with a normal and a light. I supposed to simulate a diffuse light and a simple (flat?) shading on the triangle. The light has property color. So it may affect the color of the triangle

Anyone got a formula for this calculation? And I cant use OpenGL lib to simulate this. I only able to draw a triangle and decide the color of the triangle based on the calculation.

Thanks

i assume you want to use GLSL for diffuse lighting. google “diffuse GLSL”.