Top | ![]() |
![]() |
![]() |
![]() |
void | lw_buffer_bind () |
gpointer | lw_buffer_get_data () |
guint | lw_buffer_get_name () |
guint | lw_buffer_get_target () |
guint | lw_buffer_get_usage () |
LwBuffer * | lw_buffer_new () |
void | lw_buffer_set_data () |
void | lw_buffer_set_sub_data () |
void | lw_buffer_unbind () |
LwBuffer is not finished yet. It is possible that parts of this type will be changed in a future version of LiveWallpaper.
The LwBuffer class provides a wrapper for the OpenGL buffer functions. It takes care of different OpenGL versions and makes the usage of an OpenGL buffer easy.
Example 10. Using LwBuffer
float vertices_data[] = { ... }; int vertices_count = 3; LwBuffer *vertices = lw_buffer_new(GL_STATIC_DRAW); lw_buffer_set_data(vertices, 2 * vertices_count * sizeof(float), vertices_data); // Use the vertices buffer as an attribute for a LwProgram prog lw_program_enable(prog); lw_program_set_attribute(prog, "vertices", LW_GLSL_TYPE_VEC2, vertices); glDrawArrays(GL_TRIANGLES, 0, vertices_count); lw_program_disable(prog);
The noise plugin makes use of the LwBuffer object. Take a look at the source code of that plugin to see a full working example for LwBuffer and LwProgram.
void
lw_buffer_bind (LwBuffer *self
);
Binds this LwBuffer object to the target returned by lw_buffer_get_target()
. This function
calls glBindBuffer
to bind the buffer.
Since: 0.5
gpointer lw_buffer_get_data (LwBuffer *self
,guint offset
,guint size
);
Internally this function uses glGetBufferSubData.
This method binds the buffer using lw_buffer_bind()
, but does not unbind it. After this operation
this LwBuffer is still bound to its target.
self |
A LwBuffer |
|
offset |
An offset from the beginning of the data store in bytes |
|
size |
The size in bytes of the data being returned |
A part or all of the data currently stored in this LwBuffer. Use g_free()
to free memory allocated for the data.
[transfer full]
Since: 0.5
guint
lw_buffer_get_target (LwBuffer *self
);
If this buffer is created by lw_buffer_new()
, then the target will be GL_ARRAY_BUFFER.
Since: 0.5
LwBuffer *
lw_buffer_new (guint usage
);
Creates a new LwBuffer which uses the specified usage pattern. The buffer is created using the glGenBuffers function. The usage pattern can be one of the following: GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
Since: 0.5
void lw_buffer_set_data (LwBuffer *self
,guint size
,gpointer data
);
This method binds the buffer specified by self
using lw_buffer_bind()
and copies the data specified
by data
into the buffer. This operation creates a new data store for the buffer of the size size
and also tells OpenGL about the desired usage pattern specified by lw_buffer_new()
. To update the
data in the buffer lw_buffer_set_sub_data()
can be used.
This method binds the buffer using lw_buffer_bind()
, but does not unbind it. After this operation
this LwBuffer is still bound to its target.
This function uses glBufferData to copy the specified data to the buffer's data store.
Since: 0.5
void lw_buffer_set_sub_data (LwBuffer *self
,guint offset
,guint size
,gpointer data
);
Replaces size
bytes of the buffer's data store with the memory found at data
. The
replacement starts after offset
bytes from the beginning of the data store.
This method binds the buffer using lw_buffer_bind()
, but does not unbind it. After this operation
this LwBuffer is still bound to its target.
Internally this function uses glBufferSubData.
self |
A LwBuffer |
|
offset |
An offset from the beginning of the data store in bytes |
|
size |
The size in bytes of the data that will be copied |
|
data |
A pointer to the data that will be copied |
Since: 0.5
void
lw_buffer_unbind (LwBuffer *self
);
Unbinds the LwBuffer previously bound by lw_buffer_bind()
. This function calls
to bind 0 to the target returned by lw_buffer_get_target()
. This unbinds every currently
bound buffer even if it is not the one specified by self
.
Since: 0.5
“target”
property“target” guint
The target to which the buffer will be bound to when calling lw_buffer_bind()
.
If this buffer is created by lw_buffer_new()
, then the target will be GL_ARRAY_BUFFER.
Flags: Read / Write / Construct Only
Default value: 34962
Since: 0.5