Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.
Shader
Shaders can be use to produce special effects directly on the system
graphic card instead of producing them with the CPU with a t_bunny_pixelarray.
Graphic cards work incredibely fast compared to the main CPU when
it cames to graphics.
Shaders are programmed with the GLSL programming language, which is
syntaxically close to C but have its specificities.
You can find example of shaders in the LibLapin repository.
The shader module header is lapin/shader.h
Description
  This structure describes a complete transformation: it allows
you to set in a single time an origin shift, a translation, a scale
change or a rotation setting.
INDEX
Description
  Return if shader are available on the current system.
Return value
Return true if shader can work on the current system.
INDEX
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the
"ressource" and "graphics" label.
INDEX
Description
  Load into the sent reserved shader a vertex configuration
from a file and a fragment configuration from another one.
Parameters
-
t_bunny_shader *shader:
  The shader to configure.
-
const char *vertex_file:
  The vertex shader configuration file. NULL can be sent
to use a default vertex shader to only allow 2D edition
throught the shader described in fragment_file.
-
const char *fragment_file:
  The fragment shader configuration file.
Return value
This function returns true or false depending of its success.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the
"ressource",
"graphics"
and/or
"syntax"
label.
INDEX
Description
  Load into the sent reserved shader a vertex configuration
from a string and a fragment configuration from another one.
Parameters
-
t_bunny_shader *shader:
  The shader to configure.
-
const char *vertex_string:
  The vertex shader configuration. NULL can be sent
to use a default vertex shader to only allow 2D edition
throught the shader described in fragment_file.
-
const char *fragment_string:
  The fragment shader configuration.
Return value
This function returns true or false depending of its success.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the
"ressource",
"graphics"
and/or
"syntax"
label.
INDEX
Description
  In most vertex and fragment shaders, we can find parameters
that must be sent from the cpu-side program. This function serve
this purpose: it allows you to sent values inside the graphic card
from your program.
Parameters
-
t_bunny_shader *shader:
  The shader to configure.
-
const char *variable_name:
  The name of the variable you want to set inside the shader.
-
t_bunny_variable_type type:
  Describe what the variadic part of this function will receive
as parameter.
-
...:
  Variables as described by type. Please pay attention to
what you send!
For example: if you sent BVT_1_FLOAT as type but then
give an int as parameter, no conversion will occurs! The int
will be interpreted as it as a float and it will not work
as you expect.
Use cast if neccessary.
INDEX
Description
  Delete the sent shader.
INDEX
Description
  This enumeration is used by t_bunny_screan_tweak to help in color
swaping operations. The original order of colors is red, green and
then blue, consider the name of symbols in this enumeration to
choose the one that suit you.
INDEX
Description
  This enumeration is used by t_bunny_screan_tweak to
configure the color of the additional noise over the picture.
Symbols
-
BNC_COLOR_NOISE:
  Add noise of any color over the picture.
-
BNC_GRAY_NOISE:
  Add noise of any kind of gray over the picture.
-
BNC_BLACK_AND_WHITE_NOISE:
  Add perfectly black or perfectly white noise over the picture.
INDEX
Description
  This enumeration is used by t_bunny_screan_tweak to
configure the shape of the additional noise over the picture.
Symbols
-
BNT_NO_NOISE:
  There is no noise.
-
BNT_PIXEL_NOISE:
  Noise is different on every pixel.
-
BNT_LINE_NOISE:
  Noise is different on every horizontal line.
-
BNT_ROW_NOISE:
  Noise is different on every vertical line.
INDEX
Attributes
-
float blur_level:
  The blur that will be applied to the sent picture.
-
float luminosity:
  A color coefficient to be multiplied with all color component.
-
double color[3]:
  Color coefficients to be multiplied with red, green and blue
color components, case after case.
-
t_bunny_color_blind_tweak color_blind:
  Color component shifting.
-
bool invert_color:
  Invert color.
-
bool gray_scale:
  Set to zero to stay in colors. Precise the amount of gray
shade you want to be displayed. 1 turns the whole screen black.
2 turns the whole screen pure black and white. 255 turns the whole
picture in full grayscale.
Currently, the effect is not working as expected.
-
t_bunny_noise_color noise_color:
  Define the color of the additionnal noise.
-
t_bunny_noise_tpye noise_type:
  Set the noise graphic type.
-
double noise_strenght:
  The noise opacity.
INDEX
Description
  Read the sent structure and generate the associated shader.
Multiples calls to
bunny_screen_tweak_shader will not generate
several shader: the returned one is kept in memory and reconfigured
each time. It is automatically freed when your program exit, but
you can force its release by sending
NULL as
bst.
Return value
This function returns a valid t_bunny_shader pointer on success.
NULL on failure. If you send NULL as bst, then it will
always return NULL.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the
"ressource",
"graphics"
and/or
"shader"
label.
INDEX
Description
  This function set all fields inside the bst structure with default values.
Those default values make the screen tweak shader completly useless: it won't
change anything to what is displayed.
This is useful so you can only use a single transformation or several but
don't have to neuter the one you do not use yourself.
INDEX
Attributes
-
bool $sactive:
  Is the light described in this structure active or not?
If not, it is useless to set other fields in this structure.
-
float x:
  The position on X of the light on screen.
-
float y:
  The position on Y of the light on screen.
-
float z:
  The position on Z in space. This modulates the impact
of the light by impacting reflections.
-
t_bunny_color light_color:
  The light color on illuminated space.
-
float light_attenuation:
  The attenuation of the light accordingly to the distance.
0.5 is a good reference value.
-
t_bunny_color ambient_color:
  The color of space around the light.
-
float ambient_depth:
  The position on the Z axis of the ambient light. 0.4 is a good
reference value.
-
float ambient_attenuation:
  The attenuation of the light accordingly to the distance.
4.0 is a good reference value.
-
t_bunny_color specular_color:
  The color of heavily enlighted areas. The specular_color
is quite impacted by the color on the t_bunny_normal_map specular_map.
-
float specular_depth:
  The position on the Z axis of the ambient light. 0.3 is a good
reference value.
-
float specular_attenuation:
  The attenuation of the light accordingly to the distance.
1.0 is a good reference value.
INDEX
Description
  This structure describe a dynamic lighting shader.
It includes ressources you have to define and not only
simple datas. By sending it to
bunny_normal_map_shader,
you will configure or reconfigure a complete shader.
INDEX
Description
  Read the sent structure and generate the associated shader.
Multiples calls to
bunny_normal_map_shader will not generate
several shader: the returned one is kept in memory and reconfigured
each time. It is automatically freed when your program exit, but
you can force its release by sending
NULL as
nm.
Return value
This function returns a valid t_bunny_shader pointer on success.
NULL on failure. If you send NULL as bst, then it will
always return NULL.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the
"ressource",
"graphics"
and/or
"shader"
label.
INDEX
Description
  This structure describe a color spreading shader.
A color spreading shader is a shader that will make a specified color
spread over a picture.
Attributes
-
t_bunny_color color[2]:
  This field is the color that will be used when the t_bunny_spreading
is blitted over any target with bunny_blit_shader.
Two colors are needed as you can flip from one to the other.
If you need more than two colors, you can deduce from the current_buffer,
field the color which is unused and can be modified.
-
int speed:
  This field is the speed of the spreading: it is purely the amount of
time the shader is called each time you can bunny_blit_spreading.
-
t_bunny_picture *layout:
  This field contains the shape the color can spread on. Pure opaque black
prevents the color to spread. Any other color allow it.
-
size_t source_len:
  How many color source there is to allow spreading. If there is no source
and the buffer is clean, no spreading will occur.
-
t_bunny_position sources[128]:
  The position of every source of color that will be spread. Sources should
be on non opaque black when positioned on layout.
-
bool random:
  Is the spreading random or not? A non random spreading is regular. It keeps,
the previous shape. If sources are isolated dots, diamond shapes will appeirs.
If random is true, the spreading will be more organic.
-
t_bunny_picture *alpha_buffer:
  You must set this field to NULL.
-
t_bunny_picture *spread_buffer[2]:
  You must set those fields to NULL.
-
int current_buffer:
  You must set this field to 0.
INDEX
Return value
This function returns a valid t_bunny_shader pointer on success.
NULL on failure. If you send NULL as bst, then it will
always return NULL.
Error values and logs
On error, $Vbunny_errno is set to:
Logs written by this function are tagged with the
"ressource",
"graphics"
and/or
"shader"
label.
INDEX
Description
  This function spread the color inside the matching buffer and draw the result
inside the sent buffer at the sent position.
Note that
t_bunny_clipable properties of
layout can be used to transform
the drawing, like the clip on bunny_blit.
INDEX
Description
  This function terminate the color spreading by filling enterely the inside
buffer with the layout.
INDEX
Description
  Flip the color and buffer of the sent spreading effect.
INDEX