Home | History | Annotate | Download | only in HaikuGL
      1 /*
      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 
     18 class BGLDispatcher;
     19 class GLRendererRoster;
     20 
     21 typedef unsigned long renderer_id;
     22 
     23 class BGLRenderer
     24 {
     25 							// Private unimplemented copy constructors
     26 							BGLRenderer(const BGLRenderer &);
     27 							BGLRenderer & operator=(const BGLRenderer &);
     28 
     29 public:
     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();
     39 
     40 	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 
     45 	virtual void			FrameResized(float width, float height);
     46 
     47 	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 
     55 private:
     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 
     64 	int32					fRefCount;	// How much we're still useful
     65 	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 
     73 extern "C" _EXPORT BGLRenderer* instantiate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher);
     74 
     75 
     76 #endif	// GLRENDERER_H
     77