|
openwallpaper
|
API exposed by OpenWallpaper host application (wallpaperd). More...
Data Structures | |
| struct | ow_vertex_buffer_id |
| struct | ow_index_buffer_id |
| struct | ow_texture_id |
| struct | ow_sampler_id |
| struct | ow_vertex_shader_id |
| struct | ow_fragment_shader_id |
| struct | ow_pipeline_id |
| struct | ow_render_pass_info |
| struct | ow_texture_info |
| struct | ow_texture_update_destination |
| struct | ow_sampler_info |
| struct | ow_vertex_binding_info |
| struct | ow_vertex_attribute |
| struct | ow_blend_mode |
| struct | ow_pipeline_info |
| struct | ow_texture_binding |
| struct | ow_bindings_info |
Functions | |
| void | init () |
| void | update (float delta) |
| void | ow_begin_copy_pass () |
| void | ow_end_copy_pass () |
| void | ow_begin_render_pass (const ow_render_pass_info *info) |
| void | ow_end_render_pass () |
| ow_vertex_buffer_id | ow_create_vertex_buffer (uint32_t size) |
| ow_index_buffer_id | ow_create_index_buffer (uint32_t size, bool wide) |
| void | ow_update_vertex_buffer (ow_vertex_buffer_id buffer, uint32_t offset, const void *data, uint32_t size) |
| void | ow_update_index_buffer (ow_index_buffer_id buffer, uint32_t offset, const void *data, uint32_t size) |
| ow_texture_id | ow_create_texture (const ow_texture_info *info) |
| ow_texture_id | ow_create_texture_from_image (const uint8_t *image, size_t size, const ow_texture_info *info) |
| void | ow_update_texture (const void *data, uint32_t pixels_per_row, const ow_texture_update_destination *dest) |
| void | ow_generate_mipmaps (ow_texture_id texture) |
| ow_sampler_id | ow_create_sampler (const ow_sampler_info *info) |
| ow_vertex_shader_id | ow_create_vertex_shader (const uint8_t *bytecode, size_t size) |
| ow_fragment_shader_id | ow_create_fragment_shader (const uint8_t *bytecode, size_t size) |
| ow_pipeline_id | ow_create_pipeline (const ow_pipeline_info *info) |
| void | ow_push_vertex_uniform_data (uint32_t slot, const void *data, uint32_t size) |
| void | ow_push_fragment_uniform_data (uint32_t slot, const void *data, uint32_t size) |
| void | ow_render_geometry (ow_pipeline_id pipeline, const ow_bindings_info *bindings, uint32_t vertex_offset, uint32_t vertex_count, uint32_t instance_count) |
| void | ow_render_geometry_indexed (ow_pipeline_id pipeline, const ow_bindings_info *bindings, uint32_t index_offset, uint32_t index_count, uint32_t vertex_offset, uint32_t instance_count) |
| void | ow_get_screen_size (uint32_t *width, uint32_t *height) |
| uint32_t | ow_get_mouse_state (float *x, float *y) |
| void | ow_get_audio_spectrum (float *data, size_t length) |
| const char * | ow_get_option (const char *name) |
| void | ow_free_vertex_buffer (ow_vertex_buffer_id id) |
| void | ow_free_index_buffer (ow_index_buffer_id id) |
| void | ow_free_texture (ow_texture_id id) |
| void | ow_free_sampler (ow_sampler_id id) |
| void | ow_free_vertex_shader (ow_vertex_shader_id id) |
| void | ow_free_fragment_shader (ow_fragment_shader_id id) |
| void | ow_free_pipeline (ow_pipeline_id id) |
API exposed by OpenWallpaper host application (wallpaperd).
OpenWallpaper scene is a directory containing a scene.wasm WebAssembly module and any asset files it needs. The scene module must implement and export functions init() (called once when initializing) and update() (called each frame and should update/redraw the scene). Scene module can use all extern functions from openwallpaper.h.
When you run the scene by passing scene.wasm path to wallpaperd, the scene root is the directory containing that file. Module has read-only access to all files in the scene root through standard C file I/O API (fopen, fread, etc.). Standard input and output are also available and will be forwarded to the host application.
| struct ow_vertex_buffer_id |
A handle pointing to host-managed vertex buffer. Existing vertex buffer's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_index_buffer_id |
A handle pointing to host-managed index buffer. Existing index buffer's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_texture_id |
A handle pointing to host-managed GPU texture. Existing texture's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_sampler_id |
A handle pointing to host-managed GPU sampler. Existing sampler's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_vertex_shader_id |
A handle pointing to host-managed vertex shader. Existing vertex shader's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_fragment_shader_id |
A handle pointing to host-managed fragment shader. Existing fragment shader's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_pipeline_id |
A handle pointing to host-managed GPU pipeline object. Existing pipeline's id is never zero, this value is reserved to act as non-existent object.
| Data Fields | ||
|---|---|---|
| uint32_t | id | |
| struct ow_render_pass_info |
A structure specifying render pass parameters.
| Data Fields | ||
|---|---|---|
| ow_texture_id | color_target | ID of color target texture. Setting it to 0 means render target is screen. |
| bool | clear_color |
If true, render pass will clear color target with clear_color_rgba. If false, texture target keeps its previous data, screen target data is undefined |
| float | clear_color_rgba[4] | RGBA color to clear color target with. |
| ow_texture_id | depth_target | ID of depth target texture. |
| bool | clear_depth |
If true, render pass will clear depth target with clear_depth_value. If false, target keeps its previous data |
| float | clear_depth_value | Value to clear depth target with. |
| struct ow_texture_info |
A structure specifying texture parameters.
| Data Fields | ||
|---|---|---|
| uint32_t | width | Width of texture in pixels. |
| uint32_t | height | Height of texture in pixels. |
| uint32_t | mip_levels | Number of mip levels. |
| ow_texture_format | format | Pixel format of texture. |
| bool | render_target | If true, texture can be used as render target. |
| struct ow_texture_update_destination |
A structure specifying rectangular texture fragment to update in ow_update_texture.
| Data Fields | ||
|---|---|---|
| ow_texture_id | texture | ID of texture to update. |
| uint32_t | mip_level | Mip level to update, must be less than texture's mip_levels. |
| uint32_t | x | Left offset of destination rectangle. |
| uint32_t | y | Top offset of destination rectangle. |
| uint32_t | w | Width of destination rectangle. |
| uint32_t | h | Height of destination rectangle. |
| struct ow_sampler_info |
A structure specifying sampler parameters.
| Data Fields | ||
|---|---|---|
| ow_filter_mode | min_filter | Minification filter. |
| ow_filter_mode | mag_filter | Magnification filter. |
| ow_filter_mode | mip_filter | Mipmap filter. |
| ow_wrap_mode | wrap_x | Wrap mode for X axis. |
| ow_wrap_mode | wrap_y | Wrap mode for Y axis. |
| uint32_t | anisotropy | Anisotropy level, clamped to the maximum supported value. |
| struct ow_vertex_binding_info |
A structure specifying vertex buffer binding info.
| struct ow_vertex_attribute |
A structure specifying vertex attribute.
| Data Fields | ||
|---|---|---|
| uint32_t | location | The location of the attribute in vertex shader. |
| ow_attribute_type | type | The type of the attribute. |
| uint32_t | slot | The binding slot of the associated vertex buffer. |
| size_t | offset | The offset of the attribute in bytes from the start of the vertex element. |
| struct ow_blend_mode |
A structure specifying blend mode of a color target.
| Data Fields | ||
|---|---|---|
| bool | enabled | Whether blending is enabled. |
| ow_blend_factor | src_color_factor | Value to be multiplied by the source RGB value. |
| ow_blend_factor | dst_color_factor | Value to be multiplied by the destination RGB value. |
| ow_blend_operator | color_operator | Color blending operator. |
| ow_blend_factor | src_alpha_factor | Value to be multiplied by the source alpha value. |
| ow_blend_factor | dst_alpha_factor | Value to be multiplied by the destination alpha value. |
| ow_blend_operator | alpha_operator | Alpha blending operator. |
| struct ow_pipeline_info |
A structure specifying pipeline parameters.
| Data Fields | ||
|---|---|---|
| const ow_vertex_binding_info * | vertex_bindings | A pointer to an array of vertex buffer bindings. |
| uint32_t | vertex_bindings_count | The number of vertex buffer bindings in the array. |
| const ow_vertex_attribute * | vertex_attributes | A pointer to an array of vertex attributes. |
| uint32_t | vertex_attributes_count | The number of vertex attributes in the array. |
| ow_texture_format | color_target_format | The pixel format of the color target texture. |
| ow_vertex_shader_id | vertex_shader | ID of vertex shader to use. |
| ow_fragment_shader_id | fragment_shader | ID of fragment shader to use. |
| ow_blend_mode | blend_mode | The blend mode to use. |
| ow_depth_test_mode | depth_test_mode | The depth test mode to use. |
| bool | depth_write | If true, depth test will update the depth target texture. |
| ow_topology | topology | The vertex topology to use. |
| ow_cull_mode | cull_mode | The cull mode to use. |
| struct ow_texture_binding |
A structure specifying a texture binding.
| Data Fields | ||
|---|---|---|
| uint32_t | slot | The slot of the texture in shader. |
| ow_texture_id | texture | ID of the texture to bind. |
| ow_sampler_id | sampler | ID of the sampler to use for this texture. |
| struct ow_bindings_info |
A structure specifying bindings for draw call.
| Data Fields | ||
|---|---|---|
| const ow_vertex_buffer_id * | vertex_buffers | A pointer to an array of vertex buffer IDs. |
| uint32_t | vertex_buffers_count | The number of vertex buffer IDs in the array. |
| ow_index_buffer_id | index_buffer | ID of the index buffer. |
| const ow_texture_binding * | texture_bindings | A pointer to an array of texture bindings. |
| uint32_t | texture_bindings_count | The number of texture bindings in the array. |
| enum ow_texture_format |
| enum ow_wrap_mode |
| enum ow_filter_mode |
| enum ow_attribute_type |
| enum ow_blend_factor |
| enum ow_blend_operator |
| enum ow_depth_test_mode |
| enum ow_topology |
| enum ow_cull_mode |
| enum ow_mouse_button |
| void init | ( | ) |
A user-implemented function that is called once when scene is initializing.
| void update | ( | float | delta | ) |
A user-implemented function that is called each frame and should update/redraw the scene.
| delta | Time elapsed since the last frame in seconds. You should multiply all the scene movements by this value in order to make your scene framerate independent |
|
extern |
Begins a copy pass. Can be called only if no pass is currently active, panics elsewhere.
|
extern |
Ends a copy pass. Can be called only if a copy pass is currently active, panics elsewhere.
|
extern |
Begins a render pass. Can be called only if no pass is currently active, panics elsewhere.
| info | Render pass parameters |
|
extern |
Ends a render pass. Can be called only if a render pass is currently active, panics elsewhere.
|
extern |
Creates a vertex buffer of given size.
| size | Buffer size in bytes |
|
extern |
Creates an index buffer of given size. If wide is true, the buffer will be created with 32-bit indices, otherwise with 16-bit indices.
| size | Buffer size in bytes |
| wide | Whether to use 32-bit indices |
|
extern |
Overwrites vertex buffer data subsegment beginning at offset with size bytes from data. Can be called only if copy pass is currently active, panics elsewhere.
| buffer | Vertex buffer ID to update |
| offset | Offset in bytes from the start of the buffer |
| data | Pointer to the source data |
| size | Size of subsegment to update in bytes |
|
extern |
Overwrites index buffer data subsegment beginning at offset with size bytes from data. Can be called only if copy pass is currently active, panics elsewhere.
| buffer | Index buffer ID to update |
| offset | Offset in bytes from the start of the buffer |
| data | Pointer to the source data |
| size | Size of subsegment to update in bytes |
|
extern |
Creates a texture.
| info | Texture parameters |
|
extern |
Creates a texture from PNG or WEBP image data. The image is converted to the requested texture format. For single-channel and depth formats, the image's red channel supplies the texture value.
| image | Pointer to the encoded image data |
| size | Size of the encoded image data in bytes |
| info | Texture parameters |
|
extern |
Updates a dest texture region with data from data
| data | Pointer to the source data |
| pixels_per_row | Number of pixels per row in the source data |
| dest | Pointer to the destination texture region |
|
extern |
Generates mipmaps for a texture.
| texture | Texture ID to generate mipmaps for. |
|
extern |
Creates a sampler.
| info | Sampler parameters |
|
extern |
Creates a vertex shader from SPIR-V bytecode. Shader must use following resource sets:
| bytecode | Pointer to the bytecode |
| size | Size of the bytecode in bytes |
|
extern |
Creates a fragment shader from SPIR-V bytecode. Shader must use following resource sets:
| bytecode | Pointer to the bytecode |
| size | Size of the bytecode in bytes |
|
extern |
Creates a graphics pipeline.
| info | Pipeline parameters |
|
extern |
Pushes vertex shader uniform data for given slot. Subsequent ow_render_geometry and ow_render_geometry_indexed calls will use this data until overwritten or render pass ends. The pushed data must respect std140 layout conventions. Can be called only if render pass is currently active, panics elsewhere.
| slot | Target uniform slot |
| data | Pointer to the data to push |
| size | Size of the data in bytes |
|
extern |
Pushes fragment shader uniform data for given slot. Subsequent ow_render_geometry and ow_render_geometry_indexed calls will use this data until overwritten or render pass ends. The pushed data must respect std140 layout conventions. Can be called only if render pass is currently active, panics elsewhere.
| slot | Target uniform slot |
| data | Pointer to the data to push |
| size | Size of the data in bytes |
|
extern |
Renders geometry primitives.
| pipeline | Pipeline ID to use |
| bindings | Pointer to the bindings info |
| vertex_offset | Offset in vertices to start rendering from |
| vertex_count | Number of vertices to render |
| instance_count | Number of instances |
|
extern |
Renders geometry primitives with indices from an index buffer.
| pipeline | Pipeline ID to use |
| bindings | Pointer to the bindings info |
| index_offset | Offset in indices to start rendering from |
| index_count | Number of indices to render |
| vertex_offset | Offset in vertices to start rendering from |
| instance_count | Number of instances |
|
extern |
Gets the screen size in pixels.
| width | Pointer to the variable to store the width in pixels |
| height | Pointer to the variable to store the height in pixels |
|
extern |
Gets cursor position and mouse buttons state. The cooordinate system for cursor position is x: [0, width] and y: [0, height] where (0, 0) is a top left corner.
| x | Pointer to the variable to store the X coordinate in pixels |
| y | Pointer to the variable to store the Y coordinate in pixels |
|
extern |
Gets audio spectrum data for visualization. Output data is a normalized array of floats in the range [0, 1] of length length.
| data | Pointer to the array to store spectrum data |
| length | Length of the array |
|
extern |
Gets a scene option value by name. Returns NULL if scene option with given name is unspecified. Returns an empty string if scene option with given name is specified, but has no value. The returned string is owned by the host application and must not be freed.
| name | Name of the option to get |
|
extern |
Frees a vertex buffer by ID. Panics if vertex buffer is not found or is already freed. Does nothing if id is 0.
| id | Vertex buffer ID to free |
|
extern |
Frees an index buffer by ID. Panics if index buffer is not found or is already freed. Does nothing if id is 0.
| id | Index buffer ID to free |
|
extern |
Frees a texture by ID. Panics if texture is not found or is already freed. Does nothing if id is 0.
| id | Texture ID to free |
|
extern |
Frees a sampler by ID. Panics if sampler is not found or is already freed. Does nothing if id is 0.
| id | Sampler ID to free |
|
extern |
Frees a vertex shader by ID. Panics if vertex shader is not found or is already freed. Does nothing if id is 0.
| id | Vertex shader ID to free |
|
extern |
Frees a fragment shader by ID. Panics if fragment shader is not found or is already freed. Does nothing if id is 0.
| id | Fragment shader ID to free |
|
extern |
Frees a pipeline by ID. Panics if pipeline is not found or is already freed. Does nothing if id is 0.
| id | Pipeline ID to free |