aboutsummaryrefslogtreecommitdiff
path: root/mesalib/include/HaikuGL/GLRenderer.h
blob: 7ffcc34bb12b45ee23b035000295fa4158771bf4 (plain)
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
/*
 * Copyright 2006, Philippe Houdoin. All rights reserved.
 * Distributed under the terms of the MIT License.

 * This header defines BGLRenderer, the base class making up
 * the Haiku GL renderer add-ons (essentially selfcontained C++
 * shared libraries that do the actual rendering such as
 * libswpipe.so and libswrast.so)
 */
#ifndef GLRENDERER_H
#define GLRENDERER_H


#include <BeBuild.h>
#include <GLView.h>


class BGLDispatcher;
class GLRendererRoster;

typedef unsigned long renderer_id;

class BGLRenderer
{
							// Private unimplemented copy constructors
							BGLRenderer(const BGLRenderer &);
							BGLRenderer & operator=(const BGLRenderer &);
	
public:
							BGLRenderer(BGLView *view, ulong bgl_options,
								BGLDispatcher *dispatcher);
	virtual					~BGLRenderer();

	void 					Acquire();
	void					Release();

	virtual void			LockGL();
	virtual void 			UnlockGL();
	
	virtual	void 			SwapBuffers(bool VSync = false);
	virtual	void			Draw(BRect updateRect);
	virtual status_t		CopyPixelsOut(BPoint source, BBitmap *dest);
	virtual status_t    	CopyPixelsIn(BBitmap *source, BPoint dest);

 	virtual void			FrameResized(float width, float height);
	
	virtual void			DirectConnected(direct_buffer_info *info);
	virtual void			EnableDirectMode(bool enabled);

	inline	int32			ReferenceCount() const { return fRefCount; };
	inline	ulong			Options() const { return fOptions; };
	inline	BGLView*		GLView() { return fView; };
	inline	BGLDispatcher*	GLDispatcher() { return fDispatcher; };

private:
	friend class GLRendererRoster;

	virtual status_t		_Reserved_Renderer_0(int32, void *);
	virtual status_t		_Reserved_Renderer_1(int32, void *);
	virtual status_t		_Reserved_Renderer_2(int32, void *);
	virtual status_t		_Reserved_Renderer_3(int32, void *);
	virtual status_t		_Reserved_Renderer_4(int32, void *);

	volatile int32			fRefCount;	// How much we're still usefull?
	BGLView*				fView;		// Never forget who is the boss!
	ulong					fOptions;	// Keep that tune in memory
	BGLDispatcher*			fDispatcher;// Our personal GL API call dispatcher

	GLRendererRoster*		fOwningRoster;
	renderer_id				fID;
};

extern "C" _EXPORT BGLRenderer* instantiate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher);


#endif	// GLRENDERER_H