Debian Codegraph @

modules/lsp-r3d-iface/include/lsp-plug.in/r3d/iface/backend.h

raw
1 /*
2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2020 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-r3d-iface
6 * Created on: 18 апр. 2019 г.
7 *
8 * lsp-r3d-iface is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-r3d-iface is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-r3d-iface. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_R3D_IFACE_BACKEND_H_
23 #define LSP_PLUG_IN_R3D_IFACE_BACKEND_H_
24
25 #include <lsp-plug.in/r3d/iface/version.h>
26
27 #include <lsp-plug.in/common/types.h>
28 #include <lsp-plug.in/common/status.h>
29 #include <lsp-plug.in/r3d/iface/types.h>
30
31 namespace lsp
32 {
33 namespace r3d
34 {
35 /**
36 * 3D renderning backend metadata
37 */
38 typedef struct backend_metadata_t
39 {
40 const char *id; // Enumeration unique identifier
41 const char *display; // Display name
42 const char *lc_key; // Localized display name key
43 window_handle_t wnd_type; // The actual type of the native window handle
44 } backend_metadata_t;
45
46 /**
47 * 3D Rendering backend interface, just functions that should be called on
48 * a structure instance
49 */
50 typedef struct backend_t
51 {
52 /**
53 * Destroy backend
54 */
55 void (* destroy)(backend_t *_this);
56
57 /**
58 * Initialize backend as a native window, all window manipulations
59 * should be done by the host
60 * @param window native window handle to work with
61 * @param out_window pointer to store the created window handle
62 * @return status of operation
63 */
64 status_t (* init_window)(backend_t *_this, void **out_window);
65
66 /**
67 * Initialize backend as an off-screen buffer
68 * @return status of operation
69 */
70 status_t (* init_offscreen)(backend_t *_this);
71
72 /**
73 * @param left the leftmost coordinate of the backend's viewport relative to the parent window
74 * @param top the topmost coordinate of the backend's viewport relative to the parent window
75 * @param width the width of the backend's viewport
76 * @param height the heigh of the backend's viewport
77 */
78 status_t (* locate)(backend_t *_this, ssize_t left, ssize_t top, ssize_t width, ssize_t height);
79
80 /**
81 * @param left the leftmost coordinate of the backend's viewport relative to the parent window
82 * @param top the topmost coordinate of the backend's viewport relative to the parent window
83 * @param width the width of the backend's viewport
84 * @param height the heigh of the backend's viewport
85 */
86 status_t (* get_location)(backend_t *_this, ssize_t *left, ssize_t *top, ssize_t *width, ssize_t *height);
87
88 /**
89 * Start rendering on the window
90 * @return status of operation
91 */
92 status_t (* start)(backend_t *_this);
93
94 /**
95 * Complete all pending operations
96 * @return status of operation
97 */
98 status_t (* sync)(backend_t *_this);
99
100 /**
101 * Complete rendering on the window
102 * @return status of operation
103 */
104 status_t (* finish)(backend_t *_this);
105
106 /**
107 * Set transformation matrix
108 * @param type transformation matrix type
109 * @param m transformation matrix data of 16 floats (column-major)
110 * @return status of operation
111 */
112 status_t (* set_matrix)(backend_t *_this, matrix_type_t type, const mat4_t *m);
113
114 /**
115 * Get transformation matrix
116 * @param type transformation matrix type
117 * @param m pointer to retrieve transformation matrix data of 16 floats (column-major)
118 * @return status of operation
119 */
120 status_t (* get_matrix)(backend_t *_this, matrix_type_t type, mat4_t *m);
121
122 /**
123 * Set current lighting schema according to passed array of lights
124 * @param lights array of lights
125 * @param count number of lights per scene
126 * @return status of operation
127 */
128 status_t (* set_lights)(backend_t *_this, const light_t *lights, size_t count);
129
130 /**
131 * Draw data
132 * @param buffer buffer data to draw
133 * @return status of operation
134 */
135 status_t (* draw_primitives)(backend_t *_this, const buffer_t *buffer);
136
137 /**
138 * Set the default background color
139 * @param color default background color
140 * @return status of operation
141 */
142 status_t (* set_bg_color)(backend_t *_this, const color_t *color);
143
144 /**
145 * Get the default background color
146 * @param color pointer to store default background color
147 * @return status of operation
148 */
149 status_t (* get_bg_color)(backend_t *_this, color_t *color);
150
151 /**
152 * Read pixel data, should be in drawing state
153 * @param buf target buffer of the necessary size of width * height * bytes per pixel
154 * @param format pixel format
155 * @return status of operation
156 */
157 status_t (* read_pixels)(backend_t *_this, void *buf, pixel_format_t format);
158 } backend_t;
159 }
160 }
161
162 #endif /* LSP_PLUG_IN_R3D_IFACE_BACKEND_H_ */