Top | ![]() |
![]() |
![]() |
![]() |
LwShader makes it easy to load and create OpenGL shaders. You can avoid using this structure
if you use the lw_program_create_and_attach_shader()
function.
LwShader is not finished yet. It is possible that parts of this type will be changed in a future version of LiveWallpaper.
Example 8. Using LwShader
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
GError *error = NULL; LwProgram *prog = g_object_new(LW_TYPE_PROGRAM, NULL); LwShader *shader = lw_shader_new_from_uri("/path/to/shader.glsl", GL_FRAGMENT_SHADER, &error); if(error != NULL) { g_warning("Could not load fragment shader: %s", error->message); g_error_free(error); return; } else { lw_shader_compile(shader); lw_program_attach_shader(prog, shader); } g_object_unref(shader); lw_program_link(prog); ... |
LwShader * lw_shader_new_from_uri (const gchar *uri
,guint type
);
Creates a new shader and stores the content of the file as source code in
in the shader. This function will return NULL
if it cannot get the source
code from the specified file.
The uri has to begin with the protocol, by instance file:// or resource://
uri |
The uri of the file containing the shader's source code |
|
type |
GL_VERTEX_SHADER or GL_FRAGMENT_SHADER |
A new LwShader or NULL
if an error occured. You should use
g_object_unref()
to free the LwShader.
Since: 0.5
LwShader * lw_shader_new_from_string (const gchar *source
,guint type
);
Creates a new shader and stores the source code in the shader.
Since: 0.4
gboolean
lw_shader_compile (LwShader *self
);
Compiles the source code of the shader. This function prints a warning if the compilation of the shader fails.
Since: 0.4