1 #pragma once
2 
3 #include "Types.h"
4 
5 namespace RTW
6 {
7     class Backend
8     {
9     public:
10         virtual ~Backend() = default;
11 
12     public:
13         virtual RTWError Init() = 0;
14         virtual void Shutdown() = 0;
15 
16         virtual bool IsSupported(RTWFeature feature) const = 0;
17 
18         virtual RTWData NewData(RTWDataType, size_t numItems) = 0;
19         virtual RTWData NewCopyData1D(const void *source, RTWDataType, size_t numItems) = 0;
20         virtual RTWData NewCopyData2D(const void *source, RTWDataType, size_t numItems1, size_t numItems2) = 0;
21         virtual RTWData NewCopyData3D(const void *source, RTWDataType, size_t numItems1, size_t numItems2, size_t numItems3) = 0;
22         virtual RTWData NewSharedData1D(const void *source, RTWDataType, uint32_t numItems) = 0;
23         virtual RTWData NewSharedData2D(const void *source, RTWDataType, uint32_t numItems1, uint32_t numItems2) = 0;
24         virtual RTWData NewSharedData3D(const void *source, RTWDataType, uint32_t numItems1, uint32_t numItems2,
25           uint32_t numItems3) = 0;
26         virtual RTWGeometry NewGeometry(const char *type) = 0;
27         virtual RTWGroup NewGroup() = 0;
28         virtual RTWTexture NewTexture(const char* type) = 0;
29         virtual RTWLight NewLight(const char *light_type) = 0;
30         virtual RTWMaterial NewMaterial(const char *renderer_type, const char *material_type) = 0;
31         virtual RTWVolume NewVolume(const char *type) = 0;
32         virtual RTWVolumetricModel NewVolumetricModel(RTWVolume volume) = 0;
33         virtual RTWTransferFunction NewTransferFunction(const char *type) = 0;
34         virtual RTWRenderer NewRenderer(const char *type) = 0;
35         virtual RTWCamera NewCamera(const char *type) = 0;
36         virtual RTWWorld NewWorld() = 0;
37         virtual RTWGeometricModel NewGeometricModel(RTWGeometry geometry) = 0;
38         virtual RTWInstance NewInstance(RTWGroup geometry) = 0;
39         virtual RTWFrameBuffer NewFrameBuffer(const rtw::vec2i &size, const RTWFrameBufferFormat format, const uint32_t frameBufferChannels) = 0;
40 
41         virtual void Release(RTWObject) = 0;
42 
43 
44         virtual void SetString(RTWObject, const char *id, const char *s) = 0;
45         virtual void SetObject(RTWObject, const char *id, RTWObject other) = 0;
46         virtual void SetObjectAsData(RTWObject target, const char *id, RTWDataType type, RTWObject obj) = 0;
47         virtual void SetParam(RTWObject, const char *id, RTWDataType type, const void* mem) = 0;
48         virtual void SetBool(RTWObject, const char *id, bool x) = 0;
49         virtual void SetInt(RTWObject, const char *id, int32_t x) = 0;
50         virtual void SetVec2i(RTWObject, const char *id, int32_t x, int32_t y) = 0;
51         virtual void SetFloat(RTWObject, const char *id, float x) = 0;
52         virtual void SetVec2f(RTWObject, const char *id, float x, float y) = 0;
53         virtual void SetVec3i(RTWObject, const char *id, int x, int y, int z) = 0;
54         virtual void SetVec3f(RTWObject, const char *id, float x, float y, float z) = 0;
55         virtual void SetVec4f(RTWObject, const char *id, float x, float y, float z, float w) = 0;
56 
57         virtual void RemoveParam(RTWObject, const char *id) = 0;
58 
59         virtual void Commit(RTWObject) = 0;
60 
61         virtual float RenderFrame(RTWFrameBuffer, RTWRenderer, RTWCamera, RTWWorld) = 0;
62 
63         virtual void FrameBufferClear(RTWFrameBuffer) = 0;
64         virtual const void* MapFrameBuffer(RTWFrameBuffer, const RTWFrameBufferChannel) = 0;
65         virtual void UnmapFrameBuffer(const void *mapped, RTWFrameBuffer) = 0;
66 
67         virtual void SetDepthNormalizationGL(RTWFrameBuffer frameBuffer, float clipMin, float clipMax) = 0;
68         virtual int GetColorTextureGL(RTWFrameBuffer frameBuffer) = 0;
69         virtual int GetDepthTextureGL(RTWFrameBuffer frameBuffer) = 0;
70     };
71 }
72