light

light — Controls the use of lights in the rendering window.

Synopsis

struct              VisuGlLight;
enum                VisuGlLightMaterial;
                    VisuGlLights;
VisuGlLight *       visu_gl_light_newDefault            ();
gboolean            visu_gl_lights_add                  (VisuGlLights *env,
                                                         VisuGlLight *light);
gboolean            visu_gl_lights_apply                (VisuGlLights *env);
void                visu_gl_lights_free                 (VisuGlLights *env);
GList *             visu_gl_lights_getList              (VisuGlLights *env);
VisuGlLights *      visu_gl_lights_new                  ();
VisuGlLights *      visu_gl_lights_ref                  (VisuGlLights *env);
gboolean            visu_gl_lights_remove               (VisuGlLights *env,
                                                         VisuGlLight *light);
gboolean            visu_gl_lights_removeAll            (VisuGlLights *env);
void                visu_gl_lights_unref                (VisuGlLights *env);

Object Hierarchy

  GBoxed
   +----VisuGlLight
  GBoxed
   +----VisuGlLights

Description

One can defines several lights in OpenGL. The VisuGlLights is an object that stores several of them and that can be applied to the current OpenGL context using visu_gl_lights_apply(). The lights that are created with visu_gl_light_newDefault() are ambiant light with a white colour. The multiplier coefficient is use to soften lights when several are used together. It is used as a factor for all light parameters (ambient, diffuse...) ecept the specular one.

Details

struct VisuGlLight

struct VisuGlLight {
  gboolean enabled;
  float ambient[4];
  float diffuse[4];
  float specular[4];
  float position[4];
  float multiplier;
};

This structure is convenient to store lights as defined by OpenGL.

gboolean enabled;

if the light is used or not ;

float ambient[4];

the ambient color of the light ;

float diffuse[4];

the diffuse color of the light ;

float specular[4];

the specular color of the light ;

float position[4];

the position in space of the light ;

float multiplier;

a value that multiply all color values (should be in [0;1]).

enum VisuGlLightMaterial

typedef enum {
    VISU_GL_LIGHT_MATERIAL_AMB,
    VISU_GL_LIGHT_MATERIAL_DIF,
    VISU_GL_LIGHT_MATERIAL_SHI,
    VISU_GL_LIGHT_MATERIAL_SPE,
    VISU_GL_LIGHT_MATERIAL_EMI,
    VISU_GL_LIGHT_MATERIAL_N_VALUES
} VisuGlLightMaterial;

This enum is used to address the OpenGL parameters for light rendering.

VISU_GL_LIGHT_MATERIAL_AMB

the ambient identifier ;

VISU_GL_LIGHT_MATERIAL_DIF

the diffuse identifier ;

VISU_GL_LIGHT_MATERIAL_SHI

the shiningness identifier ;

VISU_GL_LIGHT_MATERIAL_SPE

the specular identifier ;

VISU_GL_LIGHT_MATERIAL_EMI

the emissivity identifier ;

VISU_GL_LIGHT_MATERIAL_N_VALUES

number of used material identifiers.

VisuGlLights

typedef struct _VisuGlLights VisuGlLights;

A short way to access _VisuGlLights objects.


visu_gl_light_newDefault ()

VisuGlLight *       visu_gl_light_newDefault            ();

Create a new light with default value (white color and position in the front, right, top position of the screen).

Returns :

the newly created VisuGlLight. Use g_free() to deallocate this light.

visu_gl_lights_add ()

gboolean            visu_gl_lights_add                  (VisuGlLights *env,
                                                         VisuGlLight *light);

This method adds the given light to the list of known lights declared in the given environnement. The light is not copied and should not be freed when stored in the environnement.

env :

a VisuGlLights object ;

light :

a VisuGlLight object.

Returns :

TRUE if visu_gl_lights_apply() should be called.

visu_gl_lights_apply ()

gboolean            visu_gl_lights_apply                (VisuGlLights *env);

Apply all stored informations about lights to the current OpenGL context.

env :

a VisuGlLights object.

Returns :

TRUE if the "OpenGLAskForReDraw" signal should be emitted after a call to this method.

visu_gl_lights_free ()

void                visu_gl_lights_free                 (VisuGlLights *env);

Free memory occupied by the given environnement.

env :

a VisuGlLights object.

visu_gl_lights_getList ()

GList *             visu_gl_lights_getList              (VisuGlLights *env);

Retrieve the list of known VisuGlLight used by the given environnement.

env :

a VisuGlLights object.

Returns :

a list of VisuGlLight objects. Should not be freed. [transfer none][element-type VisuGlLight*]

visu_gl_lights_new ()

VisuGlLights *      visu_gl_lights_new                  ();

Create a new VisuGlLights object. It contains no light when created. Use visu_gl_lights_add() to add new lights and visu_gl_lights_remove() to remove others.

Returns :

a newly created VisuGlLights. Use visu_gl_lights_free() to free such an object.

visu_gl_lights_ref ()

VisuGlLights *      visu_gl_lights_ref                  (VisuGlLights *env);

Increase the ref counter.

env :

a VisuGlLights object.

Returns :

itself.

Since 3.7


visu_gl_lights_remove ()

gboolean            visu_gl_lights_remove               (VisuGlLights *env,
                                                         VisuGlLight *light);

This method removes the given light from the list of known lights declared in the given environnement. The light argument is first removed and then freed by a call to g_free().

env :

a VisuGlLights object ;

light :

a VisuGlLight object.

Returns :

TRUE if visu_gl_lights_apply() should be called.

visu_gl_lights_removeAll ()

gboolean            visu_gl_lights_removeAll            (VisuGlLights *env);

Empty the list of stored lights. All stored lights objects are freed.

env :

a VisuGlLights object.

Returns :

TRUE if the visu_gl_lights_apply() should be called.

visu_gl_lights_unref ()

void                visu_gl_lights_unref                (VisuGlLights *env);

Decrease the ref counter, free all memory if counter reachs zero.

env :

a VisuGlLights object.

Since 3.7