blob: a93113b171dcddfb154559a9b1adfca65e5eed75 [file] [log] [blame]
Alexander von Gluck IV56d920a2013-12-14 11:46:05 -06001/*
2 * Copyright 2006, Philippe Houdoin. All rights reserved.
3 * Distributed under the terms of the MIT License.
4
5 * This header defines BGLRenderer, the base class making up
6 * the Haiku GL renderer add-ons (essentially selfcontained C++
7 * shared libraries that do the actual rendering such as
8 * libswpipe.so and libswrast.so)
9 */
10#ifndef GLRENDERER_H
11#define GLRENDERER_H
12
13
14#include <BeBuild.h>
15#include <GLView.h>
16
17
18class BGLDispatcher;
19class GLRendererRoster;
20
21typedef unsigned long renderer_id;
22
23class BGLRenderer
24{
25 // Private unimplemented copy constructors
26 BGLRenderer(const BGLRenderer &);
27 BGLRenderer & operator=(const BGLRenderer &);
Alexander von Gluck IVe5e41202014-01-22 19:55:39 -060028
Alexander von Gluck IV56d920a2013-12-14 11:46:05 -060029public:
30 BGLRenderer(BGLView *view, ulong bgl_options,
31 BGLDispatcher *dispatcher);
32 virtual ~BGLRenderer();
33
34 void Acquire();
35 void Release();
36
37 virtual void LockGL();
38 virtual void UnlockGL();
Alexander von Gluck IVe5e41202014-01-22 19:55:39 -060039
Alexander von Gluck IV56d920a2013-12-14 11:46:05 -060040 virtual void SwapBuffers(bool VSync = false);
41 virtual void Draw(BRect updateRect);
42 virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
43 virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
44
Alexander von Gluck IVe5e41202014-01-22 19:55:39 -060045 virtual void FrameResized(float width, float height);
46
Alexander von Gluck IV56d920a2013-12-14 11:46:05 -060047 virtual void DirectConnected(direct_buffer_info *info);
48 virtual void EnableDirectMode(bool enabled);
49
50 inline int32 ReferenceCount() const { return fRefCount; };
51 inline ulong Options() const { return fOptions; };
52 inline BGLView* GLView() { return fView; };
53 inline BGLDispatcher* GLDispatcher() { return fDispatcher; };
54
55private:
56 friend class GLRendererRoster;
57
58 virtual status_t _Reserved_Renderer_0(int32, void *);
59 virtual status_t _Reserved_Renderer_1(int32, void *);
60 virtual status_t _Reserved_Renderer_2(int32, void *);
61 virtual status_t _Reserved_Renderer_3(int32, void *);
62 virtual status_t _Reserved_Renderer_4(int32, void *);
63
Alexander von Gluck IVe5e41202014-01-22 19:55:39 -060064 int32 fRefCount; // How much we're still useful
Alexander von Gluck IV56d920a2013-12-14 11:46:05 -060065 BGLView* fView; // Never forget who is the boss!
66 ulong fOptions; // Keep that tune in memory
67 BGLDispatcher* fDispatcher;// Our personal GL API call dispatcher
68
69 GLRendererRoster* fOwningRoster;
70 renderer_id fID;
71};
72
73extern "C" _EXPORT BGLRenderer* instantiate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher);
74
75
76#endif // GLRENDERER_H