1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
*
* This file is part of lsp-ws-lib
* Created on: 24 апр. 2019 г.
*
* lsp-ws-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* lsp-ws-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with lsp-ws-lib. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LSP_PLUG_IN_WS_IR3DBACKEND_H_
#define LSP_PLUG_IN_WS_IR3DBACKEND_H_
#include <lsp-plug.in/ws/version.h>
#include <lsp-plug.in/r3d/iface/backend.h>
#include <lsp-plug.in/ws/IDisplay.h>
namespace lsp
{
namespace ws
{
/**
* This class is a wrapper around r3d_backend_t that allows dynamic change of backend
*/
class LSP_WS_LIB_PUBLIC IR3DBackend
{
private:
IR3DBackend & operator = (const IR3DBackend &);
IR3DBackend (const IR3DBackend &);
friend class IDisplay;
protected:
r3d::backend_t *pBackend; // Currently used backend
void *hParent; // Parent window
void *hWindow; // Currently used window
IDisplay *pDisplay;
protected:
explicit IR3DBackend(IDisplay *dpy, r3d::backend_t *backend, void *parent, void *window);
void replace_backend(r3d::backend_t *factory, void *window);
public:
~IR3DBackend();
public:
status_t destroy();
/**
* Return native window handle if it is present
*/
inline void *handle() { return hWindow; };
inline bool valid() const { return pBackend != NULL; }
status_t locate(ssize_t left, ssize_t top, ssize_t width, ssize_t height);
status_t get_location(ssize_t *left, ssize_t *top, ssize_t *width, ssize_t *height);
status_t begin_draw();
status_t sync();
status_t read_pixels(void *buf, r3d::pixel_format_t format);
status_t end_draw();
status_t set_matrix(r3d::matrix_type_t type, const r3d::mat4_t *m);
status_t get_matrix(r3d::matrix_type_t type, r3d::mat4_t *m);
status_t set_lights(const r3d::light_t *lights, size_t count);
status_t draw_primitives(const r3d::buffer_t *buffer);
status_t set_bg_color(const r3d::color_t *color);
};
} /* namespace ws */
} /* namespace lsp */
#endif /* LSP_PLUG_IN_WS_IR3DBACKEND_H_ */
|