|
5 | 5 | * Author: sadko
|
6 | 6 | */
|
7 | 7 |
|
8 |
| -#ifndef RENDERING_BACKEND_H_ |
9 |
| -#define RENDERING_BACKEND_H_ |
| 8 | +#ifndef LSP_PLUG_IN_R3D_BACKEND_H_ |
| 9 | +#define LSP_PLUG_IN_R3D_BACKEND_H_ |
10 | 10 |
|
11 |
| -#include <dsp/dsp.h> |
12 |
| -#include <core/types.h> |
13 |
| -#include <core/status.h> |
14 |
| -#include <rendering/types.h> |
| 11 | +#include <lsp-plug.in/r3d/version.h> |
| 12 | +#include <lsp-plug.in/r3d/types.h> |
| 13 | +#include <lsp-plug.in/common/types.h> |
| 14 | +#include <lsp-plug.in/common/status.h> |
15 | 15 |
|
16 |
| -using namespace lsp; |
17 |
| - |
18 |
| -typedef struct r3d_backend_metadata_t |
19 |
| -{ |
20 |
| - const char *id; // Enumeration unique identifier |
21 |
| - const char *display; // Display name |
22 |
| -} backend_metadata_t; |
23 |
| - |
24 |
| -typedef struct r3d_backend_t r3d_backend_t; |
25 |
| - |
26 |
| -#define R3D_EXPORT |
27 |
| - |
28 |
| -/** |
29 |
| - * 3D Rendering backend interface, just functions that should be called on |
30 |
| - * a structure instance |
31 |
| - */ |
32 |
| -struct r3d_backend_t |
| 16 | +namespace lsp |
33 | 17 | {
|
34 |
| - /** |
35 |
| - * Destroy backend |
36 |
| - */ |
37 |
| - void (* destroy)(r3d_backend_t *_this); |
38 |
| - |
39 |
| - /** |
40 |
| - * Initialize backend as a native window, all window manipulations |
41 |
| - * should be done by the host |
42 |
| - * @param window native window handle to work with |
43 |
| - * @param out_window pointer to store the created window handle |
44 |
| - * @return status of operation |
45 |
| - */ |
46 |
| - status_t (* init_window)(r3d_backend_t *_this, void **out_window); |
47 |
| - |
48 |
| - /** |
49 |
| - * Initialize backend as an off-screen buffer |
50 |
| - * @return status of operation |
51 |
| - */ |
52 |
| - status_t (* init_offscreen)(r3d_backend_t *_this); |
53 |
| - |
54 |
| - /** |
55 |
| - * @param left the leftmost coordinate of the backend's viewport relative to the parent window |
56 |
| - * @param top the topmost coordinate of the backend's viewport relative to the parent window |
57 |
| - * @param width the width of the backend's viewport |
58 |
| - * @param height the heigh of the backend's viewport |
59 |
| - */ |
60 |
| - status_t (* locate)(r3d_backend_t *_this, ssize_t left, ssize_t top, ssize_t width, ssize_t height); |
61 |
| - |
62 |
| - /** |
63 |
| - * @param left the leftmost coordinate of the backend's viewport relative to the parent window |
64 |
| - * @param top the topmost coordinate of the backend's viewport relative to the parent window |
65 |
| - * @param width the width of the backend's viewport |
66 |
| - * @param height the heigh of the backend's viewport |
67 |
| - */ |
68 |
| - status_t (* get_location)(r3d_backend_t *_this, ssize_t *left, ssize_t *top, ssize_t *width, ssize_t *height); |
69 |
| - |
70 |
| - /** |
71 |
| - * Start rendering on the window |
72 |
| - * @return status of operation |
73 |
| - */ |
74 |
| - status_t (* start)(r3d_backend_t *_this); |
75 |
| - |
76 |
| - /** |
77 |
| - * Complete all pending operations |
78 |
| - * @return status of operation |
79 |
| - */ |
80 |
| - status_t (* sync)(r3d_backend_t *_this); |
81 |
| - |
82 |
| - /** |
83 |
| - * Complete rendering on the window |
84 |
| - * @return status of operation |
85 |
| - */ |
86 |
| - status_t (* finish)(r3d_backend_t *_this); |
87 |
| - |
88 |
| - /** |
89 |
| - * Set transformation matrix |
90 |
| - * @param type transformation matrix type |
91 |
| - * @param m transformation matrix data of 16 floats (column-major) |
92 |
| - * @return status of operation |
93 |
| - */ |
94 |
| - status_t (* set_matrix)(r3d_backend_t *_this, r3d_matrix_type_t type, const matrix3d_t *m); |
95 |
| - |
96 |
| - /** |
97 |
| - * Get transformation matrix |
98 |
| - * @param type transformation matrix type |
99 |
| - * @param m pointer to retrieve transformation matrix data of 16 floats (column-major) |
100 |
| - * @return status of operation |
101 |
| - */ |
102 |
| - status_t (* get_matrix)(r3d_backend_t *_this, r3d_matrix_type_t type, matrix3d_t *m); |
103 |
| - |
104 |
| - /** |
105 |
| - * Set current lighting schema according to passed array of lights |
106 |
| - * @param lights array of lights |
107 |
| - * @param count number of lights per scene |
108 |
| - * @return status of operation |
109 |
| - */ |
110 |
| - status_t (* set_lights)(r3d_backend_t *_this, const r3d_light_t *lights, size_t count); |
111 |
| - |
112 |
| - /** |
113 |
| - * Draw data |
114 |
| - * @param buffer buffer data to draw |
115 |
| - * @return status of operation |
116 |
| - */ |
117 |
| - status_t (* draw_primitives)(r3d_backend_t *_this, const r3d_buffer_t *buffer); |
118 |
| - |
119 |
| - /** |
120 |
| - * Set the default background color |
121 |
| - * @param color default background color |
122 |
| - * @return status of operation |
123 |
| - */ |
124 |
| - status_t (* set_bg_color)(r3d_backend_t *_this, const color3d_t *color); |
125 |
| - |
126 |
| - /** |
127 |
| - * Get the default background color |
128 |
| - * @param color pointer to store default background color |
129 |
| - * @return status of operation |
130 |
| - */ |
131 |
| - status_t (* get_bg_color)(r3d_backend_t *_this, color3d_t *color); |
132 |
| - |
133 |
| - /** |
134 |
| - * Read pixel data, should be in drawing state |
135 |
| - * @param buf target buffer |
136 |
| - * @param stride stride between two rows |
137 |
| - * @param format pixel format |
138 |
| - * @return status of operation |
139 |
| - */ |
140 |
| - status_t (* read_pixels)(r3d_backend_t *_this, void *buf, size_t stride, r3d_pixel_format_t format); |
141 |
| -}; |
142 |
| - |
143 |
| -#endif /* RENDERING_BACKEND_H_ */ |
| 18 | + namespace r3d |
| 19 | + { |
| 20 | + typedef struct backend_metadata_t |
| 21 | + { |
| 22 | + const char *id; // Enumeration unique identifier |
| 23 | + const char *display; // Display name |
| 24 | + } backend_metadata_t; |
| 25 | + |
| 26 | + /** |
| 27 | + * 3D Rendering backend interface, just functions that should be called on |
| 28 | + * a structure instance |
| 29 | + */ |
| 30 | + typedef struct backend_t |
| 31 | + { |
| 32 | + /** |
| 33 | + * Destroy backend |
| 34 | + */ |
| 35 | + void (* destroy)(backend_t *_this); |
| 36 | + |
| 37 | + /** |
| 38 | + * Initialize backend as a native window, all window manipulations |
| 39 | + * should be done by the host |
| 40 | + * @param window native window handle to work with |
| 41 | + * @param out_window pointer to store the created window handle |
| 42 | + * @return status of operation |
| 43 | + */ |
| 44 | + status_t (* init_window)(backend_t *_this, void **out_window); |
| 45 | + |
| 46 | + /** |
| 47 | + * Initialize backend as an off-screen buffer |
| 48 | + * @return status of operation |
| 49 | + */ |
| 50 | + status_t (* init_offscreen)(backend_t *_this); |
| 51 | + |
| 52 | + /** |
| 53 | + * @param left the leftmost coordinate of the backend's viewport relative to the parent window |
| 54 | + * @param top the topmost coordinate of the backend's viewport relative to the parent window |
| 55 | + * @param width the width of the backend's viewport |
| 56 | + * @param height the heigh of the backend's viewport |
| 57 | + */ |
| 58 | + status_t (* locate)(backend_t *_this, ssize_t left, ssize_t top, ssize_t width, ssize_t height); |
| 59 | + |
| 60 | + /** |
| 61 | + * @param left the leftmost coordinate of the backend's viewport relative to the parent window |
| 62 | + * @param top the topmost coordinate of the backend's viewport relative to the parent window |
| 63 | + * @param width the width of the backend's viewport |
| 64 | + * @param height the heigh of the backend's viewport |
| 65 | + */ |
| 66 | + status_t (* get_location)(backend_t *_this, ssize_t *left, ssize_t *top, ssize_t *width, ssize_t *height); |
| 67 | + |
| 68 | + /** |
| 69 | + * Start rendering on the window |
| 70 | + * @return status of operation |
| 71 | + */ |
| 72 | + status_t (* start)(backend_t *_this); |
| 73 | + |
| 74 | + /** |
| 75 | + * Complete all pending operations |
| 76 | + * @return status of operation |
| 77 | + */ |
| 78 | + status_t (* sync)(backend_t *_this); |
| 79 | + |
| 80 | + /** |
| 81 | + * Complete rendering on the window |
| 82 | + * @return status of operation |
| 83 | + */ |
| 84 | + status_t (* finish)(backend_t *_this); |
| 85 | + |
| 86 | + /** |
| 87 | + * Set transformation matrix |
| 88 | + * @param type transformation matrix type |
| 89 | + * @param m transformation matrix data of 16 floats (column-major) |
| 90 | + * @return status of operation |
| 91 | + */ |
| 92 | + status_t (* set_matrix)(backend_t *_this, matrix_type_t type, const mat4_t *m); |
| 93 | + |
| 94 | + /** |
| 95 | + * Get transformation matrix |
| 96 | + * @param type transformation matrix type |
| 97 | + * @param m pointer to retrieve transformation matrix data of 16 floats (column-major) |
| 98 | + * @return status of operation |
| 99 | + */ |
| 100 | + status_t (* get_matrix)(backend_t *_this, matrix_type_t type, mat4_t *m); |
| 101 | + |
| 102 | + /** |
| 103 | + * Set current lighting schema according to passed array of lights |
| 104 | + * @param lights array of lights |
| 105 | + * @param count number of lights per scene |
| 106 | + * @return status of operation |
| 107 | + */ |
| 108 | + status_t (* set_lights)(backend_t *_this, const light_t *lights, size_t count); |
| 109 | + |
| 110 | + /** |
| 111 | + * Draw data |
| 112 | + * @param buffer buffer data to draw |
| 113 | + * @return status of operation |
| 114 | + */ |
| 115 | + status_t (* draw_primitives)(backend_t *_this, const buffer_t *buffer); |
| 116 | + |
| 117 | + /** |
| 118 | + * Set the default background color |
| 119 | + * @param color default background color |
| 120 | + * @return status of operation |
| 121 | + */ |
| 122 | + status_t (* set_bg_color)(backend_t *_this, const color_t *color); |
| 123 | + |
| 124 | + /** |
| 125 | + * Get the default background color |
| 126 | + * @param color pointer to store default background color |
| 127 | + * @return status of operation |
| 128 | + */ |
| 129 | + status_t (* get_bg_color)(backend_t *_this, color_t *color); |
| 130 | + |
| 131 | + /** |
| 132 | + * Read pixel data, should be in drawing state |
| 133 | + * @param buf target buffer |
| 134 | + * @param stride stride between two rows |
| 135 | + * @param format pixel format |
| 136 | + * @return status of operation |
| 137 | + */ |
| 138 | + status_t (* read_pixels)(backend_t *_this, void *buf, size_t stride, pixel_format_t format); |
| 139 | + } backend_t; |
| 140 | + } |
| 141 | +} |
| 142 | + |
| 143 | +#endif /* LSP_PLUG_IN_R3D_BACKEND_H_ */ |
0 commit comments