Skip to content

Commit c179575

Browse files
committed
Refactoring to match code conventions
1 parent 41b1f5f commit c179575

File tree

8 files changed

+512
-427
lines changed

8 files changed

+512
-427
lines changed

dependencies.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ LSP_COMMON_LIB_VERSION := 1.0.2
33
LSP_COMMON_LIB_NAME := lsp-common-lib
44
LSP_COMMON_LIB_URL := https://github.com/sadko4u/$(LSP_COMMON_LIB_NAME).git
55

6+
LSP_TEST_FW_VERSION := 1.0.2
7+
LSP_TEST_FW_NAME := lsp-test-fw
8+
LSP_TEST_FW_URL := https://github.com/sadko4u/$(LSP_TEST_FW_NAME).git
9+
10+
STDLIB_VERSION := system
11+
STDLIB_LDFLAGS := -lpthread -ldl

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

Lines changed: 133 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -5,139 +5,139 @@
55
* Author: sadko
66
*/
77

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_
1010

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>
1515

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
3317
{
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_ */

include/lsp-plug.in/r3d/base_backend.h

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,47 @@
55
* Author: sadko
66
*/
77

8-
#ifndef RENDERING_BASE_BACKEND_H_
9-
#define RENDERING_BASE_BACKEND_H_
8+
#ifndef LSP_PLUG_IN_R3D_BASE_BACKEND_H_
9+
#define LSP_PLUG_IN_R3D_BASE_BACKEND_H_
1010

11-
#include <dsp/dsp.h>
12-
#include <core/status.h>
13-
#include <core/stdlib/string.h>
14-
#include <rendering/backend.h>
11+
#include <lsp-plug.in/common/types.h>
12+
#include <lsp-plug.in/r3d/version.h>
13+
#include <lsp-plug.in/r3d/backend.h>
1514

1615
namespace lsp
1716
{
18-
typedef struct r3d_base_backend_t: public r3d_backend_t
17+
namespace r3d
1918
{
20-
matrix3d_t matProjection;
21-
matrix3d_t matView;
22-
matrix3d_t matWorld;
19+
typedef struct base_backend_t: public backend_t
20+
{
21+
mat4_t matProjection;
22+
mat4_t matView;
23+
mat4_t matWorld;
2324

24-
color3d_t colBackground;
25+
color_t colBackground;
2526

26-
ssize_t viewLeft;
27-
ssize_t viewTop;
28-
ssize_t viewWidth;
29-
ssize_t viewHeight;
27+
ssize_t viewLeft;
28+
ssize_t viewTop;
29+
ssize_t viewWidth;
30+
ssize_t viewHeight;
3031

31-
static void init_matrix_identity(matrix3d_t *m);
32-
static void matrix_mul(matrix3d_t *r, const matrix3d_t *s, const matrix3d_t *m);
32+
static void init_matrix_identity(mat4_t *m);
33+
static void matrix_mul(mat4_t *r, const mat4_t *s, const mat4_t *m);
3334

34-
explicit r3d_base_backend_t();
35+
explicit base_backend_t();
3536

36-
static status_t init(r3d_base_backend_t *_this);
37-
static void destroy(r3d_base_backend_t *_this);
37+
static status_t init(backend_t *handle);
38+
static void destroy(backend_t *handle);
3839

39-
static status_t locate(r3d_base_backend_t *_this, ssize_t left, ssize_t top, ssize_t width, ssize_t height);
40-
static status_t set_matrix(r3d_base_backend_t *_this, r3d_matrix_type_t type, const matrix3d_t *m);
41-
static status_t get_matrix(r3d_base_backend_t *_this, r3d_matrix_type_t type, matrix3d_t *m);
42-
static status_t set_bg_color(r3d_base_backend_t *_this, const color3d_t *color);
43-
static status_t get_bg_color(r3d_base_backend_t *_this, color3d_t *color);
44-
static status_t get_location(r3d_base_backend_t *_this, ssize_t *left, ssize_t *top, ssize_t *width, ssize_t *height);
40+
static status_t locate(backend_t *handle, ssize_t left, ssize_t top, ssize_t width, ssize_t height);
41+
static status_t set_matrix(backend_t *handle, matrix_type_t type, const mat4_t *m);
42+
static status_t get_matrix(backend_t *handle, matrix_type_t type, mat4_t *m);
43+
static status_t set_bg_color(backend_t *handle, const color_t *color);
44+
static status_t get_bg_color(backend_t *handle, color_t *color);
45+
static status_t get_location(backend_t *handle, ssize_t *left, ssize_t *top, ssize_t *width, ssize_t *height);
4546

46-
} r3d_base_backend_t;
47+
} base_backend_t;
48+
}
4749
}
4850

49-
#endif /* RENDERING_BASE_BACKEND_H_ */
51+
#endif /* LSP_PLUG_IN_R3D_BASE_BACKEND_H_ */

0 commit comments

Comments
 (0)