manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.3.2 Lighting (Pure C)

There are several functions for setup lighting. The general function is mgl_set_light() which switch on/off the lighting for overall plot. It influence only for graphics which created after mgl_set_light() call. Generally MathGL support up to 10 independent light sources. But in OpenGL mode only 8 of light sources is used due to OpenGL limitations. The position, color, brightness of each light source can be set separately. By default only one light source is active. It is source number 0 with white color, located at top of the plot.

C function: void mgl_set_light (HMGL gr, int enable)

Sets the using of light on/off for overall plot. It is recommended to call this function before any plotting command. Default value is lightning off.

C function: void mgl_set_light_n (HMGL gr, int n, int enable)

Switch on/off n-th light source separately.

C function: void mgl_add_light (HMGL gr, int n, float x, float y, float z, char c)
C function: void mgl_add_light_rgb (HMGL gr, int n, float x, float y, float z, int infty, float r, float g, float b, float i)

The function adds a light source with identification n at position {x, y, z}. The color of light is defined by character c or by RGB values {r, g, b}. The brightness of light is i which must be in range [0,1]. Flag infty=true puts the source to infinite distance (for the faster drawing). It is recommended to call this function before any plotting command.

C function: void mgl_set_ambbr (HMGL gr, float bright)

Sets the brightness of ambient light. The value should be in range [0,1]. Initial value is 0.5. It is recommended to call this function before any plotting command.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2026
Individual documents may contain additional copyright information.