xref: /haiku/src/apps/glteapot/ObjectView.h (revision 6e927a5fc080cb934e7584454f472cacf4c3e361)
1 /*
2 	Copyright 1999, Be Incorporated.   All Rights Reserved.
3 	This file may be used under the terms of the Be Sample Code License.
4 */
5 
6 #ifndef OBJECT_VIEW_H
7 #define OBJECT_VIEW_H
8 
9 #include <GL/glu.h>
10 #include <GLView.h>
11 
12 #define bmsgFPS	        'fps '
13 #define bmsgAddModel	'addm'
14 #define bmsgGouraud		'gour'
15 #define bmsgZBuffer		'zbuf'
16 #define bmsgCulling 	'cull'
17 #define bmsgTextured	'txtr'
18 #define bmsgFog			'fog '
19 #define bmsgLighting	'lite'
20 #define bmsgLights		'lits'
21 #define bmsgFilled		'fill'
22 #define bmsgPerspective	'prsp'
23 
24 enum lights {
25 	lightNone = 0,
26 	lightWhite,
27 	lightYellow,
28 	lightRed,
29 	lightBlue,
30 	lightGreen
31 };
32 
33 #define HISTSIZE 10
34 
35 class ResScroll;
36 
37 class ObjectView : public BGLView {
38 	public:
39 						ObjectView(BRect r, char* name, ulong resizingMode,
40 							ulong options);
41 						~ObjectView();
42 
43 		virtual	void	MouseDown(BPoint p);
44 		virtual	void	MessageReceived(BMessage* msg);
45 		virtual	void	AttachedToWindow();
46 		virtual	void	DetachedFromWindow();
47 		virtual	void	FrameResized(float width, float height);
48 				bool	SpinIt();
49 				int		ObjectAtPoint(BPoint p);
50 		virtual	void	DrawFrame(bool noPause);
51 		virtual	void	Pulse();
52 				void	EnforceState();
53 				bool	RepositionView();
54 
55 		sem_id			drawEvent;
56 		sem_id			quittingSem;
57 
58 	private:
59 		thread_id		fDrawThread;
60 		ResScroll*		fResScroll;
61 		BList			fObjects;
62 		BLocker			fObjListLock;
63 		uint64			fLastFrame;
64 		int32			fHistEntries,fOldestEntry;
65 		bool			fFps, fLastGouraud, fGouraud;
66 		bool			fLastZbuf, fZbuf, fLastCulling, fCulling;
67 		bool			fLastLighting, fLighting, fLastFilled, fFilled;
68 		bool			fLastPersp, fPersp, fLastTextured, fTextured;
69 		bool			fLastFog, fFog, fForceRedraw;
70 		float			fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE];
71 		float			fObjectDistance,fLastObjectDistance;
72 };
73 
74 #endif // OBJECT_VIEW_H
75