flo_render/action/
render_action.rs

1use super::color::*;
2use super::identities::*;
3use super::blend_mode::*;
4use super::shader_type::*;
5use super::render_target_type::*;
6
7use crate::buffer::*;
8
9use std::ops::{Range};
10use std::sync::*;
11
12///
13/// Represents an action for a render target
14///
15#[derive(Clone, PartialEq, Debug)]
16pub enum RenderAction {
17    ///
18    /// Sets the transformation matrix to use for future renderings
19    ///
20    SetTransform(Matrix),
21
22    ///
23    /// Creates a vertex buffer with the specified 2D vertices in it (replacing any existing buffer)
24    ///
25    CreateVertex2DBuffer(VertexBufferId, Vec<Vertex2D>),
26
27    ///
28    /// Creates an index buffer with the specified 2D vertices in it (replacing any existing buffer)
29    ///
30    CreateIndexBuffer(IndexBufferId, Vec<u16>),
31
32    ///
33    /// Frees an existing vertex buffer
34    ///
35    FreeVertexBuffer(VertexBufferId),
36
37    ///
38    /// Frees an existing index buffer
39    ///
40    FreeIndexBuffer(IndexBufferId),
41
42    ///
43    /// Sets the blend mode for future drawing operations (SourceOver is the default)
44    ///
45    BlendMode(BlendMode),
46
47    ///
48    /// Creates a new render target of the specified size, as the specified texture
49    ///
50    CreateRenderTarget(RenderTargetId, TextureId, usize, usize, RenderTargetType),
51
52    ///
53    /// Frees up an existing render target
54    ///
55    FreeRenderTarget(RenderTargetId),
56
57    ///
58    /// Send future rendering instructions to the specified render target
59    ///
60    SelectRenderTarget(RenderTargetId),
61
62    ///
63    /// Send future rendering instructions to the main frame buffer
64    ///
65    RenderToFrameBuffer,
66
67    ///
68    /// Display the current frame buffer on-screen
69    ///
70    ShowFrameBuffer,
71
72    ///
73    /// Renders the specified framebuffer to the current framebuffer
74    ///
75    DrawFrameBuffer(RenderTargetId, i32, i32),
76
77    ///
78    /// Creates an 8-bit BGRA 2D texture of the specified size
79    ///
80    CreateTextureBgra(TextureId, usize, usize),
81
82    ///
83    /// Creates an 8-bit monochrome 2D texture of the specified size
84    ///
85    CreateTextureMono(TextureId, usize, usize),
86
87    ///
88    /// Creates a 1 dimensional 8-bit BGRA texture of the specified size
89    ///
90    Create1DTextureBgra(TextureId, usize),
91
92    ///
93    /// Creates a 1 dimensional 8-bit monochrome texture of the specified size
94    ///
95    Create1DTextureMono(TextureId, usize),
96
97    ///
98    /// Given a region in a 2D texture and a set of bytes to write, updates the texture with those bytes
99    ///
100    WriteTextureData(TextureId, (usize, usize), (usize, usize), Arc<Vec<u8>>),
101
102    ///
103    /// Given a region in a 1D texture and a set of bytes to write, updates the texture with those bytes
104    ///
105    WriteTexture1D(TextureId, usize, usize, Arc<Vec<u8>>),
106
107    ///
108    /// Generates mip-maps for the specified texture ID
109    ///
110    CreateMipMaps(TextureId),
111
112    ///
113    /// Copies a texture from a source ID to a target ID (replacing any existing texture at that ID)
114    ///
115    /// Mipmap levels are not copied by this operation, so would need to be regenerated
116    ///
117    CopyTexture(TextureId, TextureId),
118
119    ///
120    /// Frees up an existing texture
121    ///
122    FreeTexture(TextureId),
123
124    ///
125    /// Clears the current render target to the specified colour
126    ///
127    Clear(Rgba8),
128
129    ///
130    /// Uses the specified shader
131    ///
132    UseShader(ShaderType),
133
134    ///
135    /// Renders triangles from a vertex buffer (with no texture)
136    ///
137    /// Parameters are the range of vertices to use
138    ///
139    DrawTriangles(VertexBufferId, Range<usize>),
140
141    ///
142    /// Renders triangles using an index buffer
143    ///
144    DrawIndexedTriangles(VertexBufferId, IndexBufferId, usize)
145}