![]() |
![]() |
![]() |
V_Sim API - Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
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
);
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.
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 |
if the light is used or not ; |
the ambient color of the light ; | |
the diffuse color of the light ; | |
the specular color of the light ; | |
the position in space of the light ; | |
a value that multiply all color values (should be in [0;1]). |
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.
the ambient identifier ; | |
the diffuse identifier ; | |
the shiningness identifier ; | |
the specular identifier ; | |
the emissivity identifier ; | |
number of used material identifiers. |
typedef struct _VisuGlLights VisuGlLights;
A short way to access _VisuGlLights objects.
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. |
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.
|
a VisuGlLights object ; |
|
a VisuGlLight object. |
Returns : |
TRUE if visu_gl_lights_apply() should be called. |
gboolean visu_gl_lights_apply (VisuGlLights *env
);
Apply all stored informations about lights to the current OpenGL context.
|
a VisuGlLights object. |
Returns : |
TRUE if the "OpenGLAskForReDraw" signal should be emitted after a call to this method. |
void visu_gl_lights_free (VisuGlLights *env
);
Free memory occupied by the given environnement.
|
a VisuGlLights object. |
GList * visu_gl_lights_getList (VisuGlLights *env
);
Retrieve the list of known VisuGlLight used by the given environnement.
|
a VisuGlLights object. |
Returns : |
a list of VisuGlLight objects. Should not be freed. [transfer none][element-type VisuGlLight*] |
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. |
VisuGlLights * visu_gl_lights_ref (VisuGlLights *env
);
Increase the ref counter.
|
a VisuGlLights object. |
Returns : |
itself. |
Since 3.7
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()
.
|
a VisuGlLights object ; |
|
a VisuGlLight object. |
Returns : |
TRUE if visu_gl_lights_apply() should be called. |
gboolean visu_gl_lights_removeAll (VisuGlLights *env
);
Empty the list of stored lights. All stored lights objects are freed.
|
a VisuGlLights object. |
Returns : |
TRUE if the visu_gl_lights_apply() should be called. |
void visu_gl_lights_unref (VisuGlLights *env
);
Decrease the ref counter, free all memory if counter reachs zero.
|
a VisuGlLights object. |
Since 3.7