Camlet: Command reference

Back to main page

Overview

Commands are sent by Camlet to plug-ins whenever something interesting happens. A list of all the commands and their response formats is given below. Commands beginning with _ do not have a response (and so camlet will go on without waiting for one).

_camera_connected command

Sent to plug-ins when a new camera is connected.

Arguments

_camera_disconnected command

Sent to plug-ins when a camera was disconnected.

Arguments

frame command

Sent to plug-ins every time a frame is rendered.

Arguments

Response

_grabbed command

Sent to a plug-in to indicate that a texture was grabbed successfully. When you’re done with the texture in question, you should provide it in the release argument to the frame command, otherwise it will stay around in video memory forever.

NOTE: You may get the same texture twice from this command. For example, if there are no camera shaders, then the “unprocessed” frame is the same as the “processed” frame, so the same texture will be given for both. So make sure you don’t end up releasing the same texture twice.

Arguments

init command

Sent to a plug-in when it is enabled.

Arguments

Response

Exactly one of ok or error must be provided.

_key_down command

Sent when a key was pressed.

Arguments

_key_up command

Sent when a key was released.

Arguments

_mouse_down command

Sent when a mouse button was pressed.

Arguments

_mouse_scroll command

Sent when the mouse was scrolled.

Arguments

_mouse_up command

Sent when a mouse button was released.

Arguments

photo command

Sent when a photo is about to be taken.

Arguments

Response

_photo_error command

Sent when photo saving fails, including due to being cancelled by a plug-in. To get information about the photo that would have been taken, refer to the preceding photo command.

_photo_ok command

Sent after a photo is saved to disk. To get information about the photo, refer to the preceding photo command.

_quit command

Sent when camlet quits. Note camlet will hang until the plug-in exits after sending this. After receiving this, exit as soon as possible.

_setting command

Sent once for each setting after init, then again whenever the user changes a setting.

Arguments

video_start command

Sent when a video recording is about to start. This doesn’t mean the video recording will actually start, since a plug-in may cancel it. For that, listen out for the _video_started command.

Arguments

Response

_video_started command

Sent when a video is started. To get information about the video, refer to the preceding video_start command.

_video_stop command

Sent when a video is stopped. To get information about the video, refer to the preceding video_start command.

Built-in shader variables

Some variables are automatically passed in to your shaders by camlet.

All shaders are provided with the in vec2 camlet_pos; input which is the coordinate of the pixel being rendered in convenient 0-to-1 coordinates, with (0,0) being the bottom-left of the camera feed (in the case of camera shaders) or window (in the case of overlay shaders). There is also the uniform sampler2D camlet_frame; which is the current frame to be processed. Lastly, out vec4 camlet_color; is the place where you should output the pixel color. So then a simple fragment shader which does nothing is given by

#version 130
in vec2 camlet_pos;
uniform sampler2D camlet_frame;
out vec4 camlet_color;

void main() {
    camlet_color = texture(camlet_frame, camlet_pos);
}

Identifiers starting with camlet_ are reserved for camlet and should not be used in your shaders except for the purposes described here.

Uniform syntax

This section describes the syntax of the camera_uniforms / overlay_uniforms argument.

Scalar values must be encoded in decimal. If the number contains any of .eE then it is treated as a floating-point uniform (e.g. 1e5, 3.5e+6, 0.0). Otherwise, if the number has the suffix u then it is treated as an unsigned integer (e.g. 0u). Otherwise, it is treated as a signed integer (e.g. 35, -36).

Vector values are encoded as a comma-separated list of scalar values, matrix values are encoded as a semicolon-separated list of vector values representing the columns of the matrix, array values are encoded as a pipe-separated lists of scalar/vector/matrix values. Trailing commas, semicolons, and pipes are allowed.